Link to Attachment FIle

How do I get the link to an attachment file using system actions? If I hover over the link to the file in the attachment detail of the record, I get something like https:///0/rest/FileService/GetFile/.  The GUID doesn't match the attachment record ID. How do I get the link or ID of the file from the attachment record to send the link to someone else?

Like 0

Like

7 comments

To achieve your target you need to create a link that is a sum of:

https://<instance>/0/rest/FileService/GetFile/

+

UID value from SysSchema table for the detail from which you try to get file from: OrderFile, InvoiceFile, AccountFile etc

+

ID value from the table which represents this detail.

For example I have a record in OrderFile table (order attachment) with an ID: 2AC7AA00-2E61-4AEC-8BD0-621269731DAA. To complete the link I execute:

SELECT UID FROM SysSchema WHERE Name = 'OrderFile'

and get a value of D75D815B-0B2E-4E33-973A-ED9A43601B44. So my link is:

https://<instance>/0/rest/FileService/GetFile/D75D815B-0B2E-4E33-973A-ED9A43601B44/2AC7AA00-2E61-4AEC-8BD0-621269731DAA

Please note that user that doesn't have active session in https://<instance> won't be able to download the file.

Oscar Dylan,

How do I set the system actions to that I have a process like this:

Janine White,

It is impossible to do using the process on the screenshot. You need to add an auto-generated page where you can specify file name and schema name, after that this process should read this file and schema parameters (there should be several conditional flows for different schema names). Also you need to create a lookup with all schema names so to be able to choose from lookup in this auto-generated page from the first step. Then there should be "Read data" element that reads "Schema" object so to get UID of the schema specified on the auto-generated page that we've added previously. After that the formula element should create a link for the string parameter (using the logic I've described previously) that will be used in the final auto-generated page element where this string parameter value will be placed. Feel free to use our official documentation on business process design to achieve your business task.

Oscar Dylan,

I can read the file name from the attachment record, which is available in a parameter, and I know the attachment section, "bpm'online Environments attachments".  Why would I need to select anything manually?  I know how to set up business processes in general and use Read data elements as I've done that hundreds of times. I just don't understand how to identify the Schema and UID from the attachment record from the instructions above.  When I use the following read data, the UID is returned as zeros, clearly missing. The link in the process ends up being, "https://dev-katerra.bpmonline.com/0/rest/FileService/GetFile/00000000-0…" where "abe00c37-67f4-413c-93a0-1fa4af899bdc" is the Id of the attachment.

Nevermind, I figured out that the UID is in the link for existing files, so, I don't need to look it up.  I'll just copy it from there.

Oscar Dylan,

 There is a way to preview the file in the browser if there is a image? What format is returning the method to the client?

 

this  works to show the attachment in the browser.

var endpoint = "https://"+window.location.hostname+"/0/rest/FileService/GetFile/7661a363-68f6-4c26-879c-0590c22b963a/" + responseCollection.collection.items[0].$Id;
 
 
 
fetch(endpoint)
  //                         vvvv
  .then(response =&gt; response.blob())
  .then(imageBlob =&gt; {
      // Then create a local URL for that image and print it 
      const imageObjectURL = URL.createObjectURL(imageBlob);
      console.log(imageObjectURL);
  });

 

Show all comments