process_flow UI Macro in Scoped application
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-03-2020 02:11 AM
Hi,
I'm trying to use the ui macro process_flow in conjonction with the global business rule tablenamexxx_processflowlist in my scoped application in order to hide some stages on condition of the flow formatter. Like in the Demand Management form.
I duplicated the global business rule in my scoped app with the desired table and I also duplicated the process_flow UI Macro.
The original ui macro looks like this :
<?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">
var flows = null;
var functionName = current.getRecordClassName() + "_ProcessFlowList";
var func = GlideController.getGlobal(functionName);
if (typeof func == 'function') {
flows = func();
}
flows;
</g2:evaluate>
<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">
<j2:choose>
<j2:when test="$[jvar_flow.getParameter('state') == 'current']">
<j2:set var="jvar_flow_class" value="active"/>
</j2:when>
<j2:when test="$[jvar_flow.getParameter('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_flow.getParameter('state') == 'current']" true="step" false="false" />
<li class="$[jvar_flow_class]" data-state="$[jvar_flow.getParameter('state')]" aria-current="$[jvar_step_status]" role="option" aria-selected="$[jvar_flow.getParameter('state') == 'current']">
<a href="javascript:void(0);" role="presentation" aria-label="$[jvar_flow.getLabel()]">$[jvar_flow.getLabel()]</a>
</li>
</j2:forEach>
</ol>
</td></tr>
</j:jelly>
Since GlideController is not usable in scoped applications I changed the first eval like this :
<g2:evaluate var="jvar_flows" jelly="true" object="true">
var flows = x_61721_training_request_ProcessFlowList();
flows;
</g2:evaluate>
But it doesn't work, the flow formatter is empty.
If I display what it is inside the jvar_flows it displays this :
com.glide.script.fencing.ScopedChoiceList@1f30ab1
To test, I tried to edit the ootb flow_formater to call specifically my business rule :
<g2:evaluate var="jvar_flows" jelly="true" object="true">
var flows = null;
var table = current.getRecordClassName();
if(table == 'x_61721_training_request'){
flows = x_61721_training.x_61721_training_request_ProcessFlowList();
}
else{
var functionName = current.getRecordClassName() + "_ProcessFlowList";
var func = GlideController.getGlobal(functionName);
if (typeof func == 'function') {
flows = func();
}
}
flows;
</g2:evaluate>
It is working as expected like this. the jvar_flows variable show this :
[Draft : Draft, Awaiting Approval : Awaiting Approval, Approved : Approved, Work in Progress : Work in Progress, Complete : Complete]
But I would like to avoid editing ootb global stuff for my scoped application.... A compromise could be using the global flow_formater without naming a specific scoped table (It would work for any future scoped app), but I didn't find a way. I tried something like this : flows = gs.getCurrentScopeName() + '.' + current.getRecordClassName() + "_ProcessFlowList";. But gs.getCurrentScopedName returns rhino.global.
Anyone has an idea how I can achieve this ?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-03-2020 07:01 AM
This is not a trivial undertaking. This is where you have to ask yourself (or the people who handed you the requirement) "Is the cost of building and maintaining this customization worth it to have some states/stages conditionally hidden?" This is a high-level of customization that you, or someone else will need to maintain down the road. (Think about upgrades and testing too). There's already a 80-90% functional version of what you need OOB that ServiceNow continues to support.
Perhaps a new Idea in the Idea Portal (banner of the community pages), where product managers and developers get their ideas from customers, with a suggestion to add condition fields on a state entry and then move on to something that provides the organization with more business value. 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-27-2020 04:58 PM
I have submitted an Idea for this. Please vote it up, if you think it would still be useful!
https://community.servicenow.com/community?id=view_idea&sysparm_idea_id=3f37e536db8824109e691ea6689619bb&sysparm_idea_table=x_snc_com_ideation_idea&sysparm_module_id=enhancement_requests