items.Delete
Overview¶
Delete the specified record.
Syntax¶
Parameters¶
| Parameter | Type | Required | Description |
|---|---|---|---|
| recordId | object | Yes | Specify the ID of the target record |
Return Value¶
If the record is deleted, true is returned; if not, false is returned.
Usage Examples¶
In the following example, the record with record ID 123 will be deleted.
JavaScript¶
Code Samples¶
Modify 【 ... 】 in the code as necessary.¶
1. Delete records by specifying the record ID
Get the records whose status is '910' and delete the records by the IDs obtained.
JavaScript¶
// Specify the name of the site to process
const siteName = '【Site name】';
// Get the site information
const site = items.GetClosestSite(siteName);
if (!site) {
logs.LogInfo(`${siteName} Failed to get the site information`);
return false;
}
// Target the records whose status is On hold (910) for deletion
const status_codes = `["910"]`;
const data = {
View: {
ColumnFilterHash: {
Status: `${status_codes}`,
},
},
};
const results = Array.from(items.Get(site.SiteId, JSON.stringify(data)));
if (results.length === 0) {
logs.LogInfo('No records to delete');
return;
}
// Delete the On hold (910) records found
for (const item of results) {
const result = items.Delete(item.ResultId);
if (result) {
logs.LogInfo(`Delete succeeded: Id=${item.ResultId}`);
} else {
logs.LogUserError(`Delete failed: Id=${item.ResultId}`);
}
}
Execution Result¶
Cautions¶
This is a method used in "Server Script". It cannot be used in "Script".