How to change process formatters based on condition

tonystark
Mega Expert

Hi All,

              In my change form I have different states for type routine & emergency. So i need to change the process flow which are displayed on top of the form. can we hide those based on condition or based on views. I need those process flows to get changed based on the type the change is. Please help me where the condition needs to be built?

Thanks,

Tony

8 REPLIES 8

Paul Curwen
Giga Sage

This ServiceNow Share   should do what you are wanting, it adds a separate view condition to the process flow formatter and makes it dynamic. Works well.



Looking at the comments minor adjustments needed for Helsinki, but all documented in the discussion.


***If Correct/Helpful please take time mark as Correct/Helpful. It is much appreciated.***

Regards

Paul

robinchadwick
Mega Expert

To stay within OOB functionality, the process flow applies to the table [change_requests].   You cannot have a different process flow for different views as each of your views is still based on the table [change_requests].   The conditions you specify for each entry in the Process Flow only control when that entry is highlighted in the Process Flow at the top of the screen.  


Ajay81
Kilo Contributor

Hi tonystark,

 

 

 

Write a Business rule on Change Request(change_request) table

When to run:display

Order:1

In advanced add the script.

To check for the type of the Change Request

var typ=current.type.toString();

if(typ=='standard')

 

To make a stage in Process Flow inactive or remove:

Query 'sys_process_flow' table with 'label =<label name>'

And make that particular stage false.

var flow=new GlideRecord('sys_process_flow');

flow.addQuery('label','Assess');

flow.query();

if(flow.next())

{

flow.active=false;//make assess stage false

flow.update();

}

 

To change the order of the flow formatter:

Query 'sys_process_flow' table for 'active = true' condition

Check for the label and assign the order .

 

var floworder=new GlideRecord('sys_process_flow');

floworder.addQuery('active',true);

floworder.query();

while(floworder.next())

{

if(floworder.label=='Assess')

{

floworder.order='200';

}

if(floworder.label=='Scheduled')

{

floworder.order='300';// order changed

}

if(floworder.label=='Implement')

{

floworder.order='500';//order changed

}

if(floworder.label=='Authorize')

{

floworder.order='400';//order changed

}

floworder.update();

}

So each time Standard change is opened , the process flow formatter order changes.

 

Make sure to add another condition to keep Process flow formatter default and all the stages active for other Change Request Types.

 

if(typ=='emergency'||typ=='normal')

{

var globalFlow=new GlideRecord('sys_process_flow');

globalFlow.addQuery('label','Assess');

globalFlow.query();

if(globalFlow.next())

{

globalFlow.active=true;

globalFlow.update();

}

 

var globalFloworder=new GlideRecord('sys_process_flow');

globalFloworder.addQuery('active',true);

globalFloworder.query();

while(globalFloworder.next())

{

if(globalFloworder.label=='Assess')

{

globalFloworder.order='200';

}

if(globalFloworder.label=='Authorize')

{

globalFloworder.order='300';

}

if(globalFloworder.label=='Scheduled')

{

globalFloworder.order='400';

}

if(globalFloworder.label=='Implement')

{

globalFloworder.order='500';

}

globalFloworder.update();

}

}

If this is correct please mark helpful.

Ashwini20
Kilo Contributor

HI, 

Did you find an answer for this? I want to have two different process flows on sc_req_item table based on conditions