web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / How to save modificati...
Power Apps
Unanswered

How to save modification on page onload on quotedetail page?

(0) ShareShare
ReportReport
Posted on by 29

Hello everyone,

i have very important task, i am stuck in this, please help me in this.

 

Dyna03_1-1663740303108.png

 

this is my quote product, in this product have spec tab which is related to quote product  specification.

 

when ever i update or modified this specification and save this quote product , and then reload the page, then changes are gone.

 

i want do the JavaScript code on page onload event, and i want changes when i refresh a page.

 

Thanks

 

 

I have the same question (0)
  • Ben Thompson Profile Picture
    1,400 on at

    Are these items all part of the same table or are some of the fields being pulled from a different table for display purposes?

    And you say you want to use a Javascript an onload event - does that code currently exist and what does it do?

  • Mira Ghaly Profile Picture
    11,413 Moderator on at

    @Dyna03 

    Specifications looks like a field on the from of quote product..is that correct?

    I don't understand what you need from the onload event as in normal scenarios this should be reflected automatically upon save you can see the new changes.

     

    I believe there might be something in the background clearing the field value.

     

  • Gowri Halan Profile Picture
    262 on at

    @Dyna03 If you are setting that field value via Javascript on Onload event for the first time, Then put in form type(create form, update form) condition.

    Or if you want to set that field when it does not contains any data then add null check.

    If you manually filling the field and it is getting removed when form is loading then you need to check for existing JS registered on that form has logic on that particular field.

  • Ram Prakash Duraisamy Profile Picture
    5,593 Super User 2025 Season 2 on at

    Hi @Dyna03 

     

    You can use IsDirty function to get the unsaved field logical name and proceed your steps.

     

    Syntax :

     

    Xrm.Page.data.entity.getIsDirty()

     

     

    Url for Reference: https://carldesouza.com/checking-isdirty-dynamics-365-using-javascript/

     

     

    Please mark as Answer if it is helpful and provide Kudos


    Subscribe : https://www.youtube.com/channel/UCnGNN3hdlKBOr6PXotskNLA
    Follow me on Twitter : @rampprakashd
    Blog : https://microsoftcrmtechie.blogspot.com

     

  • Dyna03 Profile Picture
    29 on at

    @gowrihalan04  yes i have alread one js on form onload event

    belove is code on quoteine onload 

    function onLoadSetSpec(executionContext) {
    	debugger;
    	var formContext = executionContext.getFormContext();
    	var quoteLookup = formContext.getAttribute("quoteid").getValue();
    	var quoteDetailIDAX = formContext.getAttribute("sar_quotedetailidax").getValue();
    	if ((quoteLookup != null)) {
    		var quoteGUID = quoteLookup[0].id;
    		quoteGUID = quoteGUID.replace('{', '').replace('}', '');
    
    		Xrm.WebApi.online.retrieveRecord("quote", quoteGUID, "?$select=name,revisionnumber,sar_quoteidax,statecode").then(
    			function success(result) {
    				var name = result["name"];
    				var revisionnumber = result["revisionnumber"];
    				var revisionnumber_formatted = result["revisionnumber@OData.Community.Display.V1.FormattedValue"];
    				var quoteIDAX = result["sar_quoteidax"];
    				var statecode = result["statecode"];
    				var statecode_formatted = result["statecode@OData.Community.Display.V1.FormattedValue"];
    
    				var previousRevionNumber = revisionnumber - 1
    
    				Xrm.WebApi.online.retrieveMultipleRecords("quote", "?$filter=revisionnumber eq " + previousRevionNumber+ " and statecode eq 3 and sar_quoteidax eq '" + quoteIDAX + "'").then(
    					function success(results) {
    						for (var i = 0; i < results.entities.length; i++) {
    							var quoteid = results.entities[i]["quoteid"];
    							//alert("Last Close Quote : " + quoteid);
    							if (quoteid != null) {
    								Xrm.WebApi.online.retrieveMultipleRecords("quotedetail", "?$select=quotedetailid,quotedetailname,_quoteid_value,sar_specificationsenglish,sar_specificationsfrench,sar_specsreviewed&$filter=_quoteid_value eq '" + quoteid + "' and sar_quotedetailidax eq '" + quoteDetailIDAX + "'").then(
    									function success(results) {
    										for (var i = 0; i < results.entities.length; i++) {
    											var quotedetailid = results.entities[i]["quotedetailid"];
    											var quotedetailname = results.entities[i]["quotedetailname"];
    											var _quoteid_value = results.entities[i]["_quoteid_value"];
    											var _quoteid_value_formatted = results.entities[i]["_quoteid_value@OData.Community.Display.V1.FormattedValue"];
    											var _quoteid_value_lookuplogicalname = results.entities[i]["_quoteid_value@Microsoft.Dynamics.CRM.lookuplogicalname"];
    											var sar_specificationsenglish = results.entities[i]["sar_specificationsenglish"];
    											var sar_specificationsfrench = results.entities[i]["sar_specificationsfrench"];
    											var sar_specsreviewed = results.entities[i]["sar_specsreviewed"];
    											var sar_specsreviewed_formatted = results.entities[i]["sar_specsreviewed@OData.Community.Display.V1.FormattedValue"];
     formContext.getAttribute("sar_specificationsenglish").setValue(sar_specificationsenglish);
    							 formContext.getAttribute("sar_specificationsfrench").setValue(sar_specificationsfrench);
    										}
    									},
    									function(error) {
    										Xrm.Utility.alertDialog(error.message);
    									}
    								);
    							}
    						}
    					},
    					function(error) {
    						Xrm.Utility.alertDialog(error.message);
    					}
    				);
    
    			},
    			function(error) {
    				Xrm.Utility.alertDialog(error.message);
    			}
    		);
    	}
    }

     

     

    I have 2 custom field in quoteline- sar_specificationsenglish and  sar_specificationsfrench

     

    if a update this 2 field on quoteline and save quote line and after revise a quote, then changes were gone.

    so i write that code for revise quote. 

     

    Now the problem with draft quote.

     

    my quote is on draft state, and i modified those two field on quoteline. and save that form.

     

    after refresh this page, then changes are gone 

     

    so what to do for this issue

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 796 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 327 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard