Monday 15 April 2019

Web API request to refresh Rollup field Dynamic 365 through JavaScript

The following JS function is used to refresh Rollup field through webapi fom javascript

function calcRollupField(serverURL,strTargetEntitySetName, strTargetRecordId, strTargetFieldName)
{
    strTargetRecordId = strTargetRecordId.replace("{", "").replace("}", "");
    var req = new XMLHttpRequest();
    req.open("GET", serverURL + "/api/data/v9.0/" +
        "CalculateRollupField(Target=@p1,FieldName=@p2)?" +
        "@p1={'@odata.id':'" + strTargetEntitySetName + "(" + strTargetRecordId + ")'}&" +
        "@p2='" + strTargetFieldName + "'", false);
    req.setRequestHeader("OData-Version", "4.0");
    req.setRequestHeader("OData-MaxVersion", "4.0");
    req.onreadystatechange = function () {
        if (req.readyState === 4) {
            req.onreadystatechange = null;
            if (req.status === 200) {
                var results = JSON.parse(this.response);
            }
            else {
                Xrm.Utility.alertDialog(this.statusText);
            }
        }
    };
    req.send(JSON.stringify({}));
}

No comments:

Post a Comment

Numbering Table Parent group and child group ssrs report

 Recently I have faced a scenario to numbering parent group and subgroup in the following formate 10 parentGroupRow1    10.1 childGroupRow1 ...