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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Suggested Answer

Form: Lookup: New: Automatically fill-out

(0) ShareShare
ReportReport
Posted on by 26

Hello,

is there a (not custom code) way to pass the values of an existing entity record to a new lookup form?

Case:

In the entity salesorder exists this lookup to the entity sc-data

8372.lookup.png

Problem:

If the user clicks on "Neu" (New) it should automatically fill-out some fields that are already filled out in the salesorder.

My ideas:

- If possible: Get parent id from the Xrm context and retrieve the data. Then use Xrm setValue.

- Create a custom button and HTML

- Using Business process flow (I could not achive it with that. Since I could not create an entity with it or pass parameters to the workflow that should create the new entity.)

- Field mappings. It seems like that it did not work, because it is a N:1 relationship.

Any suggestions?

I have the same question (0)
  • Suggested answer
    - Matt Bayes - Profile Picture
    890 on at

    Her Bernhard,

    When you click "New" and create a new record, does that record get saved and automatically set in the source record lookup field?

    The reason I ask is because I tested with one of my environments, and on click "New" the URL of the new window has some parameters that could be used by you to get what you need. In this case, my parameters looked like (with some other information):

    extraqs=%3f_CreateFromId%3d%257bCB63BECB-C3BF-E811-80DA-005056A46CE5%257d%26_CreateFromType%3d10510%26

    You could write Javascript that would run OnLoad of the sc-data entity, parse out the extraqs parameter, get the "CreateFromId" key-value, and use that to retrieve the record (which should be source salesorder in your case) and any associated fields you would like. From there, you would then set the field values on the sc-data form with those retrieved from the query.

    This is essentially what you posed as your first item. Depending on your version of CRM, you could utilize the asynchronous Web API call to retrieve the data, and when it's done, set the fields. If the version does not have that, then you can use the standard XMLHttpRequest way of retrieving the data, but would still recommend running it asynchronously since this is the best practice.

    If you have more questions just let me know!

    Thanks!

    Matt Bayes

  • bernhards Profile Picture
    423 on at

    Hi Matt,

    thanks for your answer. No, it doesn't get saved. (Auto-saving is disabled.)

    I was hoping for a solution without a custom code, but as it looks this is not possible. I don't understand why the field mapping did not work for both directions.

    Also thanks for your suggestion with the JS logic. I was hoping for a way to get the data out of the context like in a plugin, but this is also a nice idea.

    Please give me some time to try it out and I will response to you after that or mark your answer als solution.

    Best regards,

    Bernhard

  • Suggested answer
    bernhards Profile Picture
    423 on at

    Ok, I've found it. You can retrieve the data from the context by using this.

    window.top.opener.Xrm.Page.data.entity.attributes.get("customerid").getValue()

    I think this will be my solution to go. Thanks again for your help.

    EDIT: The full code looks like this

    if (Xrm.Page.ui.getFormType() == 1) // 1 = create
    {
        // Get the value of the parent window
        let parentCustomerRef = window.top.opener.Xrm.Page.data.entity.attributes.get("customerid").getValue();
    	
    	// Set the value in the new opened form
    	Xrm.Page.getAttribute("wd_customer").setValue(parentCustomerRef);
    }

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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Hamza H Profile Picture

Hamza H 142 Super User 2026 Season 1

#2
Nagaraju_Matta Profile Picture

Nagaraju_Matta 128

#3
11manish Profile Picture

11manish 121

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans