//native
type Smartsheet = {
token: string;
baseUrl: string;
};
/**
* Update an Automation Rule
* Updates an existing automation rule.
When sending an AutomationRule, you must always specify **action.type** and it must match the existing rule type.
*/
export async function main(
auth: Smartsheet,
sheetId: string,
automationRuleId: string,
body: {
id?: number;
action?: {};
createdAt?: string | number;
createdBy?: { email?: string; name?: string };
disabledReason?:
| "APPROVAL_COLUMN_MISSING"
| "APPROVAL_COLUMN_WRONG_TYPE"
| "AUTOMATION_NOT_ENABLED_FOR_ORG"
| "COLUMN_MISSING"
| "COLUMN_TYPE_INCOMPATIBLE"
| "NO_POTENTIAL_RECIPIENTS"
| "NO_VALID_SELECTED_COLUMNS";
disabledReasonText?: string;
enabled?: false | true;
modifiedAt?: string | number;
modifiedBy?: { email?: string; name?: string };
name?: string;
userCanModify?: false | true;
},
) {
const url = new URL(
`${auth.baseUrl}/sheets/${sheetId}/automationrules/${automationRuleId}`,
);
const response = await fetch(url, {
method: "PUT",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer " + auth.token,
},
body: JSON.stringify(body),
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 235 days ago