How to run a same client script on 2 tables ? and onCHange Event

Shilpi Sharma2
Tera Contributor

Hi All,

 

I want to know how to run same client script for two table named as "sc_request" or "change_request" on Onchange events of same column present in both the table. Please help.

12 REPLIES 12

Harsh Vardhan
Giga Patron

1) Create the client script on the base table, i.e. TASK

 

2) Check the Inherited checkbox on the script

 

3) In the starting of the script, use the following condition to ensure that the script is running only on Incident and Catalog Task table and not on other inherited tables from the TASK table:

 

        function onLoad() {    

 

                  var table = g_form.getTableName();

 

                  if (table == 'incident' || table == 'sc_task')

 

                  {

 

                            //alert('Run my script');

 

                            //place your code here

 

                  }

 

}

 

reference:

 

https://community.servicenow.com/community?id=community_question&sys_id=251907e1db5cdbc01dcaf3231f96...

Hi Harsh,

Thanks for your reply. But i want to use this on Onchange Event.

Hi,

Use the same script in OnChange script it will work:

 var table = g_form.getTableName();

 

                  if (table == 'incident' || table == 'sc_task')

 

                  {

 

                            //alert('Run my script');

 

                            //place your code here

 

                  }

 

THanks,
Ashutosh

Hi Ashutosh,

 

My Column is"Custom one" which is created on the child tables not on the parent table

Will it is advisable to create custom column on Task table.

 

Please help.