Skip to main content
Dynamics 365 general forum
Suggested answer

Code to reopen the closed leads using web api

editSubscribe (0) ShareShare
Posted on by


I need code to reopen or reactivate the closed leads using web api,similar to Reactivate lead button.


  • Suggested answer
    meelamri Profile Picture
    meelamri 13,188 UG Leader on at
    RE: Code to reopen the closed leads using web api


    //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) {
            // handle error conditions

Helpful resources

Quick Links

What Motivates a Super User?

We know many of you visit the Dynamics 365 Community and Power Platform…

Demystifying Copilot with Sundar…

Industry experts answer burning questions directly from our amazing Community…

Enabling Copilot Case and Conversation…

Agents can easily recap an ongoing chat, transcribe a voice conversation…


Andre Arnaud de Calavon Profile Picture

Andre Arnaud de Cal... 282,978 Super User

Martin Dráb Profile Picture

Martin Dráb 222,562 Super User

nmaenpaa Profile Picture

nmaenpaa 101,138

Product updates

Dynamics 365 release plans