Tuesday, July 28, 2020

Custom Icons for DateTime fields in D365 Views

Hi again,
as you might know, there is a supported possiblity how to display custom icons in D365 Customer engagement views.
It's described here:

I will not go through the same steps, I just wanted to share a more info on top of this.

I needed to get the icons to the case views where we have SLA deadline. When deadline is in far future, we want green icon, when it is approaching, we want orange and when the deadline is breached, we want the icon red.

So what yyou need to do is follow the above guide, create icons, create webresource and in that web rource use script like this:
 

function displayIcon(rowData) {     

    var str = JSON.parse(rowData);

    //new datetime variable

    var checktime = new Date();

    //add 2 hours - needed to evaluate orange icon

    checktime.setHours(checktime.getHours()+2);

    //current time

    var today = new Date();

   

    //read datetime value - it is returned as a string!

    var slastage = str.new_slastageend;

   // convert to datetime object

    var slastageend = new Date(slastage);

   

    var imgName = ""; 

    var tooltip = "";

 

    compare object

    if (checktime.getTime() > slastageend.getTime() && today.getTime() < slastageend.getTime())

        {

             imgName = "orange.png"; 

             tooltip = "SLA Near Breach"; 

        }

    else if (checktime.getTime() < slastageend.getTime())

         {

             imgName = "green.png"; 

             tooltip = "SLA OK";         

         }   

       

    else if (checktime.getTime() > slastageend.getTime())

        {

             imgName = "red.png"; 

             tooltip = "SLA Breached"; 

        }

 

    var resultarray = [imgName, tooltip]; 

    return resultarray; 



So really, the trick here is to convert the string to datetime and then it is very easy. Also based on this finding, you can see that it is possible to add the icon to any column of any type.

Michal

Tuesday, January 7, 2020

Access Team Subgrid Displays all Users

Recently, I have experienced a strange behaviour with Access teams.
I have created a custom entity and enabled Access teams. Then I added a subgrid on the form for the access team members. I used the standard documented way - Form edit - Add subgrid - All records - Users - Record's team members.

I also got a warning, that an access team template must be created. So I saved the form and Published it.
The I created an access team template for my custom entity.


But the grid displayed all users instead of just those who were assigned to the record.
The settings were correct. After some searching, I have to remove the subgrid from the form and create it from scratch. Then it started to work correctly.

So the conclusion is - before you add the subgrid to the form, make sure that you have the Access Team Template created!

I wish you all the best in 2020!

Michal