Create URL to static resource image. Need quick answer ... swamped and can't think. :S

  • 2
  • Question
  • Updated 4 years ago
  • Answered
I know all the resources are in here but I don't have time. :/

Basically need to produce a URL for my Conga template to bring in an image.

https://na15.salesforce.com/resource/1421083611000/RECON__wi_wind.png

https://na15.salesforce.com/ dynamic to org

resource/ is static

1421083611000 is ???? not sure where this comes from. The resource ID is 081i0000000XWEM. I'm wondering if there is a way to get 1421083611000.

RECON__wi_ is static

wind is from field RECON__Icon__c

.png is static
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,714 Points 20k badge 2x thumb

Posted 4 years ago

  • 2
Photo of Ben Hubbard

Ben Hubbard, Employee

  • 12,490 Points 10k badge 2x thumb
Hi Pat,

The number you see there is the unix timestamp for the date that this resource was last changed.  It is actually optional.  It's only used as a "cache buster" to helping your browser not use a cache when the file is updated.

Option 1: Don't use that number at all.

https://na15.salesforce.com/resource/RECON__wi_wind.png
This should work just fine.  However, your browser will try to use its cache whenever it can.  This is probably good for an image that does not change.

Option 2: Make up a number and hardcode it.

https://na15.salesforce.com/resource/1337/RECON__wi_wind.png
This will work fine as well, however it will exhibit the same caching behavior as Option 1.

Option 3: Figure out the last modified timestamp of the resource and use it

https://na15.salesforce.com/resource/1421083611000/RECON__wi_wind.png
This option has the most desirable caching behavior in my opinion.

Option 4: Use the current timestamp for "right now".

https://na15.salesforce.com/resource/1421086698000/RECON__wi_wind.png

This will never be cached and will always be requested from the server.  Seems kinda wasteful to me.  But there are some times where this is needed.
(Edited)
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,714 Points 20k badge 2x thumb
If upon installing an app from the appexchange some apex can be used to update a system setting, then BAM!





Photo of Zach McElrath

Zach McElrath, Employee

  • 49,056 Points 20k badge 2x thumb
You can get the Instance by querying the Organization object, and grabbing the InstanceName field off it, then you could use the instance in merge syntax like this:

{{$Model.Org.data.0.InstanceName}}

Photo of Zach McElrath

Zach McElrath, Employee

  • 49,056 Points 20k badge 2x thumb
So the end result would be something like:

https://{{$Model.Org.data.0.InstanceName}}.salesforce.com/resource/RECON__wi_wind
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,714 Points 20k badge 2x thumb
That works too. Not sure what I like better now. Formula fields are better cause then there's is less code to manage. But then I have to set the "na15" via Custom Setting upon install using Apex.
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,714 Points 20k badge 2x thumb
The result needs to be stored in the object for Conga to get to it. I could update the field using javascript, but I think that it is easier to manage this standard salesforce.

This is assuming that everything between https://    &     /resource/RECON__wi_wind can be acquired with APEX upon install and populate a custom setting with this value.