web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

How to trigger Javascript to execute from server

(0) ShareShare
ReportReport
Posted on by

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

I have the same question (0)
  • Suggested answer
    jlattimer Profile Picture
    24,562 on at
    RE: How to trigger Javascript to execute from server

    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.

  • Daniel at VNS Profile Picture
    on at
    RE: How to trigger Javascript to execute from server

    Thank you Jason

  • Verified answer
    Josh Auton Profile Picture
    on at
    RE: How to trigger Javascript to execute from server

    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.

  • Suggested answer
    Community Member Profile Picture
    on at
    RE: How to trigger Javascript to execute from server

    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.

  • Daniel at VNS Profile Picture
    on at
    RE: How to trigger Javascript to execute from server

    Thank you Josh and Mohd.

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…

Pallavi Phade – Community Spotlight

We are honored to recognize Pallavi Phade as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
UllrSki Profile Picture

UllrSki 2

#1
Community Member Profile Picture

Community Member 2

#3
SC-08081331-0 Profile Picture

SC-08081331-0 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans