Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

How to get a value from two option field using javascript - MS CRM 2013 Online

(0) ShareShare
ReportReport
Posted on by 4,585

I am using this code:

status = Xrm.Page.data.entity.attributes.get('fieldname').getValue();

alert(status);

alert("end");

And that is triggered by custom button which is working.

The alert(status) window pops up, but it is just empty. The final alert("end") window pops up correctly with text end. The fieldname field is a two option field.

*This post is locked for comments

  • Ali Deldari Profile Picture
    20 on at
    RE: How to get a value from two option field using javascript - MS CRM 2013 Online

    Hi Ravi,

    Thank you for your answer,

    yes i tried some ways

    problem was somthing else, and now its resolved

    i was reading value of another boolean field and set it to this field. than field was not exist on form

    thanx

  • Suggested answer
    RaviKashyap Profile Picture
    55,410 Moderator on at
    RE: How to get a value from two option field using javascript - MS CRM 2013 Online

    Hi Ali,

    Did you try anything at your end? Are you facing any error?

    You should be able to set value directly for two option set

    Xrm.Page.getAttribute.setValue(true);

    Hope this helps.

  • Ali Deldari Profile Picture
    20 on at
    RE: How to get a value from two option field using javascript - MS CRM 2013 Online

    Aileen Gusni

    how can i set value in javascript for boolean(two option) fields?

    my function will trigger when onLoad

  • Community Member Profile Picture
    on at
    RE: How to get a value from two option field using javascript - MS CRM 2013 Online

    Try using Chrome.

    Open the Chrome browser. Press Ctrl + Shift + N. It will open an 'incognito' Chrome window. It doesn't store cache. You won't have to clear browser cache again and again.

  • Aileen Gusni Profile Picture
    44,524 on at
    RE: How to get a value from two option field using javascript - MS CRM 2013 Online

    Hi Teseitsei,

    You should re-load the web page to get new Javascript working.

    If not, the developer tool will always refers to the same javascript.

    Nice to hear that, becau I tried using both code, it also worked.

    So your problem solved.

    Thank you.

  • Suggested answer
    TseiTsei Profile Picture
    4,585 on at
    RE: How to get a value from two option field using javascript - MS CRM 2013 Online

    Thanks Aileen. I got this working. Using both Xrm.Page.data.entity.attributes.get('fieldname').getValue(); and  Xrm.Page.getAttribute("fieldname").getValue(); methods.

    I also noticed that somehow browsers remember the old javascripts if I don't remove everyting from the browsers cache. This is a little bit weird and makes the development a little bit frustrating. I used both Firefox and IE.

    With CRM 2011 I just need to force reload to test new scripts.

  • Verified answer
    Aileen Gusni Profile Picture
    44,524 on at
    RE: How to get a value from two option field using javascript - MS CRM 2013 Online

    Hi Tseitsei,

    It is actually should gieve you alert pop up with text false or true, depends on the value, 0 or 1, and should not be getting Null for this two options since only Yes/No, and you set the default value = 0 (No)

    How if you try use this?

    status = Xrm.Page.getAttribute("fieldname").getValue());

    alert(status);

    alert("end");

  • TseiTsei Profile Picture
    4,585 on at
    RE: How to get a value from two option field using javascript - MS CRM 2013 Online

    Yes, the field is on the form.

    The field is normally displayed like any other field.

    Correct field is selected.

    Label brings back the correct label value.

  • Aileen Gusni Profile Picture
    44,524 on at
    RE: How to get a value from two option field using javascript - MS CRM 2013 Online

    Hi Tseitsei,

    It is actually should gieve you alert pop up with text false or true, depends on the value, 0 or 1, and should not be getting Null for this two options since only Yes/No, and you set the default value = 0 (No)

    How if you try use this?

    status = Xrm.Page.getAttribute("fieldname").getValue());

    alert(status);

    alert("end");

  • Hosk Profile Picture
    on at
    RE: How to get a value from two option field using javascript - MS CRM 2013 Online

    so is the field definitely on the form

    How are you displaying the field

    are you definitely selecting the correct field

    is the label value bringing back anything

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

Jainam Kothari – Community Spotlight

We are honored to recognize Jainam Kothari as our June 2025 Community…

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
Mohamed Amine Mahmoudi Profile Picture

Mohamed Amine Mahmoudi 83 Super User 2025 Season 1

#2
Community Member Profile Picture

Community Member 54

#3
dkrishna Profile Picture

dkrishna 6

Featured topics

Product updates

Dynamics 365 release plans