Hi,
How do you get the url for files stored and associated with particular records through the file upload field with rbf_selectQuery?
My use case is that the query callback sends an array to the client-side code in a portal page that then constructs a custom list view. I want to have a clickable link in the list to allow the user to download the file stored with the file upload field for each record.
Thank you,
Greg
Hi Greg,
There is no direct way to get the file upload URL from client side API, but still you can achieve this. Please take a look at the below code where I've constructed URL from the available tokens
1)Production Sever URL
{!#PROD_SERV_URL}
2)Object Definition ID-(Assuming integration name of object is "SampleObject")
{!#OBJ_ID.SampleObject}
3)Record ID
Can be read from select query.
4)Integration Name of file upload field.
5)Current Customer ID
{!#CURR_CUSTM.id}
Example:
I have created an object lets say "SampleObject" with File Upload field "UploadCertificate"
Using selectQuery we need get record id
rbf_selectQuery("select id from SampleObject",100,function(arr)
{
for(var i=0;i<arr.length;i++){
console.log('{!#PROD_SERV_URL}'+"servlet/File?dir=data&objDefId="+'{!#OBJ_ID.SampleObject}'+"&id="+arr[i] [0]+"&name=UploadCertificate&c="+'{!#CURR_CUSTM.id}');
}
});
The above function will construct the URL as follows:(Assuming object has two records.)
localhost:8080/.../File
localhost:8080/.../File
Please let me know in case you need any assistance.
Regards,
Shiva
Hi Greg,
There is no direct way to get the file upload URL from client side API, but still you can achieve this. Please take a look at the below code where I've constructed URL from the available tokens
1)Production Sever URL
{!#PROD_SERV_URL}
2)Object Definition ID-(Assuming integration name of object is "SampleObject")
{!#OBJ_ID.SampleObject}
3)Record ID
Can be read from select query.
4)Integration Name of file upload field.
5)Current Customer ID
{!#CURR_CUSTM.id}
Example:
I have created an object lets say "SampleObject" with File Upload field "UploadCertificate"
Using selectQuery we need get record id
rbf_selectQuery("select id from SampleObject",100,function(arr)
{
for(var i=0;i<arr.length;i++){
console.log('{!#PROD_SERV_URL}'+"servlet/File?dir=data&objDefId="+'{!#OBJ_ID.SampleObject}'+"&id="+arr[i] [0]+"&name=UploadCertificate&c="+'{!#CURR_CUSTM.id}');
}
});
The above function will construct the URL as follows:(Assuming object has two records.)
localhost:8080/.../File
localhost:8080/.../File
Please let me know in case you need any assistance.
Regards,
Shiva
Got it, thanks a lot, Shiva.
It would be a nice addition to be able to do this directly through the selectquery or a template token, like getting the URL for a portal page.
Greg
Sure Greg we shall make a note of this.