Skip to main content

Notifications

Announcements

No record found.

Service | Customer Service, Contact Center, Fie...
Answered

Xrm.Page.data.save

Posted on by 5

I am trying to write JS code to save the record based on a specific value. The purpose is to save the record before it is submitted in order for the sub-grid to be accessible. In other words, I do not want to depend on user to manually save the record in order for them to provide more information in the sub-grid. I figure if I force a save, then the sub-grid would be available prior to actually submitting the record.

Here is what I have so far. I am just learning JS which would explain my issue of applying the correct syntax. I have not incorporated any error handling at this point. When this code runs, I get an error message that the web resource does not exist. I have applied the event on the field.

var eCIR = (function ()
{
var saveOnFieldChange = function(execContext)
{
if (Xrm.Page.getAttribute("cir_closecontactacknowledgement").getValue() == 100000000)
{
Xrm.Page.data.save();
}
};

return
{
saveOnFieldChange : saveOnFieldChange
}

})();

  • Suggested answer
    Amit Katariya007 Profile Picture
    Amit Katariya007 8,525 Super User 2024 Season 1 on at
    RE: Xrm.Page.data.save

    Hello,

    You can refer below article for the customization which requires JS.

    Views : docs.microsoft.com/.../display-custom-icons-instead

    Form : www.codeproject.com/.../Improve-user-experience-by-styling-and-coloring-Mi

    Fields on the form : www.quantacrm.com/.../

    Thank you,

    Amit Katariya

  • andrescr Profile Picture
    andrescr 15 on at
    RE: Xrm.Page.data.save

    Hi Bipin Kumar

    What if we want to change the color in view mode and not in the form? Can this be done?

    That is, change the color of a value of such a column, depending on the value of another column. We are talking about the same entity. Example:

    I have an option set column, Yes/No (picklistType)

    Any record that has No, the value that is in the Student ("student") column changes to a color.

    Thank you so much.

  • Verified answer
    Bipin D365 Profile Picture
    Bipin D365 28,964 Super User 2024 Season 1 on at
    RE: Xrm.Page.data.save

    Hi,

    If you are using Version 9 Onpremise/Online version of Dynamics CRM then do not use Xrm.Page because it is deprecated.

    I have updated your code to use formcontext -

    function saveOnFieldChange(execContext)

    {

    var formContext=execContext.getFormContext();

    if (formContext.getAttribute("cir_closecontactacknowledgement").getValue() == 100000000)

    {

    formContext.data.save();

    }

    }

    Now on your Event Handler in Function Name put - saveOnFieldChange

    Please mark my answer verified if this is helpful!

    Regards,

    Bipin Kumar

    Follow my Blog: xrmdynamicscrm.wordpress.com/

  • Suggested answer
    a33ik Profile Picture
    a33ik 84,323 Most Valuable Professional on at
    RE: Xrm.Page.data.save

    Hello,

    Your code looks correct. Can you please provide a screenshot that demonstrates how you register the event handler?

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans