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 Selected value from option list

(0) ShareShare
ReportReport
Posted on by 522

Hello,
I am trying a standard example,if customertypecode is 11 (vendor) show vendorsection else hide it.

showhidesection={showhidevendorsection:function()

{ var customerType=Xrm.Page.getAttribute("customertypecode".getValue();

var vendorsection =Xrm.Page.getControl ("moc_vendorcode").getParent();

if (customertype==11)

{vendorsection.setvisible(true);}

else{vendorsection.setvisible(false);

}}}

In above code in this line - if (customertype==11), instead of writing 11 how can I get the selected value from option list by end user?

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    gdas Profile Picture
    50,091 Moderator on at

    Hi Megha ,

    There are few syntax error in your code , here I have corrected . You can try with this -

    function showhidevendorsection() { 
        var customerType=Xrm.Page.getAttribute("customertypecode").getValue(); // make sure you correct field name 
    var customerTypeText = Xrm.Page.getAttribute("customertypecode").getText(); // To get selected text value
    if (customertype == 11) { Xrm.Page.ui.tabs.get("tabname").sections.get("sectionname").setVisible(true); // For section Show Hide , replace tab name and section name Xrm.Page.getControl("moc_vendorcode").setVisible(true); // Show Field } else{ Xrm.Page.ui.tabs.get("tabname").sections.get("sectionname").setVisible(true); // For Section Show hide , replace tab name and section name Xrm.Page.getControl("moc_vendorcode").setVisible(true); //Hide Field } }
  • megha18 Profile Picture
    522 on at

    Hi Goutam,

    Thanks for this!

    Can you also help me to get the value from option list instead of writing (customertype == 11), 11?I want to fetch this value based on user selection.

  • Suggested answer
    gdas Profile Picture
    50,091 Moderator on at
    Try with this  -

    var customerTypeText = Xrm.Page.getAttribute("customertypecode").getText();
    if(
    customerTypeText == "Optionsettext" )
    {

    }

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