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.
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.
It reduces drastically the number of steps required. You just need to:
- Open XrmToolbox, connect to your environment, and launch Iconator
- Click on "Load Entities and Images"
- Click on "Load on solution(s)"
- 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)
- For each table that needs an icon to be set
- Click on the table name
- Double-click on the icon
- 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:
- if there is a webresource called
<table_logical_name>.svg
take that one, otherwise - if there is a webresource called
<publisherprefix>_<table_logical_name>.svg
take that one, otherwise - if there is a webresource called
<publisherprefix>_/images/<table_logical_name>.svg
take that one, otherwise - if there is a webresource that ends with
/<table_logical_name>.svg
take that one, otherwise - ...do nothing, icon must be set manually
we can use just 1, simple, PACX command:
pacx webresources applyIcons
The command:
- takes all the tables contained in the default solution for the current environment that are not already associated with an SVG icon,
- then takes all the WebResources of type Image (SVG) from the same solution,
- for each table
- looks for the icon to assign using the matching rules described above
- if found, assigns the icon to the table, otherwise moves to the next table
- 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
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
(alias -nop
) Can be used to simulate the resolution algorithm and look at the matches it generates, without performing any actual 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)