Approvals for 2 Catalog Item

Asosa
Tera Contributor

Hello there!

I created two catalog items for the project I'm working on:
1. To add contacts.
2. To Request a Virtual Machine.

 

I need that when requesting item No. 1, you always need manager approval for this to proceed.

 

For item No. 2, that the approval is necessary only if it is the 2nd time that a VM is requested. (I already created a variable in the catalog item that asks if it is the 1st or 2nd request).

 

I understand that for this I must use Workflows, but I'm not very familiar with the subject.

 

Any help is greatly appreciated!

1 ACCEPTED SOLUTION

Hemanth M1
Giga Sage
Giga Sage

Hi @Asosa ,

 

you don't have to ask on the UI (users might say 1 all the time), handle it through the workflow

 

in you workflow (if your using workflow ), have a if workflow activity

 

sample script 

answer = (function(){
var req = new GlideRecord("sc_req_item");
req.addQuery("cat_item", "sys_id of the catalog item"); //update the sys_id of the catalog item
req.addQuery("requested_for", current.requested_for) //check for same requestor
req.addQuery("sys_id" "!=", current.sys_id) //exclude the curernt request
req.addQuery("state" "!=" "4") //not closed incomplete
req.query();
if(req.next()){
return 'yes';
}
return 'no';
})();

 if yes , route to approval block, if no skip the approval block.

 

let me know if any questions.

 

 

Accept and hit Helpful if it helps.

Thank you,
Hemanth
Certified Technical Architect (CTA), ServiceNow MVP 2024, 2025

View solution in original post

2 REPLIES 2

Hemanth M1
Giga Sage
Giga Sage

Hi @Asosa ,

 

you don't have to ask on the UI (users might say 1 all the time), handle it through the workflow

 

in you workflow (if your using workflow ), have a if workflow activity

 

sample script 

answer = (function(){
var req = new GlideRecord("sc_req_item");
req.addQuery("cat_item", "sys_id of the catalog item"); //update the sys_id of the catalog item
req.addQuery("requested_for", current.requested_for) //check for same requestor
req.addQuery("sys_id" "!=", current.sys_id) //exclude the curernt request
req.addQuery("state" "!=" "4") //not closed incomplete
req.query();
if(req.next()){
return 'yes';
}
return 'no';
})();

 if yes , route to approval block, if no skip the approval block.

 

let me know if any questions.

 

 

Accept and hit Helpful if it helps.

Thank you,
Hemanth
Certified Technical Architect (CTA), ServiceNow MVP 2024, 2025

Hemanth M1
Giga Sage
Giga Sage

Hi @Asosa ,

 

did this help, if so.

 

 

Accept and hit Helpful if it helps.

Thank you,
Hemanth
Certified Technical Architect (CTA), ServiceNow MVP 2024, 2025