
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-11-2017 04:43 AM
Hello Everyone,
I have a client script which i wanted to run on 2 tables like Incident & task table ?
How can i achieve this ?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-11-2017 05:45 AM
Hi Abdul,
The Inherited functionality, alone, on a client script would be useful only if you would want that script to run all the extended tables of a base table.
However, since in your case, you want the script to run only on Incident and Catalog Task table, you can do the following:
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
}
}
This should work and will make this script run on only the Incident and the Catalog Task tables extended from Task. Let me know if it doesn't.
PS: Mark this answer as Correct if it solved your query or hit Like/Helpful depending upon the usefulness of the response.
Regards
Supriya Bisht
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-11-2017 06:56 AM
Hello Abdul,
Though, I am still not fully clear with your requirement but considering the table names as incident and catalog task, I would suggest you better go with a separate catalog client script for your catalog task. It will make the things easy to manage in future. Please remember if you write a client script on Task table and use the inherit checkbox, it will apply to all the tables that extends Task table therefore, be careful when choosing this option.
This is true that when you make the script as inherited and then add a condition to verify the table name (incident or catalog task) for further execution, the script will completely run for incident and catalog task only but it will be evaluated for every table that inherits the task table. However, you will be able to achieve your objective here but it will certainly impact your instance performance in the long run.
And, when you write two different scripts one for incident and another for catalog task table, the scripts will evaluate and run only for mentioned tables and not for all tables that extends task. Option this solution, will keep your instance performance better in the long run.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-16-2022 08:03 AM
Although this is an old question, I just wanted to add my opinion.
Whereas using 1 inherited Client Script on the Task table is not "wrong", it will do the trick, it is not the best idea in terms of performance as it runs on every single Task-derived table. Using 2 separate Client Scripts specifically on the Incident and Catalog Task tables would have been the better way to handle the situation.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-16-2022 08:42 AM
Although this is an old question, I just wanted to add my opinion.
Whereas using 1 inherited Client Script on the Task table is not "wrong", it will do the trick, it is not the best idea in terms of performance as it runs on every single Task-derived table. Using 2 separate Client Scripts specifically on the Incident and Catalog Task tables would have been the better way to handle the situation.
So
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-26-2019 12:33 AM
Hi All,
I want to Know how to achieve above functionality for on change client script.
Please help