console.log(`smartProcessId: "${smartProcessId}"`);
const incompleteItemIds = [];
let lastSeenId = 0;
let loadedItems = undefined;
do {
loadedItems = bx24.callMethod('crm.activity.list',
{
start: -1,
order: {'ID': 'ASC'},
filter:
{
"OWNER_TYPE_ID": smartProcessId,
"COMPLETED": "N",
'>ID': lastSeenId
},
select:[ "ID", "OWNER_ID" ]
}
)
console.log(`Загружены ${loadedItems.length} незавершенных дел`);
if (loadedItems.length > 0) {
incompleteItemIds.push(
...loadedItems.map((element) => element.OWNER_ID)
);
lastSeenId = loadedItems[loadedItems.length - 1].ID;
}
} while (loadedItems.length == 50);
const uniqueIncompleteItemIds = [...new Set(incompleteItemIds)];
const noIncompletesList = bx24.callMethod('crm.item.list',
{
"entityTypeId": smartProcessId,
filter:
{
"!=id": uniqueIncompleteItemIds
},
select:[ "id" ]
}
).items.map((element) => element.id);
return {
"result": noIncompletesList
};