Announcements
Hi,
I need code to reopen or reactivate the closed leads using web api,similar to Reactivate lead button.
function reactivateLead() {
debugger;
var leadId = Xrm.Page.data.entity.getId(); // Current lead ka ID lete hainif (leadId) {
var entityFormOptions = {};
entityFormOptions["entityName"] = "lead";
entityFormOptions["entityId"] = leadId;var parameters = {};
parameters["statuscode"] = 1; // Status code for reactivation
parameters["statecode"] = 0; // State code for activeXrm.WebApi.updateRecord("lead", leadId, parameters).then(
function success(result) {
console.log("Lead reactivated successfully.");
// Optionally, you can refresh the form or redirect
Xrm.Page.data.refresh();
},
function (error) {
console.error("Error reactivating lead: " + error.message);
alert("Error: " + error.message);
}
);
} else {
alert("Lead ID not found.");
}
}
Hi,
//set statecode to 0 aka open var data ={"statecode": 0} var leadId = "8F4FA496-3FF2-E311-9864-A45D36FC5F1C"; // update the record Xrm.WebApi.updateRecord("lead", leadId, data).then( function success(result) { console.log("Lead updated"); // perform operations on record update }, function (error) { console.log(error.message); // handle error conditions } );
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 290,734 Super User 2024 Season 2
Martin Dráb 229,021 Most Valuable Professional
nmaenpaa 101,150