How can I update form field on Microsoft CRM Online via Javascript

I've just created a custom order form on the Microsoft Dynamics CRM Online.

Basically, I'd like to update Total Amount field as multiply of Quantity and Amount Field. I think I can do this via Javascripts. I just opened Quantity Field Properties menu and reach Events menu. It requires to select a js library and write right function. I'm quite sure it's too much easy, however, I do not know how to do.

Basically:

Update Amount Field X Quantity Field should be = Total Amount Field value. My script should run on Quantity Field on Change event.

Answers:

Answer

Here is info on how to setup the javascript for your forms: microsoft's form programming reference

the code for your calculation will look something like this:

var amount = Xrm.Page.getAttribute("youramountfieldname").getValue();
var quantity = Xrm.Page.getAttribute("yourquantityfieldname").getValue();

var totalamount = amount * quantity;
Xrm.Page.getAttribute("yourtotalamountfieldname").setValue(totalamount);
Answer
  1. The code needs tobe encapsulated as a JS function and then needs to be created as a Web Resource
  2. The web resource needs to be associated with your form
  3. You can then assign a function name to the appropriate event handler within your form.

Useful walkthrough: http://ayazahmad.wordpress.com/2011/05/25/javascript-libraries-in-microsoft-dynamics-crm-2011/

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us Javascript

©2020 All rights reserved.