web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Link of two lookups which are from different entities which don't have relationship between them

(0) ShareShare
ReportReport
Posted on by

Basically I have 2 entities. for example B,C


In Entiy B I have one field called OfficerName(Lookup)

In Entity C I have one field called Advisor(lookup).


My question is if you select Advisor as XYZ it should auto populate in OfficerName same like XYZ only.


They don't have relationship between each entities

Version: MS Dynamics CRM 2016


I was struck in this situation can you help me

Thanks

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    RaviKashyap Profile Picture
    55,410 Moderator on at
    RE: Link of two lookups which are from different entities which don't have relationship between them

    Hi,

    Without having a relationship between entity B & C how would you identify which Entity B record needs to be updated.

    So 2 answer your question, it is not possible to update the record without relating them (unless you have some other criteria to find the related record  for example say by name etc).

    Because you have this requirment, there must be some sort of link/ relation between entity B & C ( which you may have not yet created in CRM but exists as business requirement). I may be wrong, its just a thought.

    Hope this helps.

  • Suggested answer
    Temmy Wahyu Raharjo Profile Picture
    2,914 on at
    RE: Link of two lookups which are from different entities which don't have relationship between them

    Hi, this one can be done using presearch (Javascript). Something like this:

     function AddPreSearch(){
            var run;
            var fnCampaignFilter = function(){
                var b = Xrm.Page.getAttribute("new_b").getValue();
    			if(!b) return;
    			var bOfficerId = GetBOfficerId(b);
    			
                var filterXml = [
                    "<filter type='and'>",
                    "<condition attribute='new_advisorid' operator='eql' value="+bOfficerId+" />":""),
                    "</condition>",
                    "</filter>"].join("");
        
                Xrm.Page.getControl("new_c").addCustomFilter(filterXml);
            }
            return function(){
                if(!run){
                    Xrm.Page.getControl("new_c").addPreSearch(fnCampaignFilter);
                }
            }();
        };


    You must understand that you need retrieve entity B data to get the correct Officer. After you've got this Officer, you only need to give filter entity C lookup using this method. Btw, you called this method using OnLoad function. Everytime you want to changed entity C lookup value, it will populate based on the filter.

    Hope this help.

  • Suggested answer
    Aric Levin - MVP Profile Picture
    30,190 Moderator on at
    RE: Link of two lookups which are from different entities which don't have relationship between them

    You can select the first entity, get the value from the lookup, and call a web api function using JavaScript to query the other entity for the same name. The query will return the Guid from the second entity, and you can call the setValue function of the second lookup attribute to set the value from what is returned from the web api.

    If you have not used web api previously, download the CRM Rest Builder by Jason Lattimer. This tool will help you build web api queries which you can then paste into your JavaScript code:

    github.com/.../CRMRESTBuilder

    Here is an example of an article on using web api (you can generate the code from Rest Builder) on this community:

    community.dynamics.com/.../ms-crm-2016-web-api-operations-retrieve-single-or-multiple-records

    Hope this helps.

  • Community Member Profile Picture
    on at
    RE: Link of two lookups which are from different entities which don't have relationship between them

    Yes Aric, it worked for me finally after many hurdles.

    Thanks for your suggestion

  • Community Member Profile Picture
    on at
    RE: Link of two lookups which are from different entities which don't have relationship between them

    can we create oncreate java-script function for same property???

  • Community Member Profile Picture
    on at
    RE: Link of two lookups which are from different entities which don't have relationship between them

    What about oncreate?

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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
HR-09070029-0 Profile Picture

HR-09070029-0 2

#2
ED-30091530-0 Profile Picture

ED-30091530-0 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans