Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Updating option set value using API MSCRM

Posted on by 55

Hi I want to update value of option set field which is on another form using API 

below is my code but is says bad request or internal server error.

I am doing this using API as setting option set using workflow has bug in crm 8.2 version

i tried using getselectedoption / getoptiontext etc but it is not working can anyone please help

var entity = {};
entity["new_unit"] = Xrm.Page.getAttribute("aga_unit").getValue();  //this is option set

var req = new XMLHttpRequest();
req.open("PATCH", Xrm.Page.context.getClientUrl() + "/api/data/v8.2/redit_beratungs("+ConsID+")", 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.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));

*This post is locked for comments

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Updating option set value using API MSCRM

    Hi, 

    I don't see anything wrong with your request.

    1. Have you checked if "new_unit" is definitely the correct fieldname and that option set contains the option set value you are getting from "aga_unit" ?

    2. Is your ConsID correct and has the correct format, have you stripped {} from the field ? 

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