//native
type Zoho = {
token: string;
};
/**
* Update record locking configuration
*
*/
export async function main(
auth: Zoho,
record_locking_config_id: string,
_module: string,
body: {
record_locking_configurations?: {
created_time?: string;
locked_for?: string;
excluded_fields?: { api_name: string; id: string }[];
created_by?: { name: string; id: string; email?: string };
feature_type?: string;
locking_rules?: {
name?: string;
id?: string;
lock_existing_records?: false | true;
criteria?: {
comparator: string;
field: { api_name: string; id: string };
value: {};
group_operator: string;
group: {}[];
};
_delete?: false | true;
}[];
restricted_actions?: string[];
lock_for_portal_users?: false | true;
modified_time?: string;
restricted_communications?: string[];
system_defined?: false | true;
modified_by?: { name: string; id: string; email?: string };
id?: string;
lock_type?: "automatic" | "manual" | "both";
restricted_custom_buttons?: { name?: string; id?: string }[];
lock_excluded_profiles?: { name?: string; id?: string }[];
}[];
},
) {
const url = new URL(
`https://zohoapis.com/crm/v8/settings/record_locking_configurations/${record_locking_config_id}`,
);
for (const [k, v] of [["module", _module]]) {
if (v !== undefined && v !== "" && k !== undefined) {
url.searchParams.append(k, v);
}
}
const response = await fetch(url, {
method: "PUT",
headers: {
"Content-Type": "application/json",
Authorization: "Zoho-oauthtoken " + 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