Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Save and Refresh a Quote form from HTML button

(0) ShareShare
ReportReport
Posted on by

Hi,

I created an html button, I do simple calculations and want to save and refresh the form so the user does not have to?

I've tried.

formContext.data.entity.save("save");

and
Xrm.Page.data.entity.save();

and
//setTieout(function () {
//Xrm.Page.data.save().then(closeemailform, errorCallback);
//}, 6000);

I even tried this as it was the only thing that worked on a CRM form, but not in the html form.

Xrm.Page.data.refresh(true);

Any ideas?

*This post is locked for comments

  • Suggested answer
    Kokulan Profile Picture
    18,054 on at
    RE: Save and Refresh a Quote form from HTML button

    Hi

    Is there any particular reason for the first refresh?

    The reason for the value reverting is that you have not forced a save after you set the values.  Since you called the refresh, it reloaded the page again displaying old value.

    If these fields are on Quote itself, you dont need the second refresh i think

  • Emad Hanna Profile Picture
    on at
    RE: Save and Refresh a Quote form from HTML button

    Hi, all of the sudden I'm getting a very strange behavior.  I was updating a field and then the now the field reverts to it's previous value.

    For example the field had a $5 and when I press my button it changes it to $10, but then instantly it reverts back to $5.  It's the craziest thing?

    Here is my code.

      function CalcMarginButtonClick()

    {

                         //refresh before getting the new number

                         parent.Xrm.Page.data.refresh(true);

                      var MarTotal = window.parent.Xrm.Page.getAttribute("new_margin_total").getValue();

                      var TotalAmt = window.parent.Xrm.Page.getAttribute("totalamount").getValue();

                      var Frieght = window.parent.Xrm.Page.getAttribute("aaise_freightcost").getValue();

                      var Tax = window.parent.Xrm.Page.getAttribute("totaltax").getValue();

                       if (TotalAmt  != 0 || MarTotal != 0)

                           {

                               var Margin= window.parent.Xrm.Page.getAttribute("new_marginofrevenue").getValue();

                               var MarRev = (MarTotal/(TotalAmt - Frieght - Tax)) * 100;

                               window.parent.Xrm.Page.getAttribute("new_marginofrevenue").setValue(MarRev);

                               window.parent.Xrm.Page.getAttribute("new_marginofrevenue").setSubmitMode("always");

                               parent.Xrm.Page.data.refresh(true);

                            }

  • Emad Hanna Profile Picture
    on at
    RE: Save and Refresh a Quote form from HTML button

    That was the missing piece thank you again Kokulan.

  • Verified answer
    Kokulan Profile Picture
    18,054 on at
    RE: Save and Refresh a Quote form from HTML button

    Hi

    Could you please try parent.Xrm.Page.data.refresh(true); from your webresource?

    ScreenClip-_5B00_322_5D00_.png

    https://docs.microsoft.com/en-us/dynamics365/customer-engagement/developer/webpage-html-web-resources

    I have responded to your other post about refreshing the quote form, not sure if you have tried that as well.

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

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Kudos to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Microsoft Dynamics CRM (Archived)

#1
Mohamed Amine Mahmoudi Profile Picture

Mohamed Amine Mahmoudi 83 Super User 2025 Season 1

#2
Community Member Profile Picture

Community Member 52

#3
Victor Onyebuchi Profile Picture

Victor Onyebuchi 6

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans