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:
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.
The easiest way to do it, is to remove the Out of the Box check
Change the Environment variable
msdyn_IncidentShouldValidatePrimaryContact to 0
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).
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):
New created Contact field:
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?
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.
Muhammad Shahzad Sh...
51
Most Valuable Professional
Ramesh Kumar
42
David Shaw_UK
27