Skip to main content

Notifications

Microsoft Dynamics CRM (Archived)

Pass values between forms

Posted on by 12,070 Super User 2024 Season 1

Hi all

I want to pass values from main form to lookp's new form. For Example: There is a Property entity form that has two lookup fields:

1. Account

2. Bank details

Select account and than going to select bank details that was filtered on change of account. If I found account that has no bank details than I go to the create new bank details from the look up form. At this point I want to pass account on bank detail's form. Is there anyway to do so?

Thanks

Regards,

Abdul

*This post is locked for comments

  • Suggested answer
    Rawish Kumar Profile Picture
    Rawish Kumar 13,756 on at
  • Abdul Wahab Profile Picture
    Abdul Wahab 12,070 Super User 2024 Season 1 on at
    RE: Pass values between forms

    Here are details:

    UntitledA.jpg

    UntitledA.jpg

    May You please elaborate it more?

    Thanks

    Regards,

    Abdul

  • gdas Profile Picture
    gdas 50,085 on at
    RE: Pass values between forms

    Hi, Can you please share error details.

  • Abdul Wahab Profile Picture
    Abdul Wahab 12,070 Super User 2024 Season 1 on at
    RE: Pass values between forms

    Hi Goutam,

    Thank you so much for this great response. I have only one question here. If I open bank details form directly it will give me error. How can I handle this error? Is there any way to check window.open is null or something else?

    Thanks

    Regards,

    Abdul

  • gdas Profile Picture
    gdas 50,085 on at
    RE: Pass values between forms

    Hi ,

    You can not pass any parameter directly from lookup field New button , however once its open the bank account details forms you can get the parent main form Account lokup using window.parent.opener.Xrm.Page.getAttribute

    So below is the sample code you need to write onload of the BankDetails create forms .

            function setLookupValueGetFromParent()
            {
      if (Xrm.Page.ui.getFormType() == 1) { // For create Form var parentLookupObj = window.parent.opener.Xrm.Page.getAttribute("new_accountlkup"); //Ge Parent lookup object if (parentLookupObj != null) { if (window.parent.opener.Xrm.Page.getAttribute("new_parentaccountlkup").getValue() != null) { var accountid = window.parent.opener.Xrm.Page.getAttribute("new_parentaccountlkup").getValue()[0].id; // Get the parent form account lookup id var accountname = window.parent.opener.Xrm.Page.getAttribute("new_parentaccountlkup").getValue()[0].name; // Get the parent form account lookup name var lookupValue = new Array(); lookupValue[0] = new Object(); lookupValue[0].id = accountid; // GUID of the lookup id lookupValue[0].name = accountname; // Name of the lookup lookupValue[0].entityType = "bankaccount"; //Entity name of the lookup entity Xrm.Page.getAttribute("new_accountlookupfieldname").setValue(lookupValue); // Replace the lookup id of account in bank account details page } }
    } }

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans