Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

ms crm javascript

Posted on by Microsoft Employee

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
    gdas 50,085 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
    Community Member Microsoft Employee 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
    Dynamics365 Rocker 7,755 on at
    RE: ms crm javascript

    Is integer field also a option set?

  • Community Member Profile Picture
    Community Member Microsoft Employee 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
    Community Member Microsoft Employee 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
    Dynamics365 Rocker 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
    Rawish Kumar 13,756 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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans