How to check validity of icon? Rich text icon?

Certified Senior Developer

Short of creating a constant that contains all valid icons and richTextIcons (which is suboptimal given that icons are updated between Appian versions), is there a way to make icons "invalid icon"-safe? 

i.e. Checking if an icon is in the list of supported icons on a given appian version before passing it into icon or richTextIcon?

Context

We have a (larger, complex) application that dynamically determines which icon to use in a richTextDisplayField.

One can be thorough and investigate the root cause of why invalid values are being populated but I would like to be thorough and double-check.

Thanks!

  Discussion posts and replies are publicly visible

  • +1
    Certified Lead Developer

    I didn't actually know this before, but after a quick test in my environment I've found that when an invalid icon name is provided, a!richTextIcon() will return a dictionary of data wherein one of the properties is "isError" and a value of "true".

    This leads me to think that if you have a strong enough use case for this, you could set up an expression rule i.e. "MYAPP_Util_isValidIconName()" where you pass in the name and it returns TRUE if the result was valid and FALSE otherwise... it seems to execute pretty quickly.  Note this would be technically "unsupported" functionality meaning the back-end workings could change in the future with no notice, hence why I recommend only doing this if you have a strong reason for it, and wrapping the functionality in an expression rule and only using that (instead of hardcoding it in).

    if(
      property(a!richTextIcon(icon: ri!iconName), "isError", false()),
      false(),
      true()
    )

  • 0
    Certified Senior Developer
    in reply to Mike Schmitt

    Completely agreed regarding undocumented functionality. Thank you for the quick response!