- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-27-2023 04:08 AM
Hi all,
I have the following requirements for my task:
9) On RITM level we will have one approval that will be Requested For Manager approval. If Request is approved then one task should be created with short description Billing assigned to any user group you like.
10) If task is closed completed then request should be marked as closed completed.
11) If task is closed incomplete then incident should be created with short description ‘Hey for Order Server catalog ${RITM Number}/${Host Name} Billing task is marked as closed incomplete’. Incident should be assigned to any group you like. Caller of the incident should be requested for value which is present on the RITM. And marked the request as closed incomplete and update the work note of the RITM with ${Incident Number} has been created as Billing task has been marked as closed Incomplete.
I am to create a workflow to do this. I am struggling as I need to take the state of the catalog task created in 9 and then perform actions depending on it (task 10). How do I specify, 'if task is closed complete, mark request as closed complete'?
In addition, which core activity should I use to create an incident on workflow? and then take the state of this incident to close the request.
So sory the question is so general, I'm very new to serviceNow and still strying to piece it all together!
Kind regards,
G
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-27-2023 06:00 AM
Hello @gunishi,
Please refer to the screenshot to build the workflow:
I hope this will help you solve your problem. Please mark it as Accepted and Helpful.
Thanks and Regards,
Anshul
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-27-2023 06:34 AM
Hi @gunishi
Please follow the below steps :
Step 1 : In Catalog task activity write below line of code
/*1. Create new sys_id of Current task */
var taskSysId = gs.generateGUID();
/*2. Store that sysId in workflow scratchpad we will use it in run script activity to create incident*/
workflow.scratchpad.taskSysId = taskSysId;
Create two condition
you can create these condition by clicking on "condition" in catalog task activity related link.
below are condition screenshots :
Step 2 : Add Run script activity and attach it with closed incomplete line.
Write below code to create incident.
/*1. Get task id form scratchpad*/
var taskId = workflow.scratchpad.taskSysId;
var taskNumber;
/*2. Glide record on task record and get Catalog task number*/
var grTask = new GlideRecord('sc_task');
grTask.addQuery('sys_id',taskId);
grTask.query();
if(grTask.next()) {
// here we will get the task number
taskNumber = grTask.getValue('number'); //use your field name
}
/*3. Create incident*/
var short_description = 'Hey for Order Server catalog ' + current.number + '/' + taskNumber + 'Billing task is marked as closed incomplete.';
var grInc = new GlideRecord('incident');
grInc.initialize();
grInc.short_description = short_description;
grInc.caller = current.requested_for;
//add more fields if you wanr
var incSysId = grInc.insert();
/*4. Glide record on incident record and get incident number */
var incNumber;
var grInc2 = new GlideRecord('incident');
grInc2.addQuery('sys_id',incSysId);
grInc2.query();
if(grInc2.next()){
incNumber = grInc2.getValue('number');
}
/*5. Update currrent RITM worknotes */
var myNotes = incNumber + ' has been created as Billing task ' + taskNumber + 'has been marked as closed Incomplete';
current.work_notes = myNotes;
ServiceNow Developer
I know one thing, and that is that I know nothing.
- Socrates
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-27-2023 06:00 AM
Hello @gunishi,
Please refer to the screenshot to build the workflow:
I hope this will help you solve your problem. Please mark it as Accepted and Helpful.
Thanks and Regards,
Anshul
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-27-2023 06:25 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-27-2023 06:34 AM
Hi @gunishi
Please follow the below steps :
Step 1 : In Catalog task activity write below line of code
/*1. Create new sys_id of Current task */
var taskSysId = gs.generateGUID();
/*2. Store that sysId in workflow scratchpad we will use it in run script activity to create incident*/
workflow.scratchpad.taskSysId = taskSysId;
Create two condition
you can create these condition by clicking on "condition" in catalog task activity related link.
below are condition screenshots :
Step 2 : Add Run script activity and attach it with closed incomplete line.
Write below code to create incident.
/*1. Get task id form scratchpad*/
var taskId = workflow.scratchpad.taskSysId;
var taskNumber;
/*2. Glide record on task record and get Catalog task number*/
var grTask = new GlideRecord('sc_task');
grTask.addQuery('sys_id',taskId);
grTask.query();
if(grTask.next()) {
// here we will get the task number
taskNumber = grTask.getValue('number'); //use your field name
}
/*3. Create incident*/
var short_description = 'Hey for Order Server catalog ' + current.number + '/' + taskNumber + 'Billing task is marked as closed incomplete.';
var grInc = new GlideRecord('incident');
grInc.initialize();
grInc.short_description = short_description;
grInc.caller = current.requested_for;
//add more fields if you wanr
var incSysId = grInc.insert();
/*4. Glide record on incident record and get incident number */
var incNumber;
var grInc2 = new GlideRecord('incident');
grInc2.addQuery('sys_id',incSysId);
grInc2.query();
if(grInc2.next()){
incNumber = grInc2.getValue('number');
}
/*5. Update currrent RITM worknotes */
var myNotes = incNumber + ' has been created as Billing task ' + taskNumber + 'has been marked as closed Incomplete';
current.work_notes = myNotes;
ServiceNow Developer
I know one thing, and that is that I know nothing.
- Socrates
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-28-2023 06:33 AM
Thank you so much for the effort you have put into my anser. It is so explicit and this has really aided in my understanding. The screenshots have also been invaluable and confirme somethings that I was previously unsure about.
G