- Post History
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
yesterday
When working with custom tables, you might notice that the Flow Execution (Operational View) isn’t directly accessible.
Here’s how you can add UI Action to open the flow context for records on a custom table.
Overview:
We’ll create:
-
A UI Action (Client-side script) to trigger viewing the Flow Execution.
-
A Script Include to fetch the corresponding Flow Context record.
Step 1: Create a UI Action
Create a new UI Action on your custom table with the following settings:
-
Client callable: ✔️ (checked)
-
OnClick function:
showFlowContext()
function showFlowContext() { var id = g_form.getUniqueValue(); var ga = new GlideAjax('x_snc_safety.AjaxUtils'); ga.addParam('sysparm_name', 'getFlowContext'); ga.addParam('sysparm_tablename', g_form.getTableName()); ga.addParam('sysparm_id', id); ga.getXMLAnswer(getValue); function getValue(response) { var answer = JSON.parse(response); if (answer["success"] == "true") { g_navigation.open('/$flow-designer.do#/operations/context/' + answer.id, "_blank"); } } }
Step 2: Create a Script Include Make sure this Script Include is Client Callable and accessible from your scope.
var AjaxUtils = Class.create();
AjaxUtils.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
getFlowContext: function() {
var id = this.getParameter('sysparm_id');
var tablename = this.getParameter('sysparm_tablename');
var ctx = new GlideRecord("sys_flow_context");
ctx.addEncodedQuery("source_table=" + tablename + "^source_record=" + id);
ctx.query();
if (ctx.next()) {
var results = {
"success": "true",
"id": ctx.getUniqueValue()
};
return JSON.stringify(results);
}
gs.addErrorMessage("Flow Context does not exist for this record.");
var results = {
"success": "false"
};
return JSON.stringify(results);
},
type: 'AjaxUtils'
});
Tip:
If you have multiple flows running on the same record, you can extend this logic to show all related flow contexts or let users choose which one to open.