I've a Formula fields referencing some images stored as document records, in this way:

IF(AND(ISPICKVAL(Status__c, "Pendente"), Data_di_Scadenza__c< Today()), IMAGE("servlet/servlet.FileDownload?file=015w0000001emL6","RED"), 
IF(AND(ISPICKVAL(Status__c, "Pendente"), Data_di_Scadenza__c>= Today()), IMAGE("servlet/servlet.FileDownload?file=015w0000001emLB","YELLOW"), 

The field will be an attribute on a component that will be delivered with the relative package, but when I install it on an other org, the record Id will be different and my images are not shown as expected.. could this issue be solved?

3 Answers 3



If you are referencing image into formula filed and want to include this into package, you must use static resource.

To use static resource follow these steps :

1) create static resource which include your images. 2) get absolute url of your static resource image,which you want to use into formula field

your url must be in below formate :

/resource/{static-resource name}/{image path}

like this /resource/testTemplate/img/ajax-loader1.gif

remove auto generated id after package name as it is buffer address id created by salesforce.

use this address into your formula field.

When you will transfer your static resource to another org via package ,it will still the same address and your logic will not break.

Mark this as a answer if it solve your problem :)


Using harcoded IDs can be better in fixed Salesforce environment but in managed package it will fail. As Ids can be changed per instance.

Here you can use custom setting to save Ids of documents and reference them in formula so they can be updated later or by post install script.

       ISPICKVAL(Status__c, "Pendente"), Data_di_Scadenza__c< Today()), 
       ISPICKVAL(Status__c, "Pendente"), Data_di_Scadenza__c>= Today()), 

There can be better solution of it, but it will also work in managed package.

  • Does it work also with unmanaged package? I'm using this
    – user9959
    Sep 30, 2014 at 9:00
  • 1
    Yes, It should work with unmanaged packages also. @ToninoTripodi
    – Ashwani
    Sep 30, 2014 at 9:02
  • I'll try and let you know for any problem/doubt.
    – user9959
    Sep 30, 2014 at 9:03

You can use static resource to store image and refer it as following in formula field.

1) Upload image in static resource
2) Then file open --> view file on static resource detail view 3) Then copy url. (Ex. https://ap1.salesforce.com/resource/1329402101000/Image1 ) 4) Then edit the url like this 'resource/1329402101000/Image1' 5) Write formula like

    IF(AND(ISPICKVAL(Status__c, "Pendente"), Data_di_Scadenza__c< Today()), IMAGE("resource/1329402101000/Image1","RED"), 
IF(AND(ISPICKVAL(Status__c, "Pendente"), Data_di_Scadenza__c>= Today()), IMAGE("resource/1329402101000/Image2","YELLOW"), 
  • @sales_lion 's answer is the right way, as yours, but I think that in addition to yours you should remove the autogenerated Id , so the right form is: /resource/Image1 .. this is the way to solve the referencing and make it working also in other org after packaging/deploying
    – user9959
    Sep 30, 2014 at 10:36
  • 1
    @ToninoTripodi: the so called 'Id' is a timestamp holding the SystemModstamp date. This allows a better caching of static resources. Sep 30, 2014 at 11:19
  • I apologize..so it's better to include it also?
    – user9959
    Sep 30, 2014 at 11:22

You must log in to answer this question.