Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

JS to retrieve OptionSet with Space

(0) ShareShare
ReportReport
Posted on by 230

Hi, im using a JS to retrieve an option value from a custom OptionSet field, like the example below. I need to add a few more values, but the OptionSet name has a space, for example "Information Needed". How do i add it? 

     if (status == OptionSets.RequestStatus.Approved || status == OptionSets.RequestStatus.Reviewed)

*This post is locked for comments

  • JoeO Profile Picture
    JoeO 230 on at
    RE: JS to retrieve OptionSet with Space

    This actually worked. Thanks!

  • Verified answer
    ashlega Profile Picture
    ashlega 34,477 on at
    RE: JS to retrieve OptionSet with Space

    Not quite.. Somewhere, you have to do this:

    OptionSets.RequestStatus.abracadabra = 191170006;

    And, then, you can do this:

    if (status == OptionSets.RequestStatus.abracadabra)

  • JoeO Profile Picture
    JoeO 230 on at
    RE: JS to retrieve OptionSet with Space

    So if using the integer value, I would specify

    "if (status == OptionSets.RequestStatus.191170006)"?

  • Verified answer
    ashlega Profile Picture
    ashlega 34,477 on at
    RE: JS to retrieve OptionSet with Space

    From a slightly different perspective.. those js name/constant names have nothing to do with the actual optionset labels.. you can call it abracadabra in js, just give it the same integer value - that's what really matters.

  • JoeO Profile Picture
    JoeO 230 on at
    RE: JS to retrieve OptionSet with Space

    Hi,

    I can, i was just curious how its done with spaces considering my lack of JS knowledge. Also, how would i add to the JS another OptionSet field and status (on the same form) to perform the same action. For example, either if RequestStatus.Approved or RespondStatus.Approved.

  • Verified answer
    a33ik Profile Picture
    a33ik 84,325 Most Valuable Professional on at
    RE: JS to retrieve OptionSet with Space

    Hello,

    Have you considered usage of underline symbol (_) instead of Space in your Status enumeration? Is it autogenerated or you create some kind of helper? If it is autogenereated I believe it is resolved somehow in code already - just regenerate helper class. If it is manual - you can use Information_Needed or IngformationNeedede instead of "Information Needed".

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,489 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,305 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans