web
You’re offline. This is a read only version of the page.
close
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

I have the same question (0)
  • Verified answer
    Kokulan Profile Picture
    18,054 on at

    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.

  • Emad Hanna Profile Picture
    on at

    That was the missing piece thank you again Kokulan.

  • Emad Hanna Profile Picture
    on at

    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);

                            }

  • Suggested answer
    Kokulan Profile Picture
    18,054 on at

    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

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans