Lightning has pre-defined icons for the various standard object types (e.g. Account has the big and small buildings icon) and seems to allow you to associate an icon with a custom object by creating a custom object tab for the given object type.
I am looking for a way to programmatically access the icon detail (in Apex or in some LWC custom component) in a way I can then use that with LWC's lightning-icon component. I first thought about querying with SOQL, but some other means is also fine.
I'm probably looking in completely the wrong place, but here's what I've discovered so far...
I can't find a way to get the icon identities for standard object types. I can live with that since we only use a small number of these in our applications (such as Account, for example) so I can hard-code that "lookup". However, I do want to dynamically use the icons that have been assigned for custom objects.
For custom objects, as I mentioned, I can see that the CustomTab for a custom object (i.e. one named after the object itself and with "customObject" as true) has a Motif field that seems to include the icon name, mixed in with some other text. For example, I can create a custom tab for my custom object that when retrieved through the metadata API looks like:
<CustomTab xmlns="http://soap.sforce.com/2006/04/metadata">
<customObject>true</customObject>
<description>Test</description>
<motif>Custom57: Building Block</motif>
</CustomTab>
I can find "custom57" in the LDS icons library and this is the right icon for what I selected.
Now, what I can't work out is how to query the CustomTab detail since something like:
SELECT Motif FROM CustomTab WHERE customObject = TRUE AND fullName = 'MyCustomObject__c'
simply doesn't work (CustomTab is not a supported SObject type).
I have, in my quest for an answer, come across TabDefinition. This looks promising as an SOQL queryable object. However, it doesn't seem to provide the desired icon identity information.
Anyone know how to get this information programmatically?
themeInfo.iconUrl
from LWClightning/uiObjectInfoApi
. For learning I had used it for porting my lookup component to lwc component (although never got chance to finish).