Skip to main content

Notifications

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!

  • sinehelth Profile Picture
    sinehelth 45 on at
    RE: Prefill a lookup field on marketing form

    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.

  • Basvb Profile Picture
    Basvb 62 on at
    RE: Prefill a lookup field on marketing form

    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,

  • RE: Prefill a lookup field on marketing form

    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

  • Ana Almeida Profile Picture
    Ana Almeida on at
    RE: Prefill a lookup field on marketing form

    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

  • RE: Prefill a lookup field on marketing form

    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
    Ana Almeida on at
    RE: Prefill a lookup field on marketing form

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

  • RE: Prefill a lookup field on marketing form

    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

  • Suggested answer
    Ana Almeida Profile Picture
    Ana Almeida on at
    RE: Prefill a lookup field on marketing form

    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

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Congratulations to the January Top 10 leaders!

Check out the January community rock stars...

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,031 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,868 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans