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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

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

Prefill a lookup field on marketing form

(0) ShareShare
ReportReport
Posted on by 45

Hi all,

I've added a lookup field in my marketing form, and it works fine.

Now i need to prefill it with javascript, not with a unique default value because it changes from page to page - it's a product page and i have to bind the related custom product to the lookup field.

I've tried by giving to the text field the value that gather the product that i need, but it doesn't work.

Is there a way to achieve this with the javascript API ? I mean the MsCrmMkt namespace.

Bye!

I have the same question (0)
  • Suggested answer
    Ana Almeida Profile Picture
    Microsoft Employee on at

    Hello Michele,

    Based on your description I suggest a creation of a mapping.

    This lets you set default values for a record that is created in the context of another record.

    Please follow the official documentation: docs.microsoft.com/.../map-entity-fields

  • Michele Cristofani Profile Picture
    45 on at

    Thank you Ana,

    This is not quite my scenario.

    What I mean is:

    - the marketing form has a lookup field, binded to a custom lookup field (1:N) on the lead entity

    - the marketing form is embedded in an external page related to a specific record of the entity

    - my goal is to load the lookup with the specific entity, taken from the query string of the page, so, when the lead is generated, the lookup field is already populated

  • Ana Almeida Profile Picture
    Microsoft Employee on at

    Can you add more details to your explanation and add some screenshots?

  • Michele Cristofani Profile Picture
    45 on at

    I just need to prefill a lookup field in a marketing form.

    Let's say the lookup is binded to a lead field of type new_customentity, i need the field be prefilled with a specific entity (newcustomentity/{guid}).

    Cannot use the "default value" feature, because it's not static - it depends in which landing page the form is placed.

  • Ana Almeida Profile Picture
    Microsoft Employee on at

    Hello Michele,

    The best approach here is the creation of a map field associated to the relationship. The map will populate with a dynamic value, for the record that is created in the context of another record. For example, if you qualify a Lead record, certain fields are mapped to the Account, Contact, and Opportunity from the Lead.

    To create mapping between fields:

    1. Open solution explorer.

    2. Under Components, expand Entities, and then expand the entity you want.

    3. Select either 1:N Relationships or N:1 Relationships.

    4. In the main pane, in the Type list, select Mappable.

    5. Select a mappable relationship. Then, on the Actions toolbar, select Actions, and then select Edit.

    6. Under Related, select Mappings.

    7. For each new mapping, on the Actions toolbar, select New.

    8. In the Create Field Mapping dialog box, select the source field from Source Entity Fields. Select the target field from Target Entity Fields.

    9. Select OK.

    10. Select Save and Close to close the Relationship form.

    11. When your customizations are complete, publish them

  • Michele Cristofani Profile Picture
    45 on at

    Thank you Ana,

    I know hot to setup fields mapping between related entities, but this is not the case.

    I am not in the context of another record: the marketing form (not dynamics form, but a marketing app form) is embedded in a web page of an external site, it's not on Dynamics 365.

    There is not entity context, because it's not the Dynamics app.

    Best regards

  • Basvb Profile Picture
    62 on at

    Hi Michele!

    I am currently struggling with this issue as well. What I will be doing is placing the GUID inside the lookup field which is in hidden state which would mean I will still be passing the data to dynamics on Form Submit. I am passing the Event Guid which I will be retrieving through the EventManagementAPI into the lookup.

    In your situation, you will need to figure out a way to get the GUID of the product and place the data on click or redirect to that marketing form field with javascript (on form load grab it from the URL for example '?productguid=X') 

    If I'm able to get it working I'll post an update here with possible javascript solution as well as a step by step description. 

    Cheers,

  • sinehelth Profile Picture
    45 on at

    Hi all, did anybody get this to work?

    We are currently facing the same issue - we able to prefill the look up field with a text value, but it does not prefill with an actual value, so it does not work.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
ManoVerse Profile Picture

ManoVerse 197 Super User 2026 Season 1

#2
CU11031447-0 Profile Picture

CU11031447-0 100

#3
NeerajPawar Profile Picture

NeerajPawar 70

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans