DEV Community

Riccardo Gregori
Riccardo Gregori

Posted on

How to (quickly) set Dataverse table icons

This is a "bonus" post on my series about PACX commands to streamline WebResource management.

Another boring activity for a dev is to set the icons for each custom table created within a Dataverse environment. It's a tedious, but important task if you want to avoid floppy navigation UX.

A proper use of table icons makes your app look more professional and visually appealing.

Proper table image usage

Assuming the icons you want to assign have been already uploaded to your environment as SVG WebResources, this article from the official Power Platform documentation describes how to apply icons to standard or custom tables in the dataverse, .

It's a process that requires more or less 5 steps on the maker portal for each table. As a professional Power Platform Maker, I never create one table at time: the typical approach is to desing the part of datamodel I'm going to add in terms of tables/columns/relationships, then leverage PACX scripts to create all those metadata in one single step, even 5-10 new tables at once... repeat 5 steps for 10 tables... too many manual steps required just to add icons πŸ₯±.

Of course XrmToolbox Iconator saves the day.

Iconator to the rescue

It reduces drastically the number of steps required. You just need to:

  1. Open XrmToolbox, connect to your environment, and launch Iconator
  2. Click on "Load Entities and Images"
  3. Click on "Load on solution(s)"
  4. Peek a solution that contains both the tables and the images you want to set (if you tipically keep the WebResources separated from tables, you need first to create a single solution containing everything you need)
  5. For each table that needs an icon to be set
    1. Click on the table name
    2. Double-click on the icon
  6. Click on "Apply and Publish"

This reduces the cost from 5x10=50 steps, to 5+(5x2)=15 steps, not bad!

πŸ‘¨πŸ»β€πŸ’» Yes, not bad, but I'm lazy! Can we do better?

Sure we can, if we can assume one of the following (reasonable) conventions. For each table that needs to be updated with an icon:

  1. if there is a webresource called <table_logical_name>.svg take that one, otherwise
  2. if there is a webresource called <publisherprefix>_<table_logical_name>.svg take that one, otherwise
  3. if there is a webresource called <publisherprefix>_/images/<table_logical_name>.svg take that one, otherwise
  4. if there is a webresource that ends with /<table_logical_name>.svg take that one, otherwise
  5. ...do nothing, icon must be set manually

we can use just 1, simple, PACX command:

pacx webresources applyIcons
Enter fullscreen mode Exit fullscreen mode

The command:

  1. takes all the tables contained in the default solution for the current environment that are not already associated with an SVG icon,
  2. then takes all the WebResources of type Image (SVG) from the same solution,
  3. for each table
    1. looks for the icon to assign using the matching rules described above
    2. if found, assigns the icon to the table, otherwise moves to the next table
  4. Runs a Publish on all the tables that have been changed.

Of course you can tweak with the command arguments to customize the behavior of the command itself. For instance:

pacx webresources --table-solution datamodel --wr-solution webresources
Enter fullscreen mode Exit fullscreen mode

The two arguments:

  • --table-solution (alias -ts) can be used to select a specific solution to get the tables from (different from the default one)
  • --wr-solution (alias -wrs) can be used to select a specific solution to get the images from (different from the default one)

While:

pacx webresources --no-action
Enter fullscreen mode Exit fullscreen mode

(alias -nop) Can be used to simulate the resolution algorithm and look at the matches it generates, without performing any actual action.

no-action

Conclusions

That's it, just follow simple conventions while creating or pushing the image WebResources to Dataverse, and the iconization is reduced to one, simple, step. Nice, isn't it? 😎

Top comments (0)