Can you make "<<_ATTACHMENTFILE_URL>> Built in Variable to output the Google Drive attachment link?

Hi guys,

I’m adding some workflows to my CRM app, and I was wondering if I could somehow automatically output the Google drive URL of the email attachment generated by workflow.

I’ve noticed that, by default:

1. the built in variable <<_ATTACHMENTFILE_URL>> outputs the appsheet server link to the actual file, something like:

https://www.appsheet.com/template/getappfileurl?appName=XXXXXXXX&fileName=XxXxXxXxXx.pdf&appVersion=1.000…&utm_medium=email&utm_source=transactional&utm_campaign=Workflow+Email

2. the actual PDF is also generated in Google Drive, according to my specified relative folder path

I would prefer the Google drive URL because I often include <<_ATTACHMENTFILE_URL>> in the email body template, and that way my co-workers could quickly access the file located in a shared Google Drive folder.

1 Like

Why dont you create virtual column and construct the URL to your files saved in your cloud?

This is just a sample formula to create a hyperlink to PDF which was generated by Workflow and saved as archive.

hyperlink(CONCATENATE(“https://www.appsheet.com/template/getappfileurl?appName=",“YOURAPPNAMEANDID”,"&tableName=",“YOURTABLENAME”,"&fileName=",“Attachments%2F”,“YOURFILENAME”,".pdf"),"link to PDF”)

Place your appnameID (from your APP url you can find) and table name etc. By default, your file should be saved in folder which are auto-generated by appsheet with name of Attachments. If your files are saved in somewhere else, then change this part accordingly to match with your folder name. Also on your workflow you do have file name for attachment and change the file name part over to it. Make sure on your workflow to take off putting timestamp out of your file name.

Hi @tsuji_koichi, and thanks for your answer.

I’m guessing this won’t work, considering my relative folder path is also dynamically constructed, with an expression like

concatenate("/folderX/folderZ", [column name])

?

In case you’re wondering why I approached my relative path like that, it’s because my specific use case creates some project files, placing them automatically within the project’s “owner” organization folder

How do you set the folder path in your workflow? I assume you might have sort of expression to generate the path as variable. My sample formula is for file path which is static and won’t change . So your case where the file path dynamically change, you simply push expression which generate dynamic path to the part of file path in the expression which will generate full path with dynamic relative folder path as well.

@tsuji_koichi

I just add the expression in the Attachment Folder Path field, found in the email content area, within the workflow’s action

please see attached screencapture

You need to turn on disable time stamp . Right now Your PDF file in your g drive have name with time stamp all the time you run your workflow

File name out of the work flow need to be distinct.

@tsuji_koichi

Ok, that’s not a problem. But I don’t understand how my virtual column expression should look like, in order to output the google drive PDF file link, instead of the appsheet cloud file link. Can you please help me build it?

Here is the text version of my Attachment Folder Path:

concatenate("/TaskWorkfiles", [organization name])

And also the text version of my Attachment Name:

WorkFile_for_Task_<<[task id]>>_<<[task title]>>

AppName-id:
AstrivisCRM-1210465

Table Name"
crm_tasks

Let me know if you need something else please.

Could you share your appname-id (see in url of your app) and your table name where you run your workflow ?

@tsuji_koichi

I’ve edited my previous reply

hyperlink(CONCATENATE(“https://www.appsheet.com/template/getappfileurl?appName=",“AstrivisCRM-1210465”,"&tableName=",“crm_tasks”,"&fileName=",encodeurl(concatenate("TaskWorkfiles",[organization name]),"/"),“WorkFile_for_Task_”,encodeurl([task id]),"_",encodeurl([task title])",".pdf"),"link to PDF”)

I have no way to test this expression with App editor, so not sure if this is returned as valid expression. But try.

And before you go, could you change folder path definition to

concatenate(“TaskWorkfiles”, [organization name])

Just remove “/” in the beginning as slash may cause a bit of issue when we construct URL to encode.

Then run the workflow first, to generate the new PDF file within Google drive. Check if workflow properly generated the PDF at the target folder with the proper file name.

quick feedback: expression returns an error: …Number of opened and closed parentheses does not match.

we need to user encodeURL expression to convert special characters like

“/” and even " " space if they are used in the file name etc.

Sure, I understand that, thanks

hyperlink(CONCATENATE(“https://www.appsheet.com/template/getappfileurl?appName=",“AstrivisCRM-1210465”,"&tableName=",“crm_tasks”,"&fileName=",encodeurl(concatenate("TaskWorkfiles",[organization name],"/")),“WorkFile_for_Task_”,encodeurl([task id]),"_",encodeurl([task title])",".pdf"),"link to PDF”)

still return error?
with this?

yes, unfortunately still the same error

hyperlink(CONCATENATE(“https://www.appsheet.com/template/getappfileurl?appName=",“AstrivisCRM-1210465”,"&tableName=",“crm_tasks”,"&fileName=",encodeurl(concatenate("TaskWorkfiles",[organization name],"/")),“WorkFile_for_Task_”,encodeurl([task id]),"_",encodeurl([task title])",".pdf"),“link to PDF”)

@tsuji_koichi

I’m not sure it’s possible to use concatenate inside a hyperlink function…

Maybe create 2 different VC columns, one to concatenate and output as text, and the second to create the hyperlink from the previous one’s output?

It works, but to make the story simpler, we can remove hyper link expression.

CONCATENATE(“https://www.appsheet.com/template/getappfileurl?appName=",“AstrivisCRM-1210465”,"&tableName=",“crm_tasks”,"&fileName=",encodeurl(concatenate("TaskWorkfiles",[organization name],"/")),“WorkFile_for_Task_”,encodeurl([task id]),"_",encodeurl([task title])",".pdf")

The app expresion tester returns this:

The concatenation of all these text values (

…“https://www.appsheet.com/template/getappfileurl?appName=
…“AstrivisCRM-1210465”
…"&tableName="
…“crm_tasks”
…"&fileName="
…“encodeurl(concatenate(”
…".pdf"

Does it look ok?