We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

Can you have different Process Flow Formatter for Projects

Andrew Payze
Kilo Guru

Hi,

is there a way to show different process flow (formatter) based on a specific field?

We have different types of projects with different types of phases, like construction, IT deployments.  These have different types of phases.  A the moment we have a field that defines the types of projects and fields for the different phases.....

we know how to create the different process flow in system UI->process flow.  Is there a UI / BR / CS that can determine which process flow to display based on a specific field?

Tx

Andrew

 

1 ACCEPTED SOLUTION

sayali udgave
Kilo Guru

Hi Andrew,

 

Use UI macro  for conditional process flow formatters. In below code change according to your conditions.

<?xml version="1.0" encoding="utf-8" ?>

 

<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">

 

      <link rel="stylesheet" type="text/css" href="styles/process_flow_formatter.cssx"></link>

 

      <tr>

 

              <td colspan="2" width="100%" nowrap="true">

 

                      <div>

 

                              <table width="100%" cellpadding="0" cellspacing="0">

 

                                      <tr>

 

                                              <g2:flow_formatter var="jvar_flows" table="$[__ref__.getRecordClass()]" current="$[__ref__]" />

 

                                              <g2:evaluate var="jvar_elements" jelly="true" object="true">

 

                                                      var afterCurrent = false;

 

                                                      var tableText = '';

 

                                                      var show = [];

 

                                                      var label = "";

 

                                                      var gr = new GlideRecord("sys_process_flow");

 

                                                      gr.addQuery("table", current.sys_class_name);

 

                                                      gr.orderBy("order");

 

                                                      gr.query();

 

                                                      while(gr.next()){

 

                                                              //Check to see if the record should be displayed.   If so add element to array.

 

                                                              //Array info

 

                                                              //     show[] -> Each element is a flow formatter record to display

 

                                                              //           show[].label -> Label for the flow formatter to display.

 

                                                              //           show[].state -> used to indicate the state of the flow formatter.

 

                                                              //                           Possible values: past, current, future

 

                                                              //           show[].next_state -> used to indicate the state of the next flow formatter.

 

                                                              //                           Possible values: past, current, future

 

                                                              if(GlideFilter.checkRecord(current, gr.u_view_condition)){

 

                                                                      var item = new Object();

 

                                                                      item.label = gr.getValue("label");

 

                                                                      //Check if this is the current flow that should be green/selected.

 

                                                                      if(GlideFilter.checkRecord(current, gr.condition)){

 

                                                                              item.state = "current";

 

                                                                              item.next_state = "future";

 

                                                                              //Once current is found update the previous element

 

                                                                              if(show.length > 1){

 

                                                                                      show[show.length - 1].next_state = "current";

 

                                                                              }

 

                                                                              afterCurrent = true;

 

                                                                      } else {

 

                                                                              if(afterCurrent){

 

                                                                                      item.state = "future";

 

                                                                                      item.next_state = "future";

 

                                                                              } else {

 

                                                                                      item.state = "past";

 

                                                                                      item.next_state = "past";

 

                                                                              }

 

                                                                      }

 

                                                                      show.push(item);

 

                                                              }

 

                                                      }

 

                                                      //clear the next_state element so that the process flow has a pointer at the end.

 

                                                      show[show.length - 1].next_state = "";

 

                                                      if(!afterCurrent){

 

                                                              show[show.length - 1].state = "future";

 

                                                      }

 

                                                      show;

 

                                              </g2:evaluate>

 

                                              <j2:forEach items="$[jvar_elements]" var="jvar_el">

 

                                                      <g2:evaluate jelly="true">

 

                                                              var label = jelly.jvar_el.label;

 

                                                              var state = jelly.jvar_el.state;

 

                                                              var next_state = jelly.jvar_el.next_state;

 

                                                      </g2:evaluate>

 

                                                      <td nowrap="nowrap" class="process_flow $[state]" title="$[label]">

 

                                                              $[label]

 

                                                      </td>

 

                                                      <td width="16" height="100%">

 

                                                              <img style="height: 24px; width: 21px; margin: 0px; padding: 0px;" src="images/chevron_$[state]_$[next_state].pngx" />

 

                                                      </td>

 

                                              </j2:forEach>

 

                                      </tr>

 

                              </table>

 

                      </div>

 

              </td>

 

      </tr>

 

</j:jelly>

 

 

View solution in original post

10 REPLIES 10

ggg
Giga Guru

I am trying to do exactly this and need a bit of help understanding this solution.

I have a custom process flow formatter that i want to show on a particular view of a record.

(There is another process flow formatter oob that i do NOT want to show on this view)

in each of the sys_process_flow records

i have a condition: x_myApp_state == 'New' (for example)

I think i need another condition that is: record_view_name == 'my new view'

how do i get the name of the view for that condition?

or is my logic wrong?