CRM 2011 - Custom Button (Save and Calculate) RRS feed

  • Question

  • I create a custom ribbon button to calculate some values, but before calculating I need to save the record (through JavaScript)
    How can I apply that?
    Note that after saving ,the form will be loaded and the custom function will not be executed.
    Thursday, June 12, 2014 1:13 PM

All replies

  • You can call Xrm.Page.save()


    If it's CRM 2013 you can even call the save asynchronously.

    Thursday, June 12, 2014 4:53 PM
  • As you are using ms crm 2011, you can implement a workaround using a flag that you can set if calculation required and on onload you can check your flag if it is try calculate (write the same logic).

    Our Website| Our Blog | Follow US | My Facebook Page | Microsoft Dynamics CRM 2011 Application Design
    Make sure to "Vote as Helpful" and "Mark As Answer",if you get answer of your question.

    Friday, June 13, 2014 5:10 AM
  • Hi Rita,

    As had been said, in CRM 2011 you can implement this by setting a boolean hidden value on the form and then saving the record. On load you can then have code that fires if that boolean is set to yes (and set it back to no so it does not keep firing).

    In CRM 2013 this becomes a bit trickier with their new way of implementing save events. However what will work for both systems, and will be a more reliable way of handling it would be to have your JavaScript set a hidden boolean flag and save the record, and then have a plugin trigger when that boolean field is saved to do your calculation behind the scenes. This will give you access to the values before and after the update (if necessary). This might be overkill for your specific requirement, but it is always good to weigh up you're options. :)

    Your plugin would also need to set that boolean flag back to no.

    ~ Atomic Coder

    Saturday, June 14, 2014 9:08 PM