I want to suppress OOTB notifications for specific catalog items

bonsai
Mega Sage

I don't want to send OOTB notifications "Request approved" or "Request was opened" when I submit and approve a specific catalog item.

I wanted to control it with the condition field of the notification, but it doesn't work,Request approved.JPGRequest was opened.JPG

 

I tried setting the following script as the notification record sending condition, but it did not work properly...
I would like to consider processing without using scripts if possible.

If a catalog item other than a specific catalog item is submitted and approved, I would like to send "Request approved" and "Request was opened" as usual.

 

//Wait 3 seconds (Wait until the requested item record is created. It will be created in about 1 second, but just to be safe, wait 3 seconds)
gs.sleep(3000);

//Identification of request item record linked to request record
var tmp_req_rec = new GlideRecord("sc_req_item");
tmp_req_rec.addQuery("request", current.getUniqueValue());
tmp_req_rec.query();

//Judgment processing if the requested item record can be identified
if (tmp_req_rec.hasNext()) {
    tmp_req_rec.next();

	//Get catalog item name of requested item record
    var cat_item_name = tmp_req_rec.getDisplayValue("cat_item");

	//If the catalog item name is "XXXX" or "YYYY", the email sending process will be canceled.
    if (cat_item_name == "XXXX" ||
        cat_item_name == "YYYY"){
			answer = false;
		}
    //Submit processing for other catalog items
    else{
		answer = true;
	}

//Send email if requested item record cannot be identified
} else {
    answer = true;
}

 

1 ACCEPTED SOLUTION

If it doesnt work. Create a reference field on request table which references to catalog item table and place the condition in notification filter

"fieldName" isnot "your catalog name"

and update this field with catalog name when you submit a request for catalogs so that notification can validate this condition on your request.

Regards
Harish

View solution in original post

7 REPLIES 7

Alka_Chaudhary
Mega Sage
Mega Sage

Hello @bonsai ,

Try the below code in advanced condition of the notification just update the sys id of catalog item for which you don't want to send the notification:-

var gr = new GlideRecord('sc_req_item');
gr.addQuery('cat_item', 'edd55c3d8702111050554046cebb35c8'); //sys_id of catalog item
gr.query();
while (gr.next()) {
    if (gr.request.toString() == current.getUniqueValue()) {
        answer = false;
    } else {
        answer = true;
    }
}

 

 

If this response clears up your doubt, kindly flag it as both helpful and correct.

Thanks,

Alka

I tested it a few times and the email was sent.

I think there is a lag until the requested item is created.

Jaspal Singh
Mega Patron
Mega Patron

Hi Bonsai,

 

if (cat_item_name == "XXXX" ||
        cat_item_name == "YYYY"){

I believe should be

if (cat_item.name == "XXXX" ||
        cat_item.name == "YYYY"){

instead of _name it should be .name

The label information of the displayed catalog item is obtained by the following process.

var cat_item_name = tmp_req_rec.getDisplayValue("cat_item");