0
votes

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?

2
What triggers this functionality? This appears to be something that you would want to do with SQL or using ExecuteMultiple through the services.Zach Mast

2 Answers

0
votes

Xrmservicestoolkit has functionality that you can use to perform rest and soap queries.

once you have the library installed and referenced it's a matter of creating the fetchxml request, performing the math, then writing it to the "total" field.

the query will look something like this:

var query = "<fetch mapping='logical'>" + "<entity name='customentity'>" + "<attribute name="field1" />" + "<attribute name="field2" />" + "</entity>" + "</fetch>";
var result = XrmServiceToolkit.Soap.Fetch(query);

from that point you just have to add all the values and then write it to the proper field. Let me know if you have trouble.

keep in mind that by performing this using javascript will only update the latest record created, and not all of them.

0
votes

With CrmRestKit you can retrieve (CrmRestKit.ByQuery()) all the records you want to update

http://www.dynamic-crm.com/javascript-in-crm-2011/

https://crmrestkit.codeplex.com/documentation