Skip to main content
Dynamics 365 general forum
Suggested answer

Code to reopen the closed leads using web api

editSubscribe (0) ShareShare
ReportReport
Posted on by

Hi,

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

pastedimage1616074822362v1.png

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

    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
        }
    );

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…

Leaderboard

#1
Andre Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 222,562 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,138

Product updates

Dynamics 365 release plans