Rename folder

Hi team!
My app creates a new folder when a new sale is done (an automation that creates a dummy pdf with route of the file containing /data/appsheet/newsalecode/Dummyfile

Is it possible to modiffy via API the name of the folder after?

I know its a little complicated but sometimes the sale code contains some extra info that is added during the sale and not at the beggining.

thanks as always!

Solved Solved
0 7 126
1 ACCEPTED SOLUTION

So you are saying the [customer purchase id] might change at some point? And at that point you would want to rename the folder?

In this case Google Apps Script would be your friend. I would suggest adding a new bot with a data change event on updates only. The condition for execution probably should be [_THISROW_BEFORE].[customer purchase id] <> [_THISROW_AFTER].[customer purchase id]. Create a google apps script file with a function like this:

function changeFolderName(oldpurchaseid, newpurchaseid) {
let folders = DriveApp.getFoldersByName(oldpurchaseid);

if(folders.hasNext()) {
let folder = folders.next();
folder.setName(newpurchaseid);
}
}

In your process you would select 'run a task' => 'run a script'. Select the google apps script file, you may have to authorize the script first, then select function, then it will bring up two fields for your variables in your function.

For oldpurchaseid the setting would be [_THISROW_BEFORE].[customer purchase id]

For newpurchaseid the setting would be [_THISROW_AFTER].[customer purchase id]

For full disclosure, your app needs to run as the creator, or the app user needs to have full access to the parent folder of where this folder is stored in the case where you run the app as the user. Additional finagling might still be required since this is just off the top of my head and have not tested this.

 

View solution in original post

7 REPLIES 7

Probably not with the API, but it likely is possible using an automation in conjunction with Google Apps Script (assuming your file store is Google Drive?). Are you recording the file folder ID as part of your process?

Hi Markus, I did not see this message, so sorry.

My folder is created by appsheet... Can I make that folder ID is auto saved? Any idea? 

THANKS!!!!

You are saying that Appsheet creates a new folder? Is this done through an automation or are you referring to the the default folder that Appsheet creates when you add a new column for a file?

What I am trying to point out is if you already have an automation that creates a new file folder in GDrive then it would likely just take a few more steps in the same process to rename the folder. But I would need to understand a little more of your process.

I created a bot that creates a new pdf file.

in the folder path i added like this: appsheet/folder1/[customer puchase id]/

so it creates the customer folder if it was not created before โ€ฆ 

the point is sometimes we change something of the purchase and it would be cool to update the folder nameโ€ฆ 

(I used example just to explain myself)

So you are saying the [customer purchase id] might change at some point? And at that point you would want to rename the folder?

In this case Google Apps Script would be your friend. I would suggest adding a new bot with a data change event on updates only. The condition for execution probably should be [_THISROW_BEFORE].[customer purchase id] <> [_THISROW_AFTER].[customer purchase id]. Create a google apps script file with a function like this:

function changeFolderName(oldpurchaseid, newpurchaseid) {
let folders = DriveApp.getFoldersByName(oldpurchaseid);

if(folders.hasNext()) {
let folder = folders.next();
folder.setName(newpurchaseid);
}
}

In your process you would select 'run a task' => 'run a script'. Select the google apps script file, you may have to authorize the script first, then select function, then it will bring up two fields for your variables in your function.

For oldpurchaseid the setting would be [_THISROW_BEFORE].[customer purchase id]

For newpurchaseid the setting would be [_THISROW_AFTER].[customer purchase id]

For full disclosure, your app needs to run as the creator, or the app user needs to have full access to the parent folder of where this folder is stored in the case where you run the app as the user. Additional finagling might still be required since this is just off the top of my head and have not tested this.

 

Thanks x10000

I will try later.

Every day more fascinared of what appsheet can do!

Hi Markus, I could not yet apply this in my App but this is a supur cool and complete solution. Thanks a lot foy your time. Have a nice week

Top Labels in this Space