Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

change the state and status reason through Web Api.

Posted on by 382

Hi ,

i would like to set the state and status to open for phone call  entity through web API .

could any one please help me on this .

Thanks,

Waseem 

*This post is locked for comments

  • Suggested answer
    Jeevarajan Kumar Profile Picture
    Jeevarajan Kumar 747 Most Valuable Professional on at
    RE: change the state and status reason through Web Api.

    Hi Waseem,

    Below is a sample to open a phone call.

    State

    Status Reason

    0 : Open

    1 : Open

    1 : Completed

    2 : Made

    4 : Received

    2 : Canceled

    3 : Canceled

    var entity = {};
    entity.statuscode = 1;
    entity.statecode = 0;
    
    var req = new XMLHttpRequest();
    req.open("PATCH", Xrm.Page.context.getClientUrl() + "/api/data/v8.1/phonecalls(0000000-0000-0000-0000-000000000000)", 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) {
                
            }
            else {
                Xrm.Utility.alertDialog(this.statusText);
            }
        }
    };
    req.send(JSON.stringify(entity));
    


    Hope it helps

  • Mohammed Waseem Profile Picture
    Mohammed Waseem 382 on at
    RE: change the state and status reason through Web Api.

    It worked .

    Thank You .

    Thanks,

    Waseem.

  • Verified answer
    a33ik Profile Picture
    a33ik 84,323 Most Valuable Professional on at
    RE: change the state and status reason through Web Api.

    Hello,

    Use regular update approach passing statecode/statuscode as regular fields.

    Good luck.

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,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans