async function main(SelectedItemIds){
//If any subgrid records are selected.
if(SelectedItemIds.length !==0){
console.log(SelectedItemIds);
//Iterate through all selected opportunity records and recalculate their amounts.
for(let item of SelectedItemIds){
await Recalculate(item).then(
function success(response) {
if (response.ok) { console.log("Success"); }
}
).catch(function (error) {
console.log(error.message);
});
}
}
//Returns false and always hides the button.
return false;
}
function Recalculate(ID){
//Perform the unbound operation Recalculate.
var execute_RecalculatePrice_Request = {
entityLogicalName: "opportunity", // Edm.String
entityId: {guid: ID }, // Edm.Guid
getMetadata: function () {
return {
boundParameter: null,
parameterTypes: {
entityLogicalName: { typeName: "Edm.String", structuralProperty: 1 },
entityId: { typeName: "Edm.Guid", structuralProperty: 1 }
},
operationType: 0, operationName: "RecalculatePrice"
};
}
};
return Xrm.WebApi.execute(execute_RecalculatePrice_Request)
}