- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-02-2024 12:59 PM
Hello,
I have a requirement to make a state value( "Work In Progress" ) visible only when a particular configuration item is chosen on an incident form.
If a user choses "Abc" in configuration item on an incident form, Work In progress state ( value =-5) value should show up in State field.
Can you all help me with the client script for this please.
Appreciate your response.
-Thanks
Shree
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-02-2024 08:53 PM
Hi @Shree Nag
Can you try the below script
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
// If the form is loading or the new value is empty, do nothing
if (isLoading) {
var citem = g_form.getValue('cmdb_ci');
return;
}
var citem = g_form.getDisplayBox('cmdb_ci').value;
alert(citem);
if (citem !== '' && citem.startsWith('Thi')) { // updated the code as per your need
g_form.addOption('state', 'work_in_progress', 'Work In Progress');
} else {
g_form.removeOption('state', 'work_in_progress');
}
}
Thanks and Regards
Sai Venkatesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-02-2024 01:12 PM
If you post what you have already tried, you are likely to get your issue resolved faster.
Blog: https://sys.properties | Telegram: https://t.me/sys_properties | LinkedIn: https://www.linkedin.com/in/slava-savitsky/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-02-2024 01:15 PM
Hi @Shree Nag
You can use onChange client script to achieve this, select configuration item as a field name for this client script.
var ci = g_form.getValue("cmdb_ci");
if (ci == "<sys_id of ABC ci>") {
g_form.setVisible('state', true);
g_form.setValue("state", "-5");
} else {
g_form.setVisible('state', false);
}
If this solution resolves your query, kindly mark it as the accepted solution and give it a thumbs up.
Best Regards,
Krushna Birla
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-02-2024 01:27 PM
I updated my script. @SAI VENKATESH was helpful in getting the State field setting to "work in Progress". But we need to just populate/add the choice of "Work In Progress" to state field. The user will select from the list.
Also when the configuration item is not ABC, The state should not display " work In Progress" at all. Right now it does.
here is what I did So far.
1.I added the Work In Progress in Choice list on incident form.
2. I added a UI Policy. Added condition as, If configuration Item contains "ABC".
3. I want to add UI policy action under this to select Field name "State" to display "Work In Progress" , Only when the configuration item is selected. But Im unable to select to value level .
How do I narrow down for the value of "work In Progress" to display only when certain Configuration is selected.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-02-2024 01:30 PM - edited 07-02-2024 01:52 PM
Hi @Shree Nag
I provided the updated script please look into it.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
// If the form is loading or the new value is empty, do nothing
if (isLoading || newValue === '') {
return;
}
if (newValue !== '') {
g_form.addOption('state', 'work_in_progress', 'Work In Progress');
}
else{
g_form.removeOption('state', 'work_in_progress', 'Work In Progress');
}
}
Thanks and Regards
Sai Venkatesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-02-2024 07:12 PM
Hello All,
Thank you all for pitching in. I updated the client script with both @Community Alums and @Krushna R Birla's script. But I still see the work in progress state without even choosing any configuration item. Here are few pics attached
Hopefully this will shed some light and help me resolve the issue.