Skip to main content

Notifications

Announcements

No record found.

Customer experience | Sales, Customer Insights,...
Suggested answer

JavaScript Code to set Bookable resource as Deactivate if System user is Disable

Posted on by 80

Can anyone help me

  • Suggested answer
    Bipin D365 Profile Picture
    Bipin D365 28,964 Super User 2024 Season 1 on at
    RE: JavaScript Code to set Bookable resource as Deactivate if System user is Disable

    Hi,

    It can be achieved with below code

    function SetBookableResourceStatus()
    {
    var entity = {};
    entity.statecode = 1;
    entity.statuscode = 2;

    var req = new XMLHttpRequest();
    req.open("PATCH", Xrm.Page.context.getClientUrl() + "/api/data/v9.1/msft_employees(061b30a1-bb2c-ec11-b6e6-6045bd72faf4)", true);
    req.setRequestHeader("OData-MaxVersion", "4.0");
    req.setRequestHeader("OData-Version", "4.0");
    req.setRequestHeader("Accept", "application/json");
    req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
    req.onreadystatechange = function() {
    if (this.readyState === 4) {
    req.onreadystatechange = null;
    if (this.status === 204) {
    //Success - No Return Data - Do Something
    } else {
    Xrm.Utility.alertDialog(this.statusText);
    }
    }
    };
    req.send(JSON.stringify(entity));
    }

    Replace Entity name and record guid in above code.

    Please mark my answer verified if this is helpful!

    Regards,

    Bipin Kumar

    Follow my Blog: xrmdynamicscrm.wordpress.com/

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans