Skip to main content
Community site session details

Community site session details

Session Id :
Service | Customer Service, Contact Center, Fie...
Suggested answer

Creating Case: select Contact from Parent Account

(0) ShareShare
ReportReport
Posted on by 35

When creating a Case, we select an Account in the Customer field, and then the Contact in the Contact field. The out-of-the-box solution will cause the Contact field to show only the records that are part of the selected Account.

We just realized that if the selected Account has a Parent Account, then we cannot select Contacts of the Parent Account.

How can I reconfigure the system to allow this to happen?

For example:

  • Company A owns Company B. (Company A is the parent of Company B)
  • Employee A works at Company A.
  • Employee A calls with an issue at Company B. <-- When creating a case, I cannot select Employee A in the Contact field after I select Company B in the Customer field.

We need to do this because, in our case, the parent Account is a "Headquarters" and the child Account is an installation site. So people who work at HQ might report an IT issue at an installation site.

  • Walter Deworezky Profile Picture
    on at
    RE: Creating Case: select Contact from Parent Account

    The easiest way to do it, is to remove the Out of the Box check

    Change the Environment variable

    msdyn_IncidentShouldValidatePrimaryContact to 0

    learn.microsoft.com/.../remove-validation-contact

  • Suggested answer
    Community Member Profile Picture
    on at
    RE: Creating Case: select Contact from Parent Account

    Hi AlexEisenhart,

    Yes, you could new a many(Case) to one(Contact) relationship on the Case entity. And add it to the OOB form(Case for Interactive experience).

    Snipaste_5F00_2022_2D00_02_2D00_18_5F00_10_2D00_30_2D00_20.png

    Then you need use addCustomFilter to filter the results displayed in the Contact lookup. Create an onload event on the Case for Interactive experience and onchange event on the Customer field.

    The following is my sample code:

    var formContext,customer,parentId;
    
    function onLoad(executionContext) {
        formContext = executionContext.getFormContext();
    	customer = formContext.getAttribute("customerid").getValue();
    	
        //check customer type is account or contact
    	if(customer && customer[0].entityType == "account"){
    		
    		//get parent account id if exists
    		Xrm.WebApi.retrieveMultipleRecords("account", "?$filter=accountid eq "   customer[0].id).then(
    			function success(result){
    				if(result && result.entities.length > 0){
    					parentId = result.entities[0]["_parentaccountid_value"];
    					//filter result
    					formContext.getControl("cr2f9_contact").addPreSearch(addFilter);
    				}
    			}, 
    			function failed(error){
    				console.log(error.message);
    			}
    		);
    		
    	}
    }
    function addFilter(){
    		
    		var customerId = customer[0].id.replace("{","").replace("}","");
    		var customerAccountFilter = ""; 
    		if(parentId){
    			customerAccountFilter  = "";
    		}
    		customerAccountFilter  = ""
    		formContext.getControl("cr2f9_contact").addCustomFilter(customerAccountFilter, "contact");
    	
    }

    Test:

    Original Contact field( You could hide it on the OOB form):

    Snipaste_5F00_2022_2D00_02_2D00_18_5F00_10_2D00_38_2D00_47.png

    New created Contact field:

    Snipaste_5F00_2022_2D00_02_2D00_18_5F00_10_2D00_39_2D00_33.png

  • Alexander Eisenhart Profile Picture
    35 on at
    RE: Creating Case: select Contact from Parent Account

    Hey . Thanks for your message! That makes sense. Is there any way for me to create a new field on Case that operates in the way that I want it to?

  • Suggested answer
    Community Member Profile Picture
    on at
    RE: Creating Case: select Contact from Parent Account

    Hi AlexEisenhart,

    Yes, you could only select the current account's contact in the Contact field on Case form. This is by design so we couldn't change this. As a workaround, you could add him as a contact in Company B for temporary. 

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

News and Announcements

Now Available: 2025 Release Wave 2

Quick Links

Ramesh Kumar – Community Spotlight

We are honored to recognize Ramesh Kumar as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Service | Customer Service, Contact Center, Field Service, Guides

#1
Muhammad Shahzad Shafique Profile Picture

Muhammad Shahzad Sh... 51 Most Valuable Professional

#2
Ramesh Kumar Profile Picture

Ramesh Kumar 42

#3
David Shaw_UK Profile Picture

David Shaw_UK 27

Featured topics

Product updates

Dynamics 365 release plans