Search code examples
dynamics-crmmicrosoft-dynamicsdynamics-365dynamics-crm-365

How to remove pre-population from a lookup field oncreate?


I have an entity called Club that has a sub-grid for another entity called Membership. When I am on a Club record and I click the "+" on the Membership grid, it opens a create window with the Lookup fields pre-populated. The fields it currently pre-populates are both Lookups to the Club entity, but for one of the fields I don't want it to pre-populate to the Club entity that clicked the "+". How can I achieve this?

I have looked at the 1:N relationships on the Club and Membership entities. The membership entity has a N:1 mapping from the field in question to the Club but when I try to remove the mapping it says that the component is in use by CRM so I cannot remove it. If I remove the fields from the dependent forms and then remove the mapping, what are the repercussions of this? I've noticed that other fields have lookup mappings but they don't pre-populate so why does this field in particular? I don't have any business rules or javascript that pre-populates it. What else can I try here to narrow down the issue?

Opening the Membership Create form from a Club entity pre-populates the lookup fields to the entity record that opened the create form. I want it to not pre-populate a specific field.


Solution

  • For me this does not look like an issue, just the expected behavior.

    One to Many 1[a]:N[b] relationship gives a lookup attribute in b record. In reverse, b records subgrid in a record. Here in your case, a is Club and b is Membership.

    The fields it currently pre-populates are both Lookups to the Club entity, but for one of the fields I don't want it to pre-populate to the Club entity that clicked the "+". How can I achieve this?

    Either you should have duplicate relationships between Club & Membership or duplicate Club lookup control is added to the form. So when you say both are getting filled without BPF or script, then check the schema in form editor they should be same, with “1” appended to the name. Essentially the same field added twice.

    The lookup associated for that relationship will always autofill when created from Associated view/subgrid. This is expected behavior.

    I've noticed that other fields have lookup mappings but they don't pre-populate so why does this field in particular?

    They will pre-populate when you create the record from the respective related subgrid for that relationship.

    If I remove the fields from the dependent forms and then remove the mapping, what are the repercussions of this?

    Not sure if you can remove this mapping, if you do so that will try to break the platform functionality. In other words, you want simply a new record creation experience in regular form or Quick create form without pre-populating values unlike associated record created from its parent record.