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)

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

(0) ShareShare
ReportReport
Posted on by

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

I have the same question (0)
  • Inogic Profile Picture
    703 on at

    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!

  • Community Member Profile Picture
    on at

    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
    703 on at

    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
    on at

    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

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