Does anyone know of sample code to update the rollupfields (in the current entity) using Web Api?
I've got the basic pages about it, but could do with a sample to get myself going in the right direction.
Thanks
Lee
Does anyone know of sample code to update the rollupfields (in the current entity) using Web Api?
I've got the basic pages about it, but could do with a sample to get myself going in the right direction.
Thanks
Lee
Thank you
You have to do a new one every time.
One last question, I've got 5 fields I need to do, can I just add them to the same string (the line begining req.open(GET
or will i have to do a new one every time?
You are welcome.
Yep, put the right id in instead of incidentid in your code and it works fine
Thanks for your help
I think I've got it, I've left some code dependant on your system, where i should change it that on mine.
function recaclulateRollupField(executionContext) { var formContext = executionContext.getFormContext(); var recordId = formContext.data.entity.getId().replace("{", "").replace("}", ""); var entityLogicalName = formContext.data.entity.getEntityName(); var lastReviewRollup = "can_lastreview"; console.log("Lee - " lastReviewRollup); var req = new XMLHttpRequest(); // console.log(calculatedRollupFieldReq); req.open("GET", Xrm.Utility.getGlobalContext().getClientUrl() '/api/data/v9.2/CalculateRollupField(Target=@Target,FieldName=@FieldName)?@Target={"incidentid":"' recordId '","@odata.type":"Microsoft.Dynamics.CRM.' entityLogicalName '"}&@FieldName=\'' lastReviewRollup '\'', true); req.setRequestHeader("OData-MaxVersion", "4.0"); req.setRequestHeader("OData-Version", "4.0"); req.setRequestHeader("Accept", "application/json"); req.setRequestHeader("Content-Type", "application/json; charset=utf-8"); req.onreadystatechange = function () { if (this.readyState === 4) { req.onreadystatechange = null; if (this.status === 200) { //refresh var results = JSON.parse(this.response); formContext.data.refresh(false); console.log(results) } else if (this.status === 400) { //refresh console.log("Lee - failure"); console.log("Lee - " this.statusText); } else { Xrm.Utility.alertDialog(this.statusText); } } }; req.send(); }
Hi,
I just tested my Script with a date rollup, it works without any problem. Can you please share your code and how you configure your handle, thank you :)
I'm getting a 400 error with it
The rollups are all date fields, and need to be timestamped to whenever the page is opened
Adis
136
Super User 2025 Season 1
Sohail Ahmed
81
Jonas "Jones" Melgaard
77
Super User 2025 Season 1