Skip to content

Instantly share code, notes, and snippets.

@furkankaracan
Created June 16, 2022 08:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save furkankaracan/a20dd38c1071fd0cc030c8dd65bd0b20 to your computer and use it in GitHub Desktop.
Save furkankaracan/a20dd38c1071fd0cc030c8dd65bd0b20 to your computer and use it in GitHub Desktop.
CopyOpportunity: function (primaryControl) {
try {
//showProgressIndicatior
Xrm.Utility.showProgressIndicator("Please wait while processing your request");
//Save current record first once copy button is getting clicked
primaryControl.data.save().then(function () {
var recordURL = primaryControl.getUrl();
var actionName = "ad_CloneRecord";
executeAction(recordURL, actionName, primaryControl);
},
function () {
alert("An Error has occured. Please contact with your System Administrator.");
});
} catch (error) {
Xrm.Utility.closeProgressIndicator();
console.log(error);
throw "An Error has occured. Please contact with your System Administrator.";
}
},
executeAction: function (recordURL, actionName, primaryControl) {
var req = {};
req.RecordURL = recordURL;
req.Prefix = prefix;
req.FieldsToIgnore = fieldsToIgnore;
req.getMetadata = function () {
return {
boundParameter: null,
parameterTypes: {
"RecordURL": {
typeName: "Edm.String",
structuralProperty: 1
},
"Prefix": {
typeName: "Edm.String",
structuralProperty: 1
},
"FieldsToIgnore": {
typeName: "Edm.String",
structuralProperty: 1
},
},
operationType: 0,
operationName: actionName
};
};
var successCallbackExc = function (result) {};
var errorCallbackExc = function (error) {
Xrm.Utility.closeProgressIndicator();
alert(error.message);
};
Xrm.WebApi.online.execute(req).then(successCallbackExc, errorCallbackExc);
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment