Workflow Automation - Activate or Deactivate
Is there any way to achieve Activate/Deactivate the workflow automation via programmatically using python or any Smartsheet API available to do. Have gone through the API documentation and couldn't got anything helpful related to my requirements. Should not open sheet and manually click the activate/deactivate the workflow.
Answers
-
There is a way to update the automation through the API, possibly here? https://smartsheet.redoc.ly/tag/automationRules#operation/automationrule-update
-
Specifically, the AutomationRule Object has a boolean "enabled" attributed.
https://smartsheet.redoc.ly/tag/automationRulesObjects#section/AutomationRule-Object
There is also a "disabledReasonText" attribute, I haven't done this, but you could probably add a comment here suc has "Disabled via API"
-
@Tim C @Lee Joramo Thanks for your response. Using update automation rule API to enable/disable the workflows. However getting few error like below
1012 - Required object attribute(s) are missing from your request: action.includedColumnIds. - ApiError
Majorly action attribute has many things and unable to copy as it is or creating new automation object with few changes similar like enabled: true/false in automation objects
Actually found the issue also, few of the workflows has only notification message without fields. In this scenarios, getting the above error. Still looking into fixing this issue, if anyone facing this earlier and rectified. Please post it your approach here.
disabledReasonText attribute also we can update and have not tried yet.
-
@karthick please provide the full Payload/JSON/object you are sending. For example, taken from the example Node.js "Update an Automation Example"
var options = { sheetId: 4583173393803140, automationRuleId: 789994550205316, body: { name: "Approval Request", action: { type: "APPROVAL_REQUEST_ACTION", recipients: [ { email: "jane.roe@smartsheet.com" } ], frequency: "WEEKLY", includeAllColumns: true, includeAttachments: true, includeDiscussions: true, notifyAllSharedUsers: false } } }
-
@Lee Joramo Have connected smarsheet API using python SDK. Using python script, the below are the following approaches
Seems working for most of the workflows without issues. Few workflows contains only message triggering notification and there got the includedcolumnids attribute error. Debugged and identified and those field are not mapped with any columns id's.
Approach 1:
existing_rule = ss_client.Sheets.get_automation_rule(
sheet_id, # sheet_id
automation_light.id_) # automation_rule_id
automation_spec = smartsheet.models.AutomationRule({
'enabled': False, # Disable Automation Rule
'name': automation_light.name, # Change Name of Automation Rule
'action': existing_rule.action
})
response = ss_client.Sheets.update_automation_rule(
sheet_id, # sheet_id
automation_light.id_, # automation_rule_id
automation_spec)
Getting below error for the above code.
Required object attribute(s) are missing from your request: action.includedColumnIds.
-------------------------------------------------------------------------------------------
Approach 2:
Tried in different way to achieve the same and got error like "Unable to parse request. The following error occurred: Field "action" was of unexpected type."
existing_rule = ss_client.Sheets.get_automation_rule(
sheet_id, # sheet_id
automation_light.id_) # automation_rule_id
# Create a new action object
new_action = smartsheet.models.AutomationAction({
'type_': existing_rule.action.type_,
'message': existing_rule.action.message, # You may modify other fields if needed
'included_column_ids': existing_rule.action.included_column_ids, # Include 'includedColumnIds' if available
'frequency': existing_rule.action.frequency,
'include_all_columns': existing_rule.action.include_all_columns,
'include_attachments': existing_rule.action.include_attachments,
'include_discussions': existing_rule.action.include_discussions,
'subject': existing_rule.action.subject,
'recipient_column_ids': existing_rule.action.recipient_column_ids,
'recipients': existing_rule.action.recipients,
'notify_all_Shared_users': existing_rule.action.notify_all_shared_users,
'_AutomationAction__initialized': existing_rule.action._AutomationAction__initialized
})
automation_spec = smartsheet.models.AutomationRule({
'enabled': False, # Disable Automation Rule
'name': automation_light.name, # Change Name of Automation Rule
'action': new_action
})
response = ss_client.Sheets.update_automation_rule(
sheet_id, # sheet_id
automation_light.id_, # automation_rule_id
automation_spec)
-------------------------------------------------------------------------------------------
Atleast Approach 1 is working for most the automation workflow and got error if includede columns ids are blank. Might be will get some other error after rectifying on the same
approach 2 gets error for all the workflows. I know its related to action type error, have converted to AutomationAction model as well
-
Note: while I am a Python programmer, almost all of the Smartsheet API work I do is using Node.js. Additionally, I have not used the Automation Rules portion of the API. But here are some suggestions.
For the errors you are getting, what are the values being passed via
existing_rule.action.included_column_ids
. Given the comment on this line, I expect you are passing the wrong values.'included_column_ids': existing_rule.action.included_column_ids, # Include 'includedColumnIds' if available
I suspect that if you are only going to display certain selected columns, you are suppose to either send something like this :
'included_column_ids': existing_rule.action.included_column_ids, # your array of columns to display 'include_all_columns': false,
or if you want ALL columns, I think you do not send
'included_column_ids'
'include_all_columns': true,
-
@Lee Joramo Have not passed any values, using the existing rule values mostly except enabled is false. The below values are tried as you suggested.
'included_column_ids': existing_rule.action.included_column_ids, # your array of columns to display 'include_all_columns': false,
Have assigned one default column id if included_column_ids are blank - this way its resolve my issue. This issue is only via API and not from Smartsheet UI
-
@Tim C @Lee Joramo As per Smartsheet API documentation, List all automation rules wont provide multistep workflows. Is there any workaround to get multistep workflow via API
-
Ok, so there is no way to do this.
I now remember when I was trying to build a Smartsheet backup solution for my organization that there were limitations. Looking at the various third party vendors of Smartsheet backup tools, none of them claim to backup automation/workflows. And those that do mention it, only say they do NOT backup it up. Since these tools use the API to do their work, I think it is pretty clear that smartsheet does not provide any way to do this.
For reference ProBackup says they do not support Automation : https://support.probackup.io/help-center/article/what-does-pro-backup-back-up-for-smartsheet/
(I use Smartsheet's Java based backup tool to backup all of my organizations data, which only gets me the data in excel files and the attachments.)
Categories
- All Categories
- 14 Welcome to the Community
- Smartsheet Customer Resources
- 64.2K Get Help
- 416 Global Discussions
- 221 Industry Talk
- 461 Announcements
- 4.8K Ideas & Feature Requests
- 143 Brandfolder
- 141 Just for fun
- 58 Community Job Board
- 462 Show & Tell
- 32 Member Spotlight
- 1 SmartStories
- 299 Events
- 38 Webinars
- 7.3K Forum Archives