Hello,
We are using Dynamics CRM (on Premise) version 9.0.28.1.
I have a very simple javascript that gets the Record Id, puts it in a field and saves the form. This is set to run on load in event handlers as I need to make sure the Record Id field is populated prior to workflows that run that require the field. That said, we have been transitioning over to Unified Interface and with this Function running, I'm hitting a few issues:
- The forms this runs on have required fields that must be filled out before the form is saved. Since the Function runs on load, we get the /A required field cannot be empty/ warning on all fields.
- When the record is saved, we get an error saying /Saving in Progress/.
The JavaScript Code is:
function PopulateGUID()
{
Xrm.Page.getAttribute(/ds_guid/).setValue(Xrm.Page.data.entity.getId().replace(/}/,//).replace(/{/,//));
Xrm.Page.data.entity.save();
}
From the bit of reading I've done it looks like I should transition to using formContext or something, but I am not 100% familiar with this. Any guidance or example of how I can make it so that I get the record id, populate it in a field and save the form on load without getting the issues above would be much appreciated.