Within a form, I have a IFrame. This IFrame list all associated entities with a button to "Enable" the entity. OnClick for the entity it uses the API to send a PATCH on the value of the entity. So far so good.
Back to the form, I have a counter that counts % of enabled entities associated with the (parent) entity in the form. But upon clicking "Enable" that entity gets a updated value, but it is not saved? In Dynamics, if I open up the child entity the value is changed but the notification down in the right side states that there are unsaved changes.
How can I fetch, update and save a underlying entity of while in another form?
*This post is locked for comments
I resolved the problem. I was doing it right, the RESTful API saves the entity. The problem was that we had business rule in the entity where another parameters value was decided by the value I changed. I did not to this, so when I entered the entity the business logic ran and changed the second parameter and that is why I got the notification that there were unsaved changes. Setting the value and setting the second value so it matches the result of the business rule solves the problem :-)
Hi,
Try using XrmServiceToolkit.Soap for this. Use the code below.
//Update Entity var updateEntity = new XrmServiceToolkit.Soap.BusinessEntity("EntityName", entityGuid); //Lookup to update updateEntity.attributes["fieldName"] = { id: entityGuid, logicalName: 'entityName', type: 'EntityReference' }; //OptionSet updateEntity.attributes["fieldName"] = { value: Value, type: 'OptionSetValue' }; //Currency updateEntity.attributes["fieldName"] = { value: Value, type: 'Money' }; //Boolean updateEntity.attributes["fieldName"] = { value: true/false, type: 'boolean' }; //String updateEntity.attributes["fieldName"] = "Value"; updateEntity.attributes["fieldName"] = { Value: 2, type: "int" }; updateEntity.attributes["fieldName"] = { Value: 1.5617, type: "double" }; var updateResponse = XrmServiceToolkit.Soap.Update(updateEntity);
You should also register XrmServiceToolkit.js library in the Form Properties.
See: https://xrmservicetoolkit.codeplex.com/
Hope this helps.
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,240 Super User 2024 Season 2
Martin Dráb 230,149 Most Valuable Professional
nmaenpaa 101,156