- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2020 04:56 AM
Dear Community Members,
I am working on enabling state progress bar on case form. I have managed to do it with process flow formatter.
Now, thing is I am getting all the state in the progress bar. As below:
Now my question is, is there any way I can show only certain state based on scenerio. For example, if a case is closed completed then closed incomplete and suspended should not be visible. In other case, if a case is closed incomplete, Awaiting acceptance and closed complete should not be visible.
Can I achieve this? If yes, please help me how.
Regards,
Peeyush Jaroli
Solved! Go to Solution.
- Labels:
-
HR Service Delivery

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2020 08:13 AM
Hi,
It is possible using Onchange() client script and Script include combination i have done this try below code it work.
OnChange() Client script on State Field
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var gr = new GlideAjax('Test');//Test is Script include name
gr.addParam('sysparm_name', 'getDetails');//getDetails is function name in script include
gr.addParam('syaparm_val', newValue);//newValue is state value
gr.getXML(callback);
function callback(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
alert(answer);
if (answer == 'Authorize') //here set your case ie. 'closed completed' instead of Authorize
{
//here hide 'closed incomplete' and 'suspended' using g_form.removeOption() method
g_form.removeOption('state', '-5'); //here pass your 'closed incomplete' backend value instead of '-5'
g_form.removeOption('state', '-3'); //here pass your 'suspended' backend value instead of '-3'
} else if (answer == 'New') //here set your case ie. 'closed incomplete' instead of 'New'
{
//here hide 'Awaiting acceptance' and 'closed complete' g_form.removeOption() method and also do same as above pass correct backend value
g_form.removeOption("state", '-1');//set 'Awaiting acceptance' backend value instead of '-1'
g_form.removeOption("state", '-2');//set 'closed complete' backend value instead of '-2'
}
}
}
Script Include to check the state with Process flow state and it return label of that current state based on that hide state.
var Test = Class.create();
Test.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getDetails: function() {
var state_val = this.getParameter('syaparm_val');
gs.addInfoMessage("state=" + stateval);
var gr = new GlideRecord('sys_process_flow');
gr.addQuery('table', 'change_request');//here pass your table name instead of change_request
gr.query();
while (gr.next()) {
if (gr.condition == 'state='+state_val+'^EQ') //compare current condition with process flow condtion
{
gs.addInfoMessage("label=" + gr.label);
if (gr.label == 'Authorize')//if the label is 'closed completed' then return it to client script
{
return gr.label;
}
}
}
},
type: 'Test'
});
I hope it will help you.
Please Mark Correct/Helpful answer if it help you in any way.
Thanks and Regards,
Kunal.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-13-2020 10:12 AM
Hi,
Any update on this.
If your issue get resolve then close this thread by marking Correct/Helpful answer Or Any further assistance is needed so that we will continue this thread.
Thanks,
Kunal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-16-2020 01:11 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-14-2020 08:29 AM
Hello,
How did you get yours to work? I'm trying the same script without any luck
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-16-2020 02:55 AM