web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

How to get option set value?

(1) ShareShare
ReportReport
Posted on by 12,119 Moderator

Hi all,

I am using this code

function CreateListMemberValidation()
{
debugger;
var entityId = Xrm.Page.data.entity.getId();
var Name = Xrm.Page.getAttribute('aw_name');

//fetch xml code
var MarketingListQuery = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='true'>" +
" <entity name='list'>" +
" <attribute name='createdfromcode' />" +
" <attribute name='listid' />" +
" <order attribute='createdfromcode' descending='true' />" +
" <link-entity name='aw_mailchimp_list' from='listid' to='listid' visible='false' intersect='true'>" +
" <link-entity name='aw_mailchimp' from='aw_mailchimpid' to='aw_mailchimpid' alias='al'>" +
" <filter type='and'>" +
" <condition attribute='aw_mailchimpid' operator='eq' uiname='" + Name + "' uitype='aw_mailchimp' value='" + entityId + "' />" +
" </filter>" +
" </link-entity>" +
" </link-entity>" +
" </entity>" +
"</fetch>";
var Records = XrmServiceToolkit.Soap.Fetch(MarketingListQuery);
if (Records.length > 0) {

if (Records[0].attributes.createdfromcode != undefined){
var MemberType = Records[0].attributes.createdfromcode;
}
}
}

How can  I get below formattedvalue?

formattedValue.jpg

 Thank You

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Nithya Gopinath Profile Picture
    17,078 on at

    Hi Abdul Wahab,

    You could get the formatted value or text of an option set value using the following Javascript code.

    function getOptions() {
        var obj = Xrm.Page.getAttribute("fieldSchemaName");
        if (obj != null) {
            //Get OptionSet Text
            var optionSetText = obj.getText();
            //Get OptionSet Val
    var optionSetValue = obj.getValue();
    }
  • Abdul Wahab Profile Picture
    12,119 Moderator on at

    Hi Nithya Gopinath

    It is giving me this error

    optionsetvalue1.jpg

    Thank You

  • Verified answer
    Abdul Wahab Profile Picture
    12,119 Moderator on at

    Hi all

    I write below line and I get the value

    var MemberType = Records[0].attributes.createdfromcode.formattedValue;

    Thank You

  • Saddamk206 Profile Picture
    777 on at

    Use :-   Xrm.Page.getAttribute("new_myoptionset").getValue()

  • Abdul Wahab Profile Picture
    12,119 Moderator on at

    Assalam o Alikum Saddam,

    Could please make separate thread for your problem and explain your problem there ?

    Thank you

    Regards,

    AW

  • Kishore P Profile Picture
    45 on at

    Hi

    Try These  

    var Value = Xrm.Page.getAttribute("FieldName").getValue();

  • Kishore P Profile Picture
    45 on at
  • Suggested answer
    Vipin J Profile Picture
    1,603 on at

    you should try : var MemberType = Records[0].attributes.createdfromcode.formattedValue;

    How to get and set value for different datatypes in Dynamic 365 CRM

    https://vjcity.blogspot.com/2019/07/how-to-get-and-set-value-for-different.html

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans