Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

CustomerId gets cleared when you remove parentcontactid on Opportunity

Posted on by Microsoft Employee

Hi there, functionality question.

We have code that preselects and account in the parentaccountid field when we open the new opportunity form.  Then when the form is saved, the accountid value gets saved to both the parentaccountid and also CRM saves the value to the customerid.   

We also have a contact field (parrentcontactid) on the form. 

When a user fills this value, saves the form, and then deletes the value from the field and saves the form, it appears the CRM also deletes the customerid it had previously set.  Even though the customerid was was filled with the accountId.

It seems illogical but is this correct behavior?

Is there a way to not have it do this?

Thanks!

*This post is locked for comments

  • Suggested answer
    Shidin Haridas Profile Picture
    Shidin Haridas 3,497 on at
    RE: CustomerId gets cleared when you remove parentcontactid on Opportunity

    While we are on the topic of override the '+' to open the main form, I hope you are using the configuration setting on the Opportunity entity (see screenshot below). You just need to turn this off.
    03736.Capture.PNG

    I wouldn't recommend you to create a new custom lookup, as there exists one relationship between Contact & Opportunity.

    If you can make the 'Customer' lookup an optional field, then do that and do not use it any longer.

    1. Hide it from your forms, views and make it non-searchable.

    2. Rename 'Account' field to 'Customer'.

    Now, effectively, you just have an Account lookup & Contact lookup.

    The system OOB may map fields / clear the value of the Customer lookup. But that shouldn't affect you as you will not be using the Customer lookup field.

    PS: This only works if the Customer lookup on Opportunity can be made 'Optional'.

    If you do not want to go that route, from an optimisation point of view, I wouldn't recommend having a workflow to update the Opportunity values. Do it through the script, on change rather.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: CustomerId gets cleared when you remove parentcontactid on Opportunity

    Hi Shidin, thanks for your response.  Right now, for us the only way a user can create an opportunity is through a sub grid we have on our account form.  We override the add new + click on this grid and force it to open the main form, and also pre-fill the account into the parentaccountid field for the user.  

    When the user saves, CRM is saving the parentaccountid to the customerid automatically.  We aren't manually filling it.  So that functionality is out of the box it appears.   The issue is that when the user also fills out the parentcontactid, then clears it, CRM also clears the customerid automatically.   So it's the change of the contact that clears the customerid.

    Currently I put a workflow in place that when the parentcontactid changes, I check if the customerid is null, and if it is null I fill it with the parentaccountid.  This is fairly close to what you suggested.  I was hoping there was a way to break the link, so that CRM would not auto-clear the customerid when the parentcontactid is changed, so I wouldn't need to have a workflow.

    Your explanation of how the customerid maps to both parentaccountid and parentcontactid is interesting.  It seems to indicate the intended use of the fields is to expose customerid, prefilter (if desired) it down to just accounts or contacts and let it fill the other fields.  And then hide the field you don't want to use.   So the only use of the 2 named fields is to determine if an acocunt or contact was selected.

    So then would the intended use be for us be to prefilter the customerid to accounts only, and then create a custom contact field that is not associated with the customerid?   Then no extra steps would be needed?

    thanks!

  • Suggested answer
    Shidin Haridas Profile Picture
    Shidin Haridas 3,497 on at
    RE: CustomerId gets cleared when you remove parentcontactid on Opportunity

    Nope, this is not the default behaviour.

    The default behaviour maps the Customer field to the Account field(if the Customer is an Account) or maps the Customer field to the Contact field.

    In your case, instead of saving the Account value to both the Account & Customer, just save it to the Customer field, and make the account field hidden and optional.

    However, if the user clicks on 'new record' from the Customer lookup, a Contact Quick Create form will be open up.

    To prevent this and a better user experience, I recommend doing the following:

    1. Hide the Customer field on the form.

    2. Show only Account & Contact fields.

    3. On change of Account, map that Account value to the Customer lookup.

    If you follow this, you won't need an OnLoad / OnSave event for prefiltering the Customer lookup.

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,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans