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)

Get data from one entity another another entity based select field

(0) ShareShare
ReportReport
Posted on by

Hi,

    I have created two entities one Branch and Customer entities. I will select branch id in customer form then branch entity related fields are updated in Customer form by default

   

*This post is locked for comments

I have the same question (0)
  • Community Member Profile Picture
    on at

    I will tried to this code.

    function getBranchdetails()

    {

    var Lookup=Xrm.Page.getAttribute("parentcustomerid").getValue();

    var id=Lookup[0].id;

    alert(id);

    var req = new XMLHttpRequest();

    req.open("GET", Xrm.Page.context.getClientUrl() + "/api/data/v9.1/sbl_branchs(guid""+id"")?$select=sbl_branch_name,sbl_branchid,sbl_name&$count=true", true);

    req.setRequestHeader("OData-MaxVersion", "4.0");

    req.setRequestHeader("OData-Version", "4.0");

    req.setRequestHeader("Accept", "application/json");

    req.setRequestHeader("Content-Type", "application/json; charset=utf-8");

    req.setRequestHeader("Prefer", "odata.include-annotations=\"*\",odata.maxpagesize=5000");

    req.onreadystatechange = function() {

       if (this.readyState === 4) {

           req.onreadystatechange = null;

           if (this.status === 200) {

               var results = JSON.parse(this.response);

               var recordCount = results["@odata.count"];

               for (var i = 0; i < results.value.length; i++) {

                   var b_name = results.value[i]["sbl_branch_name"];

                    Xrm.Page.getAttribute("sbl_branch_name").setValue(b_name);

               }

           } else {

               Xrm.Utility.alertDialog(this.statusText);

           }

       }

    };

    req.send();

    }

    But i have an error.

    Script Error

    One of the scripts for this record has caused an error. For more details, download the log file.

    ReferenceError: getBranchdetails is not defined at eval (eval at RunHandlerInternal (skbsolution.crm8.dynamics.com/.../ClientApiWrapper.aspx), <anonymous>:1:1)

  • Suggested answer
    Adrian Begovich Profile Picture
    1,027 Moderator on at

    Hi BobbyBoddu,

    You can achieve this with JavaScript, Plugins, or Workflows.

  • Suggested answer
    Ashutosh Pandey Profile Picture
    40 on at

    You can set field mappings at the time of relationship creation.

  • Verified answer
    Alex Fun Wei Jie Profile Picture
    33,628 on at

    Hi,

    if the branch id in customer form is a lookup control.

    You also can consider the Quick view Form.

    www.magnetismsolutions.com/.../how-to-add-a-quick-view-form-in-microsoft-dynamics-365

  • Suggested answer
    Pawar Pravin  Profile Picture
    5,237 on at

    Hi,

    I believe you are working dynamics 365 9.0 version and as you queried the answer is straight forward. You can use Xrm webApi to retrieve and set data on customer entity.

    Please do refer following url for reference.

    arundynamix.blogspot.com/.../xrmwebapi-call-synchronous-in-v9.html

  • Verified answer
    gdas Profile Picture
    50,091 Moderator on at

    Hi ,

    Creating additional fields for branch information in customer entity not only increase your additional work but also increase cost and efforts . In this case every create/Update branch information you need to handle in customer entity fields as well. This is why Quick View Form is introduced , you can easily show real time  data of related  entity using lookup id.

    Just think  , why you are doing  additional customization and maintain same data in two different entity ? You just refer the quick view forms of branch in your customer form. I know this is hard to change your current design , but why not you are  upgrade and use the OOB (without code ) quick view form feature.

    Above Alex is already shared the link of quick view form , in addition I am also sharing another link to understand more.

    www.websan.com/.../720-create-d365-quick-view-forms-in-3-easy-steps

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