Add condition to client script

dvelloriy
Kilo Sage

Hi All,

I have 2 OOB client scripts - Variable Editor Readonly

on RITM and SC TASK table.

This is making all variables read-only on RITM and sc task.

Requirement is to restrict these 2 client scripts only to few catalog items. (where catalogs = Procurement).

How can i add this condition to the client scripts?

Thanks

9 REPLIES 9

Sandeep Rajput
Tera Patron
Tera Patron

@dvelloriy In your client script  Variable Editor Readonly on RITM you can check the following.

 

// Get the Catalog Item reference
var catalogItem = g_form.getReference('cat_item', callback);



function callback(catalogItem){

if (catItem.sys_id === '<sys_id of catalog item>') {

//Don't make the variables read only

}

else{

//Make variables read only

}

Hope this helps.

Thanks Sandeep, There are multiple catalog items, however they are all pointing to 1 catalogs (Procurement).

Can we add item.catalogs in the condition?

@dvelloriy Yes, the catalog check will also work. This will eliminate the need to check each catalog item individually. 

Anurag Tripathi
Mega Patron
Mega Patron

Hi,

You can try to USe Display BR to set a scratchpad variable as below, This is on RITM.

if(curent.cat_item.sc_catalogsLIKE<sys_idOf Procurement catalog>)
//set a scratchpad variable

 

In your client script check for the scratchpad, if it is true then don't run the script and if it is null or false then run it.

-Anurag