We have some JS that does some mathematical functions on an entity form onload/onsave. We had to do it via JS because the field does calculations based on other calculated fields, so the option to use a calculated field was not available to us. It also does some if/else that I could not find a way to execute with calculated fields anyway.
Problem is, we need to apply it to every form. Expecting anyone to manually open/save thousands of records is obviously not realistic.
I think that in a case like this, a plugin would be the right solution but I am not a coder and don't have a clue where to start on a plugin. So I have to try and find a solution with the tools and skills I do have.
That said, I'd looked at workflows and do not see anything that would open a record (so that the JS could execute client-side), then save the record, en-masse.
Am I missing anything that might do this for me OOB, or would a plug-in be my only option?
Thank you
*This post is locked for comments
Thank you Josh and Mohd.
If it's a On Premise System then you can use SQL update. But you have to be very careful and take backups before updating.
You can also download the data in an excel and calculate in excel and reimport it.
You could use XrmServiceToolkit.js library to do what you need to do. I would use the XrmServiceToolkit.Rest.RetrieveMultiple() to get all the records that need to be updated and then use the XrmServiceToolkit.Rest.Update() to update them all. I don't know if using the restful endpoints is considered doing is server side or not but this is how you would do it in javascript.
Feel free to reach out if you need a little more guidance.
Thank you Jason
Short answer - you can't execute JavaScript from the server since in runs in the browser.
If you need to update 1000's of records, you be better off using a stand alone application with the calculations to run once and update all the records. Going forward using a plug-in would be a good option because it does run on the server so any data changes that might come in via an integration or something outside the browser would still cause the calculation to be made.
André Arnaud de Cal...
291,996
Super User 2025 Season 1
Martin Dráb
230,853
Most Valuable Professional
nmaenpaa
101,156