Client side check if item is either Requested or Catalog item

dalton1
Giga Expert

Hi,

I want to determine on catalog client script if the current item being viewed is either Requested Item or Catalog Item. This is because I want a consolidated script that will run on both Requested and Catalog items but with special handling to each of the mentioned types.

1 ACCEPTED SOLUTION

Hi Pradeep Sharma,



I already found a way. Instead of using current, I have used g_form. So now, I can utilize the g_form.getTableName(). sc_req_item is the value being returned if current item is Requested Item. Thanks!


View solution in original post

4 REPLIES 4

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hi Dalton,



Can you give little more details what you mean if "current item being viewed is either requested item or catalog item".


Both the requested item and catalog item stored is on different table.



Please let me know if you have any questions.


Hi Pradeep Sharma,



Yes, they are stored on a different table. I have this Catalog Client Script that is applied on both Requested and Catalog items. I want to include different special handling to each of Request and Catalog items. Rather than creating additional catalog client scripts. I want to put all the codes in one client script. Below are the process:


OnLoad.PNG


Note:


1. On page load, apply general handling.


2. Determine if item is Requested or Catalog item


        2.1 If item is Catalog item, apply function A.


        2.2 If item is Requested item, apply function B.



I want a consolidated and clean script so that it could be managed easily by others. No need to handle lots of separate catalog scripts.


I have found something. Maybe I could use something like current.getTableName() to know where the current record is associated to. But 'current' cannot be used in client scripts.


Hi Pradeep Sharma,



I already found a way. Instead of using current, I have used g_form. So now, I can utilize the g_form.getTableName(). sc_req_item is the value being returned if current item is Requested Item. Thanks!