Skip to main content

Notifications

Customer Service forum
Suggested answer

How to Display Contacts on the Active Cases View?

Posted on by 4

Hello everyone,

I have a requirement and need some assistance. On the Case form in Dynamics, we have a subgrid called /Contacts,/ which shows all the contacts linked to a particular case. I would like to be able to view the contacts associated with each case directly in the /Active Cases/ view (or another view that could work similarly).

Is there a way to include or display the contacts directly within the view, or do I need to implement a workaround through custom development or other methods? I'd love to hear any ideas or suggestions from those who have tackled similar requirements.

I know that I wouldn't be able to filter on those contacts on that view but that's not the goal. I just want to be able to show the contacts on that view. As of now the Active Cases view shows the following columns: Case Title, Case Subject, Owner, Urgency.

 

Thank you!

Categories:
  • Dengliang Li Profile Picture
    Dengliang Li Microsoft Employee on at
    How to Display Contacts on the Active Cases View?
    Hi,
     

    There is currently no out-of-the-box method to support this feature.

    However, there is a workaround to add a button that, when clicked, creates a drop-down list on one of the columns of the view to display the contacts associated with each record.

     

    In my testing, I add dropdown lists to display related contacts in grid cells in the Related Contact column.

     

    The code is below.

     

    function main(primaryControl){
        //Get the list of grid records.
        const girdrowList = primaryControl.getGrid().getRows().get();
       
        //Gets the HTML element where the grid unit is located.
        const labelList=[]
        const divList =window.top.document.querySelectorAll("div[aria-colindex='4']");
     
        //If the wrong column is fetched, print a message on the console and exit.
        if(!divList[0].innerText.includes("Related Contacts")){
            console.error(`You incorrectly got the DivHTML element in the ${divList[0].innerText} column, and should got the HTML element in the Related Contact column`)
            return;
        }
     
        for(let i=1;i<divList.length;i++){
        let label = divList[i].querySelector("label[aria-label='']")
        labelList.push(labelabel)
    }
       
        //Creates a drop-down box for each grid cell in the column to display the related contacts information,
        //if the contact information have already been obtained and the drop-down boxes have been generated then it is an update operation.
        if(labelListList[0].querySelectorAll("select").length ===1){
            updateData(girdrowList,labelList);
        }else{
            createDropdown(girdrowList,labelList);
        }
     
       
    }
     
    async function createDropdown(girdrowList,labelList) {
        for(let i=0;i<girdrowList.length;i++){
            //Gets the ID of a record.
            let ID = girdrowList[i].data.entity.getId();
     
            //Create a drop-down box
            let select = window.top.document.createElement("select");
            select.style.display="block";
            let label = labelList[i];
           
           
            //Expands the many-to-many relationship between case and contact to get the contact records related to a record in the view grid.
           await Xrm.WebApi.retrieveRecord("incident",ID,"?$expand=cr642_Contact_Incident_Incident" ).then(
                function success(result) {
                    let contacts = result.cr642_Contact_Incident_Incident
                    for (var i = 0; i < contacts.length; i++) {
                        let option = window.top.document.createElement('option');
                        option.innerText = contacts[i].fullname;
                        select.appendChild(option);
                    }
                    label.appendChild(select);
                                       
                },
                function (error) {
                    console.log(error.message);
                }
            );
     
        }
     }
     
     async function updateData(girdrowList,labelList){
        for(let i=0;i<girdrowList.length;i++){
           
            let ID = girdrowList[i].data.entity.getId();
            let label = labelList[i];
            let select = label.querySelector("select");
            select.options.length = 0;
           
           
           await Xrm.WebApi.retrieveRecord("incident",ID,"?$expand=cr642_Contact_Incident_Incident" ).then(
                function success(result) {
                    let contacts = result.cr642_Contact_Incident_Incident;
                    for (var i = 0; i < contacts.length; i++) {
                        let option = window.top.document.createElement('option');
                        option.innerText = contacts[i].fullname;
                        select.appendChild(option);
                    }
                    label.appendChild(select);
                                     
                },
                function (error) {
                    console.log(error.message);
                }
            );
     
        }
    }
     
     

     

     

     

     

    If my answer was helpful, please click Like, and if it solved your problem, please mark it as verified to help other community members find more.
    If you have further questions, please feel free to contact me .
     
    Best Regards,
    Dengliang Li
     

     
  • CU09051936-0 Profile Picture
    CU09051936-0 4 on at
    How to Display Contacts on the Active Cases View?
    Hi Dengliang Li,
     
    I have a many-to-many relationship between those entities. The issue that I'm having is that there are multiple subgrids on the Case form. Each of those subgrids can be used to add contacts. I do however only need to show the data of one particular subgrid in the Active Cases view.
     
    Best
     
     
  • Suggested answer
    Dengliang Li Profile Picture
    Dengliang Li Microsoft Employee on at
    How to Display Contacts on the Active Cases View?
    Hi,
     
    Have you added a new 1:N relationship for the case entity and the contact entity, resulting in a single case that can be associated with multiple contacts?
     
    The default relationship that the system establishes for the case entity and the contact entity is many-to-one.
    Therefore, only one contact can be connected to each case.
     
     
    You can modify the Active Case View in Power Apps to add a contact column. 
    This will show the contact that the case points to in the view.

     

    Best Regards,
    Dengliang Li
     

Helpful resources

Quick Links

Take the Community feedback survey!

Answer this brief 15-question survey about your Community experience…

Demystifying Copilot: Service Edition with Sundar Raghavan

Sundar answers more questions about Copilot for Service...

Dynamics 365 Business Central vs Finance and SCM

Take a look at the key differences between Business Central and…

Leaderboard

#1
Andre Arnaud de Calavon Profile Picture

Andre Arnaud de Cal... 283,377 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 223,308 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,140

Featured topics

Product updates

Dynamics 365 release plans