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
BoolsEyeBoolsEye 

Reference javascript and images in S-Control

I am working on an AJAX application with S-controls which reference third party javascript libraries and images from a folder on the documents tab.

It works fine but when I upload my application to AppExchange and someone installs the application the file ids in the download urls change

"https://na1.salesforce.com/servlet/servlet.FileDownload?file=015300000005Gll"
"https://emea.salesforce.com/servlet/servlet.FileDownload?file=015300000006846"

Even the server name changes from n1.salesforce.com to emea.salesforce.com. How can I resolve this ?

Is this good practice or should I host the libraries and images on our own website.

I looked into the "Sforce Explorer" s-control and it includes javascript files from "http://sandbox.sforce.com/ajax/sforceExplorer/". What other options do I have in salesforce to upload files.

Thanks,

Juergen
DevAngelDevAngel
You should be able to create the js libs and images as document object and reference those with a relative url in your scontrol. Then when packaging the app, include the image and js "documents" as part of the package. This should duplicate the libs and images into the other users account and the renamed urls should point to the copies of the libs and images in the user account.
BoolsEyeBoolsEye
Thanks for you reply, so this syntax within a scontrol should resolve the server name right ?

[script language="JavaScript" src="/servlet/servlet.FileDownload?file=01530000000IOtB"][/script]

I created an app package and uploaded it.

Within the demo account everything works fine but when I installed the package into a different account as a customer or different organization would do, the id behind the file= parameter changed. The javascript file was still there within one of the document folders but it had a different download file id.

If you say that it should stay the same when installing from AppExchange I will test it again, maybe I made a mistake.

Thanks,

// Juergen
Ron HessRon Hess
you are observing the "re-map" process, where ID's which you specify in your app are fixed-up durring the install process so that they point to the same document that they did in your original org.

so, yes they change upon install and, yes they should still work as you expect ( point to a document which also instlled by your app)
BoolsEyeBoolsEye
Ok, my fault, I placed a javascript file in a documents folder and this file itself referenced images in this folder.

After the installation these images were missing so the ids inside documents are not re-mapped, only those in scontrols.

// Juergen
Ron HessRon Hess
yes, sounds correct, so the next step is to refer to the document images from the scontrol, where they will be mapped
Luke@TWSLuke@TWS
Is there any way to reference a document in the javascript and have it still work when the package is published?