Process Flow formatter conditions

Stacy1
Mega Guru

Hello,

I have created a process flow for Release.   Our releases have 2 different flows depending on if the product is an application or an operating system.   In my process flow I have put the condition of product.product_type is operating system but it still shows on my releases where the product.product_type is an application.

I do not see that I can create a UI Policy on process flows.

Does anyone have any thoughts on how I can have it only show based on my product type.

Thank you,

Stacy

This screen shot is a release where the product is an application, it should not be showing here:

find_real_file.png

1 ACCEPTED SOLUTION

Deepak Ingale1
Mega Sage

Unfortunately, process flow formatter shows all the process steps irrespective of the conditions given. The only thing is, it highlights a particular process step when condition matches.



You might want to create a custom process flow in which you will require to control the display of flow formatter steps based on either views.We had created separate form view to drive this.


View solution in original post

15 REPLIES 15

Thank you so much for posting this! I've been looking for a process_flow script that worked with Orlando for days! 

Hey Winston, I'm at Orlando too, but it didn't work for me following all the steps. How did you perform the steps?

Hey sir,  

Here's a helpful post that has a lot of good historical info on putting view conditions on the process flow formatter: https://community.servicenow.com/community?id=community_question&sys_id=6a738f25dbd8dbc01dcaf3231f96190d

Here are the steps I took to get it working in my test environment:

Go to system definition > dictionary entries. Add u_view_condition to sys_process_flow table as a conditions type. Note: I couldn't do this from the form designer because the condition type field wasn't available there only in dictionary.

find_real_file.png


Submit, then add "table" in dependent field.

 find_real_file.png

Make sure the new View Condition field is on the sys_process_flow form, and add the view conditions to the records you want to filter.

 find_real_file.png

Go to system UI > UI Macros. There were two process_flow UI Macros in my environments. If you have two as well mark each one unactive and see which one is actually being used currently. For me it was the newest one. I just left the older one unactive.

find_real_file.png


Drop in the below script (Same as posted above by Vishwas) in the correct process_flow UI Macro:

<?xml version="1.0" encoding="utf-8"?>
<j:jelly xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null" trim="false">
<g2:evaluate var="jvar_flows" jelly="true" object="true">
<![CDATA[
var afterCurrent = false, result = [], gr = new GlideRecord('sys_process_flow');
gr.addQuery('table', current.sys_class_name);
gr.orderBy('order');
gr.query();
while(gr.next()){
if(GlideFilter.checkRecord(current, gr.u_view_condition) && +gr.getValue('active') == 1){
var item = { label: gr.getValue('label') };
if(GlideFilter.checkRecord(current, gr.condition)){
item.state = 'current';
afterCurrent = true;
} else {
item.state = afterCurrent ? 'future':'past';
}
result.push(item);
}
}
result;
]]>
result;
</g2:evaluate>

<!-- test - ${jvar_flows} -->

<j2:if test="$[jvar_flows == null]">
<g2:flow_formatter var="jvar_flows" table="$[${ref_parent}.getRecordClassName()]" current="$[${ref_parent}]"/>
</j2:if>
<tr><td>
<ol class="process-breadcrumb process-breadcrumb-border" role="listbox">
<j2:forEach items="$[jvar_flows]" var="jvar_flow">
<g2:evaluate jelly="true" var="jvar_label" object="true" expression="jelly.jvar_flow.label">
</g2:evaluate>
<g2:evaluate jelly="true" var="jvar_state" object="true" expression="jelly.jvar_flow.state">
</g2:evaluate>

<!-- state $[jvar_label] -->

<j2:choose>
<j2:when test="$[jvar_state == 'current']">
<j2:set var="jvar_flow_class" value="active"/>
</j2:when>
<j2:when test="$[jvar_state == 'past']">
<j2:set var="jvar_flow_class" value="completed disabled"/>
</j2:when>
<j2:otherwise>
<j2:set var="jvar_flow_class" value="disabled"/>
</j2:otherwise>
</j2:choose>
<g2:set_if var="jvar_step_status" test="$[jvar_state == 'current']" true="step" false="false" />
<li class="$[jvar_flow_class]" data-state="$[jvar_state]" aria-current="$[jvar_step_status]" role="option" aria-selected="$[jvar_state == 'current']">
<a href="javascript:void(0);" role="presentation" aria-label="$[jvar_label]">$[jvar_label]</a>
</li>
</j2:forEach>
</ol>
</td></tr>
</j:jelly>


Good luck! Let me know how it goes. 

Wow! Now it worked. The problem was precisely that I changed the incorrect process_flow, since there are two. Thanks

Yea, I have no Idea why there's two of them, but glad to hear it's working now!