get url for file upload field through selectquery?

Posted by gwf on 04-Aug-2016 14:06

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

Posted by Shiva Duriseati on 08-Aug-2016 04:22

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

All Replies

Posted by Shiva Duriseati on 08-Aug-2016 04:22

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

Posted by gwf on 09-Aug-2016 09:56

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

Posted by Shiva Duriseati on 10-Aug-2016 01:06

Sure Greg we shall make a note of this.

This thread is closed