Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

CRM 2016: Oppurtunity form, Select a default value using JavaScript

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hi all

 I have opportunity page and need the key product selected by default based on another field. i can use java script to trigger a function but not able to select the key product field at all. this is a subject field and has a collapsible menu and i need to select a default option. any help is much appreciated.

*This post is locked for comments

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: CRM 2016: Oppurtunity form, Select a default value using JavaScript

    Hi

    Not sure how to explain the lookup field. it is like subject where you click it it opens the parent item in a small window. it is OOB field and not custom one. i have added a pic of the same below for easy identification. 

    please review and suggest thanks!

    646045.Capture.PNG

  • Inogic Profile Picture
    Inogic 438 on at
    RE: CRM 2016: Oppurtunity form, Select a default value using JavaScript

    We didn’t get what exactly the meaning of  “because the field is collapsible options lookup” could you explain this in details?

    Still based on our understanding below are suggested solution.

    If the Field Key Product is type of Lookup then, in order to set the value of “Key Product” Please used below code sniped in the script.

    var lookup = new Array();

    lookup[0] = new Object();

    lookup[0].id = recorid;

    lookup[0].name = recordname;

    lookup[0].entityType = entityname;

    Xrm.Page.getAttribute("attributename").setValue(lookup);

    If the Field Key Product is of type Option Set then.

    Xrm.Page.getAttribute("attributename").setValue(optionset value);

    Hope this Help.

    Thanks!

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: CRM 2016: Oppurtunity form, Select a default value using JavaScript

    Hi I already explained in my question that i tried this approach and in javascript i cannot assign a value to the key product field because the field is collapsible options lookup and there are no IDs that we can use to set the value. any other idea on how we can do this?

  • Inogic Profile Picture
    Inogic 438 on at
    RE: CRM 2016: Oppurtunity form, Select a default value using JavaScript

    As per our understanding, you need to populate the “Key Product” field based on the value of another “XYZ” filed.

     

    To Achieve the above requirement, you would need to write a JavaScript function and register it on change event of “XYZ” field.

     

    JavaScript function

    -          Check the value of “XYZ” field, and based on the value of “XYZ” field set the value of “Key Product” field.

     

    Hope this help.

     

    Thanks!

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,489 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,305 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans