Bridge: Automatically backup a workspace using "Save as New"

Would anyone be wiling to share their Bridge Workflow and Script that automatically backs up a Workspace by using "Save as New"?
I hope there are many of you with a solution like this since Smartsheet's backup option is very limited, whereas "Save as New" preserves EVERYTHING.
Please and thank you!
-Neil
Answers
-
You would simply use an API module to copy the workspace.
.
-
I understand that option, but I'm a lot more new to this than I may have expressed. I meant to ask details on the bridge settings you'd use to do this, plus the code. Ideally, the workspace would add the date backed up to the front of the workspace name as well. Is that something you could share?
-Neil
-
If you need to adjust the name, I would first use an API module to get the workspace. Then you can use a JS module to append the date to the workspace name. Finally an API module to copy the workspace and specify the new name.
How much do you understand about using API and JavaScript modules? I am happy to help where needed, but don't want to dive into details that you already know.
-
@Paul Newcome I don't know very much at all. I do have the AI prompt you previously suggested I use:
"You are an expert in Smartsheet API. You are an expert in Javascript. You are an expert on the Smartsheet Bridge Platform. You understand that a JavaScript module in the Smartsheet Bridge platform strictly forbids the calling of API's within the javascript code, strictly forbids the access of the Bridge workflow runtime data, strictly forbids the user of external libraries, and that parameters will always be passed directly into the javascript module."
Here's how I Imagine the workflow to go:
- List Workspaces in account
- Get workspace for each workspace in the account to find the names and ID's
- Add child workflow? to iterate through each workspace ID, maybe? and:
a. Copy workspace and specify the new name in string. eg. COPY [oldworkspacename]
c. Rename new workspace by the new ID (Using Javascript Module), something like this (ai generated using your prompt):
function modifyWorkspaceName(originalName) { const currentDate = new Date().toISOString().slice(2, 10).replace(/-/g, ''); let newName = `yymmdd-${currentDate}-${originalName}`; if (newName.length > 50) { newName = newName.slice(0, 50); } return newName;}
d. Repeat for each workspace ID
Is this right? If so, what would the Workflow "Elements" look like in Bridge?
-Neil
-
I would list workspaces then send the list to a child workflow.
When you are first building it, set the number of runs to 2. When you look at the child workflow run log, you will see that it sends over the triggering data in the trigger section. You can reference this in your modules.
-
-
Let me amend the above first. When you are building this out, set it to only pull a couple of workspaces. For the "Number of Runs" portion when setting up the child workflow module, set it as the array produced by the API call.
Then your child workflow trigger will contain the workspace data that triggered it which can then be used in the modules of the child workflow to create your copy.
-
@Paul Newcome OK, I think i duplicated your workflows above identically and that part is working :)
Now I use the Child Workflow log, find Sheet ID's Data Reference, and use that in the child workflow to take action on each of the SheetID's it found? So all the next steps will be in the child workflow?
Parent:
Child:
-Neil
-
Not quite. You would send the list of workspaces over one at a time (managed by the child module), and make copies of the workspaces themselves instead of trying to do one sheet at a time.
-
@Paul Newcome Could you please show me how that should look in Bridge? I"m still learning and still not grasping what you mean..
-Neil
-
The first workflow is correct. The child workflow would simply consist of an API module to copy the workspace. You would use a reference to the run log data for the workspace id.
If you wanted to rename it, you could include other modules before the API module to manipulate the text string. My personal preference is to us a JS module to append a date/time stamp to the end of the workspace name so that it comes out something along the lines of
"Workspace Name: yyyymmddhhmm"
// INPUT: originalName (passed into the module)
const now = new Date();
function pad(number) {
return number < 10 ? '0' + number : number;
}
const timestamp =
now.getFullYear().toString() +
pad(now.getMonth() + 1) +
pad(now.getDate()) +
pad(now.getHours()) +
pad(now.getMinutes());
const newName = originalName + ': ' + timestamp;
return newName;
Categories
- All Categories
- 14 Welcome to the Community
- Customer Resources
- 68K Get Help
- 474 Global Discussions
- 209 Use Cases
- 517 Announcements
- 5.6K Ideas & Feature Requests
- 87 Brandfolder
- 157 Just for fun
- 85 Community Job Board
- 521 Show & Tell
- 36 Member Spotlight
- 3 SmartStories
- 309 Events
- 37 Webinars
- 7.3K Forum Archives