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)

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

I have the same question (0)
  • Suggested answer
    Rawish Kumar Profile Picture
    13,758 on at

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

  • Suggested answer
    Dynamics365 Rocker Profile Picture
    7,755 on at

    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);

  • Community Member Profile Picture
    on at

    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

  • Community Member Profile Picture
    on at

    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.

  • Dynamics365 Rocker Profile Picture
    7,755 on at

    Is integer field also a option set?

  • Community Member Profile Picture
    on at

    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

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

    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

    }

    }

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