Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

ms crm javascript

(0) ShareShare
ReportReport
Posted on by

I have created a integer entity and optionset entity,I have to autopopulate the optionset field value when the interger field value is given using javascript

*This post is locked for comments

  • Suggested answer
    gdas Profile Picture
    50,091 Moderator on at
    RE: ms crm javascript

    May I know what is the business scenario ,?user can put any value in integer field which may not match the value of optionset.

    Assuming that user would be fill predefined value to integer field in that case you can create business rules as well.But keep in mind business rule will not set any value to the optionset if integer value does not match.

    You can go with JS ,like below, register function form onload and integer field  on Change event.

    function onChangeIntVal()

    {

    var integerValue=Xrm.Page.getAttribute("Name of Integer field").getValue();

    if( integerValue == 1 || integerValue == 2 || integerValue == 3)

    {

    Xrm.Page.getAttribute("Name of optionset field").setValue(integerValue);

    }

    else{

    Xrm.Page.getAttribute("Name of optionset field").setValue(2); // set some default value

    }

    }

  • Community Member Profile Picture
    on at
    RE: ms crm javascript

    No integer field is not option set ,but when the value given by the user in the int field the option set field must autopopulate to the appropriate value from the provided value in the option set

  • Dynamics365 Rocker Profile Picture
    7,755 on at
    RE: ms crm javascript

    Is integer field also a option set?

  • Community Member Profile Picture
    on at
    RE: ms crm javascript

    Tq for your response but my question is if i select any value in the integer field,the option set field value also want to get autopopulated.

  • Community Member Profile Picture
    on at
    RE: ms crm javascript

    I have created a integer entity and optionset entity,I have to autopopulate the optionset field value when the interger field value is selected using javascript

  • Suggested answer
    Dynamics365 Rocker Profile Picture
    7,755 on at
    RE: ms crm javascript

    You have to write script on load and on save event.

    You can use below code:

    var integerValue=Xrm.Page.getAttribute("Name of Integer field").getValue();

    Xrm.Page.getAttribute("Name of optionset field").setValue(integerValue);

  • Suggested answer
    Rawish Kumar Profile Picture
    13,758 on at
    RE: ms crm javascript

    duplicate : https://community.dynamics.com/crm/f/117/t/320048  

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

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Kudos to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

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 52

#3
dkrishna Profile Picture

dkrishna 6

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans