function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
MattMet86MattMet86 

Images in Documents from Sandbox to Production without changing ID

We have images that are used in formulas in Sandbox like this:
CASE( Session_Status_Picklist__c,
"Complete", IMAGE("/servlet/servlet.FileDownload?file=01518000000EvIC","! Completed",50,50),
"In Progress", IMAGE("/servlet/servlet.FileDownload?file=01518000000EvI2","! In Progess",50,50),
"Under Admin Review", IMAGE("/servlet/servlet.FileDownload?file=01518000000EvIW","! Under Review",50,50),
""
)
When I move the images to Production the ID value for the image will  change.

Is there a better way to reference images so that they can be referenced in both Sandbox and Production? Maybe the thing called Static Resource which I haven't used yet.  

 
Mahesh DMahesh D
Hi Matt,

You can try below sample formula:
 
IMAGE( 
CASE( Priority, 
"Low", "/img/samples/flag_green.gif",
"Medium", "/img/samples/flag_yellow.gif",
"High", "/img/samples/flag_red.gif", 
"/s.gif"), 
"Priority Flag")

Regards,
Mahesh
 
JeffreyStevensJeffreyStevens
You could also use (I think) $Organization.Id in the formula.  Then you could test for the prod org ID, and use one file ID vs the other. 
Mahesh DMahesh D
Hi Matt,

For more information, using the static resource you will not get these kind of issues.

Example given here:

Upload image in resourse . and then file open --> view file  then copy url.   for example
 url may be https://ap1.salesforce.com/resource/1329402101000/Image1 
 then edit the url like this  ' /resource/Image1' 
 
IMAGE(
CASE( {!Rating__c},
1, " /resource/Image1'", 'None','No Image'
)


More links:

https://developer.salesforce.com/forums/?id=906F00000008o86IAA

http://sfdcsrini.blogspot.com/2014/07/how-to-use-static-resource-in-image.html

https://developer.salesforce.com/forums/?id=906F00000008zCfIAI

https://developer.salesforce.com/forums/?id=906F0000000BURhIAO



Please do let me know if it helps you.

Regards,
Mahesh
MattMet86MattMet86
Any idea how to get the image when it is stored in a zip archive static resource? My archive name is BCIGraphics and the image name is RedLocked.

I tried this but it didn't work:
IMAGE("/resource/BCIGraphics/RedLocked","! Outside Window",50,50)