Grey out "No longer Required" option from the Approval drop down "Action on selected rows"

Community Alums
Not applicable

Hi,

I have a requirement to grey out/hide "No longer Required" option from the Approval drop down from "Action on selected rows" and this should be hidden only to tickets generated from a particular catalog item. How can I achieve this? Any suggestions would be greatly appreciated. Here is the screenshot of the requirement. I have to hide "No longer Required" option which is highlighted in yellow for tickets generated from a particular catalog item. Please guide me.

 

saran20_0-1700127807733.png

 

Thanks,

Saran.

 

15 REPLIES 15

Hi @Community Alums 

Oops! It's because the table, what I gave you before is for Requested item [sc_req_item] table.

And from your screenshot, I can see it's for Request [sc_request] table. So there'll be no Cat Item [cat_item] field in this table.

We need to define a function in a script include to achieve it.

#Script Include

 

var CLCatalogItemUtils = Class.create();
CLCatalogItemUtils.prototype = {
    initialize: function() {
    },

	isVisible: function(current){
		//apply only Request table
		if(current.source_table != 'sc_request'){
				return true;
		}
		var itemID = 'e591f18b47eaf990ab9bb6bf016d430b'; //Snack Ordering
		var grRITM = new GlideRecord('sc_req_item');
		grRITM.addQuery('request', current.sysapproval);
		grRITM.addQuery('cat_item', '!=', itemID);
		grRITM.query();
		return grRITM.hasNext();
	},

    type: 'CLCatalogItemUtils'
};

 

 

#UI Action

 

new CLCatalogItemUtils().isVisible(current);

 

 

My Test Case with the Approve button

#Snack Ordering

Timi_0-1701775198042.png

Timi_1-1701775213763.png

 

#Other item

Timi_2-1701775262922.png

Timi_3-1701775284172.png

 

Cheers,

Tai Vu