Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Web API MetaData: Get Status Reasons (statuscode) for a specific status (Statecode)

Posted on by 11

Hi Expert,

Is there a way to get all status reasons filtered by a status in a web API metadata call.
e.g: I need all status reason for lead entity filtered by status "DisQualify".

Thanks in Advance.

*This post is locked for comments

  • Arun Vinoth Profile Picture
    Arun Vinoth 11,613 on at
    RE: Web API MetaData: Get Status Reasons (statuscode) for a specific status (Statecode)

    Did you try querying statusmap or picklistmapping entity?

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Web API MetaData: Get Status Reasons (statuscode) for a specific status (Statecode)

    deleted

  • Suggested answer
    Siddique mahsud Profile Picture
    Siddique mahsud 11 on at
    RE: Web API MetaData: Get Status Reasons (statuscode) for a specific status (Statecode)

    Waheed thanks for your response - But I don't need to filter records by status.

    Actually I was in need to get all status reasons against a status for a specific entity  from metadata. We can get status reasons for an entity and then we can filter the return data by statecode as I have explained it here siddiquemahsud.blogspot.com/.../get-status-reasons-statuscode-for.html

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Web API MetaData: Get Status Reasons (statuscode) for a specific status (Statecode)

    var req = new XMLHttpRequest();
    req.open("GET", Xrm.Page.context.getClientUrl() + "/api/data/v8.2/leads?$select=statuscode&$filter=statuscode eq 3", false);
    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.setRequestHeader("Prefer", "odata.include-annotations=\"*\"");
    req.onreadystatechange = function() {
    if (this.readyState === 4) {
    req.onreadystatechange = null;
    if (this.status === 200) {
    var results = JSON.parse(this.response);
    for (var i = 0; i < results.value.length; i++) {
        var statuscode = results.value[i]["statuscode"];
    }
    } else {
         Xrm.Utility.alertDialog(this.statusText);
    }
    }
    };
    req.send();

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,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans