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 :
Service | Customer Service, Contact Center, Fie...
Answered

Xrm.Page.data.save

(0) ShareShare
ReportReport
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
}

})();

I have the same question (0)
  • Suggested answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at

    Hello,

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

  • Verified answer
    Bipin D365 Profile Picture
    28,983 Moderator on at

    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/

  • andrescr Profile Picture
    15 on at

    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.

  • Suggested answer
    Amit Katariya007 Profile Picture
    10,409 Super User 2025 Season 2 on at

    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

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 > Service | Customer Service, Contact Center, Field Service, Guides

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 45 Super User 2025 Season 2

#2
Daniyal Khaleel Profile Picture

Daniyal Khaleel 27 Most Valuable Professional

#3
Soundari Profile Picture

Soundari 15

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans