You need to sign in to do that
Don't have an account?

Using Static Resources in Image Formula Field
Is there a DOCUMENTED way to use a static resource as an image in a formula field? I'm trying to create an 'action link' that looks like a command button and need to find a place to store the background image for the link in a way that is environment agnostic
I'd hoped this would work, but $Resource doesn't seem to be recognized in formula fields (works fine in visualforce formulas).
HYPERLINK('/apex/createAgreement?id=' + Id , IMAGE( $Resource.Create_Agreement_Button , 'Create Agreement' ) , '_top')
It appears that this will work, but I'd rather not depend on undocumented functionality to accomplish this. Particulary given I'd like to add this to a managed package at sometime and in theory there could be an identically named resource that alread exists in the org.
HYPERLINK('/apex/createAgreement?id=' + Id , IMAGE( '/resource/Create_Agreement_Button' , 'Create Agreement' ) , '_top')
Documents are also a reasonable approach, but I don't know how to use them across multiple environments where I won't no the document id.
It is very simple .first u 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'
)
All Answers
Its not possible as of now and posted as an Idea, you can vote for it though.
Hey Greg, can you post a link? I can't seem to find it.
http://success.salesforce.com/ideaView?c=09a30000000D9xtAAC&id=087300000007dQnAAI
I think we can have the formuales field returning text and embed an Image tag within formaule field. But the problem is while packaging the stuff the images are not rendered unless we prepend the namespace prefix with the Resource name. In case, if you requirement is suffice by the sample images given by Salesforce , then this should be fine. Following link gives some more information on that.
http://www.salesforce.com/community/assets/docs/Sample_Image_Formula_Fields_Customization_Guide.pdf
Cheers
Sunny
else, what you can do is hardcode the namespace prefix before building the manage package in the formuale field.
Just prepend the namespace before the resource name and it works like a charm.
I understand this to be a temporary workaround but cannot wait for the Idea to be implemented though voted for the idea which Gulshan has raised.
Please mark this post as resolved in case this works out for you.
Ok... thinking about what you are saying, i did this:
IMAGE('/resource/' + $Setup.Package_Resources__c.Prefix__c + $Setup.Package_Resources__c.Name__c + '/images/flags/' + Name +'.gif', Name)
Where "Package_Resources__c" is a Custom Setting, with 2 fields: "Prefix" and "Name". In prefix i'm saving the prefix of the package, and in name the static resource name.. so it works fine. :)
Thank you guys
It is very simple .first u 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'
)
That's great tselvam.
I'd just highlight for people that you can (and should) take the resource Id out of the URL as you've done. It's then safe to migrate between environments.
Cheers,
Ray
I've always used the Static Resource ID which was a pain to manage new versions, thanks @tselvam for this simple solution.
My question..What if i log in as other user... I cant see the image referencing from static resource.
IF( ISPICKVAL( Traffic_light__c , 'Green'), IMAGE("/resource/GreenTrafficLight", "Green"), IF(ISPICKVAL( Traffic_light__c , 'Yellow'), IMAGE("/resource/YellowTrafficLight", "Yellow"), IF(ISPICKVAL( Traffic_light__c , 'Red'), IMAGE("/resource/RedTrafficLight", "Red"), '') ) )
Upload the three image files by typing Static Resources in Quick Find Box -> New :-
1. GreenTrafficLight.png
2. YellowTrafficLight.png
3. RedTrafficLight.png
Traffic_light__c is a picklist.