If you want
to call plugin from ribbon button click event with custom action, you can use
this script.
// Ribbon button click event call custom action
executeCloneEvent: function (formContext, eventId) {
var eventId = formContext.data.entity.getId();
var entityrecordId = eventId.substr(1, eventId.length - 2);
var request = {
entity: { entityType: "account", id: entityrecordId},
getMetadata: function () {
return {
boundParameter: "entity",
parameterTypes: {
"entity": {
"typeName": "account",
"structuralProperty": 5
},
},
operationType: 0,
operationName: "acct_CloneEvent"
};
}
};
// Calling Plugin
Xrm.WebApi.online.execute(request).then(function (result) {
if (result.ok) {
result.json().then(function (response) {
// on response you will get reponse output parameter
if (response.CloneId) {
// Load newly copy record
var entityFormOptions = {};
entityFormOptions["entityName"] = "account";
entityFormOptions["entityId"] = response.CloneId;
// Open the form.
Xrm.Navigation.openForm(entityFormOptions).then(
function (success) {
},
function (error) {
});
}
else {
}
});
}
}, function (error) {
});
}
Comments
Post a Comment