locked
Java script Function for update one Field for all Record in entity RRS feed

  • Question

  • Aim:Need to update field using javascript using SOAP or REST.

    Available Fields in Form : Total,Field1,Field2

    Question: I have three fields in custom Entity Form Total,Field1,Field2. I need to update Total field with addition of Field1 &                         Field 2.If the javascript execute means need to update total field value for all records which is available in a Entity.

    How to do this?Is possible to using FetchXml in javascript?

    Thursday, November 13, 2014 11:24 AM

All replies

  • You can write a simple javascript to add two fields and put their sum in total field.

    var field1 = Xrm.Page.getAttribute("field1").getValue();
    var field2 = Xrm.Page.getAttribute("field2").getValue();
    
    var sum = field1 + field2
    
    Xrm.Page.getAttribute("total").setValue(sum);

    You can call this function on change of field1 and field2.

    You don't need to write fetchxml to get values from same entity.

    However this is client side code so it will run when you open and change the record so old records will not be updated.


    Regards, Saad

    Thursday, November 13, 2014 11:41 AM
  • Yes, This is possible with  Simple Javascript if you are working on Single Record.

    Saad ^^ pretty much explained it.

    Although, if you need to update the older records with total value, then you must use plugin i guess.

    Here are the resources to help you get Started if you are not yet familiar with MS CRM:)

    JavaScript Codes :- http://garethtuckercrm.com/2011/03/16/jscript-reference-for-microsoft-dynamics-crm-2011/

    MS All products training kit Links
    http://jtabadero.wordpress.com/2012/09/11/free-microsoft-developer-training-kits/

    CRM notes and Blogs

    http://erikpool.blogspot.in/

    http://www.mscrmconsultant.com
    http://balarajann.blogspot.in/?view=flipcard

    Curah
    https://curah.microsoft.com/31635/microsoft-dynamics-crm-2013-helpful-resources

    "If you Liked My Post , please Propose as answer for Helping you :)"

    Thank you :)

    • Proposed as answer by Sreekanth P Thursday, November 13, 2014 12:06 PM
    Thursday, November 13, 2014 11:57 AM