Render Party list field on Entity List's Activity view (Email or Portal Comment view) in PowerApps Portal (D365 Portal).

Hello folks, In the today's article we will learn, 

⇒ How we can render the Party List type field on PowerApps Portal (D365 Portal). 

Sometime we could have a requirement to apply the the Activity view on portal and activity could be of any type like Email/Portal Comment/Task/Appointment etc. Some of these entity contain Party List type field like in Email or in Portal Comment, To and From field is Party List. When we apply the view of entities which contain the party list field, the data in these fields won't render properly. it would comes like this as in below snapshot.

Guys, till now there is no OOB way to render party list field on portal, But yes with the help of JS we can do this.

Before moving forward, here I am assuming, you have some basic knowledge of JS and how to apply JS on Powerapp Portal (D365 Portal), If you don't know then I would recommend to check this article first.

Step 1: Copy the below code and paste it in your code editor.

$(document).ready(function() {

    $(".entitylist.entity-grid").on("loaded", listLoad);

});


function listLoad() {

    // $(this).children(".view-grid").find("tr[data-entity='ENTITY_NAME']");

  var gridRows = $(this).children(".view-grid").find("tr[data-entity='email']");

    if (gridRows.length > 0) {

        gridRows.each((i, row) => {

// $(row).find("td[data-attribute='FIELD_NAME']");

            var fromCell = $(row).find("td[data-attribute='from']");

            var toCell = $(row).find("td[data-attribute='to']");       

            var fromEntityCollection = fromCell.data('value').Entities;

            var toEntityCollection = toCell.data('value').Entities;

            var fromNames = "";

            var toNames = "";

            fromEntityCollection.forEach(entity => {

                var partyAttribute = entity.Attributes.find(x => x.Key == "partyid");

                if (partyAttribute == null) return;

                fromNames += partyAttribute.Value.Name + ',';

            });

            toEntityCollection.forEach(entity => {

                var partyAttribute = entity.Attributes.find(x => x.Key == "partyid");

                if (partyAttribute == null) return;

                toNames += partyAttribute.Value.Name + ',';

            });

            $(toCell).text(toNames);

            $(fromCell).text(fromNames);

        });

    }

}


Step 2: Now change the code according to your requirement. Here my i am rendering the from and To field.

Step 3: Now apply this JS on your web page or in your Entity list.

Now check, it is working.


Keep learning , Keep Growing, Keep sharing !!!

2 comments:

randyorton said...

crm software for small business I think this is an informative post and it is very useful and knowledgeable. therefore, I would like to thank you for the efforts you have made in writing this article.

intelligenes said...

you are sharing useful and knowledgeable info.if anyone want to best powerapps microsoft develpoment then contact us..