Skip to main content

Notifications

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

  • RE: How to trigger Javascript to execute from server

    Thank you Josh and Mohd.

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee 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.

  • Verified answer
    Josh Auton Profile Picture
    Josh Auton 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.

  • RE: How to trigger Javascript to execute from server

    Thank you Jason

  • Suggested answer
    jlattimer Profile Picture
    jlattimer 24,558 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.

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Congratulations to the January Top 10 leaders!

Check out the January community rock stars...

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,996 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,853 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans