Client Script to control the state choice of task
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā08-16-2024 07:01 AM
How to write client script to control the state choice option for task table
It should behave like below -
-show work in progress when task is open
-show other state when the task is work in progress except open
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā08-16-2024 07:11 AM
I feel your pain, ChadLee4! As of now, there isn't a way to directly map attachments to specific fields in the portal. However, I've seen some discussions on the ServiceNow community about potential future enhancements for this functionality. Maybe subscribing to relevant forums or keeping an eye on release notes could be helpful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā08-16-2024 07:22 AM
Use remove option in an onLoad Client Script with caution - applying this to the task table will affect extended tables that you may not want to do this on - incident, problem, change, request, requested item, and like 60 other tables, so better to apply it directly to whatever table(s) you want to have this behaviour.
You would need a similar script onChange to handle the State field changing whilst a record is displayed.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā08-16-2024 09:09 AM
hmm, I tried an onload client script defined on task. And I don't see it running when I open an incident record or other child table. The following works in limited testing of a few records.
//-show work in progress when task is open
//-show other state when the task is work in progress except open
function onLoad() {
var stateVal = g_form.getValue('state');
alert("Task state client script. state = " + stateVal);
if (stateVal == '1') {
// alert('state is 1');
g_form.removeOption('state', '3');
g_form.removeOption('state', '-5');
g_form.removeOption('state', '4');
g_form.removeOption('state', '1');
g_form.removeOption('state', '7');
}
if (stateVal == '2') {
// alert('state is 2');
g_form.removeOption('state', '1');
}
}
And as @Brad Bowman states, you may want an onChange client script based on your goal.