Ajay81
Kilo Contributor

Requirement:

1.Process flow formatter sequence is different for each CR type.

2.Some stages in Process Flow formatter are not required for some CR Type.

Solution:

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();

}

}

 

Comments
dschumann86
Tera Contributor

I think this is not a good solution since you update the definition records for process formatter. Problems will occur if someone else opens a change request at the same time.

Version history
Last update:
‎04-22-2019 04:16 AM
Updated by: