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)

Custom look up field in Opportunities

(0) ShareShare
ReportReport
Posted on by

Hi

I seem to be going around in circles on this one. I want to create a relationship and lookup similar to the "Potential Customer" field in opportunities (looks up Contact or Account). For the user the field on the form will allow them to select a record from one of two tables. In the example the "Potential Customer" field has a type of "Customer" which is not available.

Is the "Potential Customer" field a special field or do I just not know the technique?

Many thanks

Michael M

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    ScottDurow Profile Picture
    21 on at

    Hi Michael,

    Unfortunately this kind of lookup is a special system field that can't be created through customisations. You would need to create two lookups, one for accounts and one for contacts, and then have field that shows/hides based on what type of relationship the user needs.

    hth

  • Michael Mo Profile Picture
    on at

    Hi Scott

    thank for the reply, it is as I feared. We have two custom entities, one is the primary record the second is the component of the primary record. I wanted the user to pick either one, alas, back to the drawing board!

    Just for interest how could I go about the show/hide idea, in theory of course?

  • Suggested answer
    ScottDurow Profile Picture
    21 on at

    Hi,

    In theory - you could add an two value optionset, with the values Account and Contact, then add a JavaScript webresource with something like:

    var crm= crm || {};

    crm.myForm= {

       onload  : function () {

           // Register onchange handlers

           Xrm.Page.getAttribute("new_lookuptype").addOnChange(crm.myForm.onLookupTypeChange);

           crm.myform.onLookupTypeChange();

       },

       onLookupTypeChange: function () {

           var attributeValue = Xrm.Page.getAttribute("new_lookuptype").getValue();

           Xrm.Page.getControl("new_accountid").setVisible(attributeValue );

           Xrm.Page.getControl("new_contactid").setVisible(!attributeValue);

       }

    };

    Then add an onload webresource event that calls crm.myForm.onload

    hth

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