Here I have attached my JS.
function callActionToReopenOpp(primaryControl){
var formContext = primaryControl;
var Id = formContext.data.entity.getId().replace('{', '').replace('}', '');
var target = {};
target.entityType = "opportunity";
target.id = Id;
var req = {};
req.entity = target;
req.InputParam = target;
req.getMetadata = function () {
return {
boundParameter: "entity",
parameterTypes: {
"entity": {
typeName: "mscrm.opportunity",
structuralProperty: 5
}
},
"InputParam": {
"typeName": "mscrm.opportunity",
"structuralProperty": 5
},
operationType: 0,
operationName: "ReopenOpportunityFromDeclinedStage"
};
};
Xrm.WebApi.online.execute(req).then(
function success(result) {
if (result.ok) {
//Success - No Return Data - Do Something
alert("Web API Action Called Successfully...");
}
},
function(error) {
Xrm.Utility.alertDialog(error.message);
}
);
}