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
BJamesBJames 

trouble with Image in scontrol

Hello,

  I'm attempting to load an image into my scontrol by storing the image in my documents tab. I then get the reference to it as so... https://na1.salesforce.com/servlet/servlet.FileDownload?file=01530000000AY1V . To top it off it displays as it should within the browser via the direct URL.
 
  However when I make that URL an <img src=""> it always comes back as "Undefined"...  
 
  Any thoughts?
 
Thanks,
-=Bryan
Pat McQueenPat McQueen

Bryan,

Two thoughts - First is the image marked as externally available in the docs tab?  Second - How are you creating the image reference?  Are you using a calculated field?

Pat

zachzach
I'm doing the same thing in many of my custom sControls & yeah... Make sure it's marked "externally available" and make sure you get the image source by clicking on the Documents tab, then clicking on the link to the image you've stored, and then right-click and view properties on that image.  That location is what you'll use in your code as the src=""

One of my image references looks like this, if it helps:
https://na1.salesforce.com/servlet/servlet.ImageServer?oid=00D3000000002jy&id=01530000000Epuu

-Zach
mikefmikef
Also it is good to set all salesforce.com URL's without the host name.

For example you are storing the image in the doc's tab and referencing it with 'https://na1.salesforce.com/servlet/servlet.ImageServer?oid=00D3000000002jy&id=01530000000Ep'.
Take the https://na1.salesforce.com off and only use
'/servlet/servlet.ImageServer?oid=00D3000000002jy&id=01530000000Ep'.

That way if we ever change the name of our hosts your sControl will not break.

This logic can be used for all references into SFDC.

MikeF