Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

In CRM Lookup Window, pass parameters to the New Button From Current Form

Posted on by Microsoft Employee

Scenario:  On our opportunity form we have an Account lookup field.  We want to pass this value to the new contact form.

We also have a contact lookup on the same form, when the user selects the New button from the contact lookup window, can I pass parameters from the current form to the new contact form?  If so how would this be accomplished?

Here is an image of the button I want to pass parameters to, from the form the lookup field is on:

newcontact.PNG

Thanks for any help or ideas.

*This post is locked for comments

  • MadhanSA Profile Picture
    MadhanSA 115 on at
    RE: In CRM Lookup Window, pass parameters to the New Button From Current Form

    Did anyone find solution to this issue? (it should work in V9.0 Unified interface)

  • Aric Levin Profile Picture
    Aric Levin 30,188 on at
    RE: In CRM Lookup Window, pass parameters to the New Button From Current Form

    Can you send the link of the old solution?

    It might be unsupported customization which is why it is not working in v7 (2015).

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: In CRM Lookup Window, pass parameters to the New Button From Current Form

    Thanks for the response Aric - I'm going to mark this as answered, since you did answer in that it is not possible to override and posted an alternate solution.  The solution doesn't work for our particular situation because the account field is required and our contact form and our contact lookup is filtered based on the  account (so it then wouldn't show up in the available list).

    Our next thought is to just hide the "New" button.  I found an older solution that worked on a previous version of CRM for this but it doesn't appear possible to hide the button in our current (2015) version?

    Thanks!

  • Suggested answer
    Aric Levin Profile Picture
    Aric Levin 30,188 on at
    RE: In CRM Lookup Window, pass parameters to the New Button From Current Form

    Hi Codiax,

    You have no control of the code that gets executed when you click the New button. It is generated by the application layer. You do have control to modify entity data using Rest Api or actions.

    What this means is that after you create a new record (you can do this on the Change event of the Contact Lookup control), you can update the Contact record with the Account Id of the Opportunity record.

    You can use CRM Rest Builder (github.com/.../CRMRESTBuilder) to build your Rest Query. You will need to add SDK.REST.js to your solution which is found in the SDK.

    Here is sample code to update the Contact Entity with an Account Id (from CRM Rest Builder):

    var entity = {};

    entity.ParentCustomerId = {

       Id: "45678901-5678-5678-5678-0123456789AB",

       LogicalName: "account"

    };

    var req = new XMLHttpRequest();

    req.open("POST", Xrm.Page.context.getClientUrl() + "/XRMServices/2011/OrganizationData.svc/ContactSet(guid'12345678-1234-1234-1234-123456789ABC')", true);

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

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

    req.setRequestHeader("X-HTTP-Method", "MERGE");

    req.onreadystatechange = function() {

       if (this.readyState === 4) {

           this.onreadystatechange = null;

           if (this.status === 204 || this.status === 1223) {

               //Success - No Return Data - Do Something

           } else {

               Xrm.Utility.alertDialog(this.statusText);

           }

       }

    };

    req.send(JSON.stringify(entity));

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,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans