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 set option set value by default.

(0) ShareShare
ReportReport
Posted on by 15

For example we have the employee filed as option set and in that we the values as
1)Contract
2)Temporary

so by default we need to fill the field as Contract so for this we have couple of ways by using
javascript we can write the code as follows :

function countrycode()
    {
        var country = Xrm.Page.data.entity.attributes.get("sample_countryname");
        country.setValue("727000000");// here the 727000000 will be the option set value while we creating the option set we will have this.

    }

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Alex Fun Wei Jie Profile Picture
    33,628 on at

    Hi,

    you can set the optionset default value in field setting.

    6574.28.png

  • Narendra Dynamics Consultant Profile Picture
    15 on at

    yes

  • Verified answer
    gdas Profile Picture
    50,091 Moderator on at

    Hi Narendra ,

    Try with this  -

    function countrycode() {
        Xrm.Page.getAttribute("sample_countryname").setValue("727000000");  
    }


    In addition also you can set default value by going to field properties if you want.

  • Narendra Dynamics Consultant Profile Picture
    15 on at

    Thanks Gautham

  • Verified answer
    gdas Profile Picture
    50,091 Moderator on at

    Please close the thread if you got answer .

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