- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2019 04:12 AM
Hi All,
How can I add Checklist template automatically on catalog task on the bases of Catalog item.
For eg : I have an catalog item named as 'Printer toner' on this catalog task it should display the checklist template eg ('printer toner checklist') Likewise for other catalog item it should display the checklist which is created for those specific item in catalog task.
Below is my business script which is working fine , but it is displaying same checklist template for all catalog task.
(function executeRule(current, previous /*null when async*/) {
var getTemplate = new GlideRecord('checklist_template');
getTemplate.addQuery('sys_id', 'a67c9775db797300a477874239961985');
getTemplate.query();
if(getTemplate.next()) {
var itemJSON = new JSON().decode(getTemplate.template);
var name = itemJSON['name'];
var items = itemJSON['items'];
var owner = itemJSON['owner'];
// create checklist
var table = current.getTableName();
var checklistId = '';
var list = new GlideRecord('checklist');
list.addQuery('document', current.sys_id + '');
list.addQuery('table', table);
list.query();
if (!list.next()) {
list.document = current.sys_id + '';
list.name = name;list.owner = owner;
list.table = table;
checklistId = list.insert();
// create checklist items
for (var i = 0; i < items.length; i++) {
var item = new GlideRecord('checklist_item');
item.checklist = checklistId;
item.complete = false;
item.name = items[i]['name'];
item.order = items[i]['order'];
item.insert();
}
}
}
})(current, previous);
Any help or suggestions would be helpful.
Thanks and Regards,
Meenal
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2019 04:22 AM
can you add the log in your glide record to check the row count.
i am adding one thread here, which has quite same requirement. hope it will help you

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2019 04:22 AM
can you add the log in your glide record to check the row count.
i am adding one thread here, which has quite same requirement. hope it will help you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2019 05:28 AM
Hi Harshvardhan,
I checked the above link and it is working fine, but then if I have to run the script on all workflow's---> catalog task.
Is there any way I can use single script for all catalog task checklist on the bases of catalog Items requested.
Thanks and regards,
Meenal