Can we populate 1st task number in the work notes of 2nd task in workflow.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2023 08:29 AM
Hi Community,
Can we populate the 1st catalog task number to the work notes of the 2ns catalog task in workflow. Can anyone please help me.
Thanks,
Spandana.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2023 10:28 AM
HI There,
Here's the high-level solution:
Create a Business Rule on the 2nd catalog task table (e.g., sc_task) to trigger the action when a new record is inserted.
In the Business Rule, use a script to retrieve the 1st catalog task number associated with the same parent request (request number) as the current 2nd catalog task.
Once you have the 1st catalog task number, update the work notes field of the current 2nd catalog task with this information.
Here's a code snippet to illustrate the solution:
// Business Rule on the 2nd catalog task table (sc_task)
// Set the 'When' field to "Before" and 'Insert' for the 'Insert' operation.
(function executeRule(current /* GlideRecord */) {
// Check if the current 2nd catalog task has a parent request (request number)
if (current.request) {
// Query the 1st catalog task associated with the same parent request
var firstCatalogTask = new GlideRecord('sc_task');
firstCatalogTask.addQuery('request', current.request);
firstCatalogTask.orderBy('sys_created_on'); // Assuming you want the first task created.
firstCatalogTask.setLimit(1);
firstCatalogTask.query();
// If the 1st catalog task is found, update the work notes of the current 2nd catalog task.
if (firstCatalogTask.next()) {
current.work_notes = '1st catalog task number: ' + firstCatalogTask.number;
}
}
})(current);
Regards,
Riya Verma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2023 06:23 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2023 12:15 PM
@spandana kalla , where its getting stuck?
Regards,
Riya Verma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2023 02:07 AM
@Riya Verma the script itself is not working . I created the business rule and then for testing purpose i submitted the request to the form and then checked it in the catalog tasks, it's not populating.
Thanks,
Spandana.