1

Is it possible to refer to an IMAGE in a FORMULA by 'name' instead of ID? Just in formulas - not Apex, not VF, etc.

IMAGE( 
"/servlet/servlet.FileDownload?file=" & 

CASE( 
TEXT( Division_Project__c ), 
"BEX","015210000009KeV", 
"IDW","015210000009Kea", 
"IDZ","015210000009Kef", 
"PID","015210000009Kek", 
"SID","015210000009Kep", 
"Corporate","015210000009KfJ", 

"*** NO Division Logo present for " & 
TEXT( Division_Project__c ) & 
" - alert SF Administrator ASAP **" 
), 

"[[ LOGO MISSING or NOT LOADED ]]", 
80, 
140 
/* Minimal images are 400,700 */ 
)

It would be ideal to reduce this to a single reference without a Case being used to translate TEXT into an SFID.

imAGE( "/servlet/servlet.FileDownload?file=" & "IDW" & ".png" )

1 Answer 1

2

You can't do this for normal documents, unfortunately. However, you could use static resources, which would look like this:

IMAGE( 
"/resource/imageBundle/" & TEXT(Division_Project__c) & ".png",
TEXT( Division_Project__c ) & 
" - alert SF Administrator ASAP **", 
80, 
140 
)

Where imageBundle is the static resource name, uploaded as a ZIP file, and each file is contained within the ZIP file.

Or, alternatively, you could write a VF page and have it redirect to the appropriate resource. That's probably more complicated than it needs to be, though; I think using a static resource would be the most most straight-forward means of creating portable values.

3
  • Sounds excellent. I almost resorted to just hosting the logos on a public website. :-P I'll give that a try ASAP. Thanks.
    – AMM
    Feb 9, 2017 at 20:54
  • We also had to use full url path on the domain enabled org as it wasn't shown in some places (I believe it was a list view, but I could be wrong), and validation for a blank value: IF(ISBLANK( TEXT(Division_Project__c) ), '', IMAGE( LEFT($Api.Partner_Server_URL_260, FIND( '/services', $Api.Partner_Server_URL_260)) & 'resource/imageBundle/' & TEXT(Division_Project__c) & '.png', '' ) )
    – o-lexi
    Feb 9, 2017 at 21:44
  • Static Resources work SO fantastically for this. Thanks. No more SF IDs for image references. Woohoo.
    – AMM
    Mar 7, 2017 at 15:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .