- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-20-2021 01:26 AM
I have custom tables that also have Flows that attach themselves.
I'm trying to replicate the "Flow Context" UI action on a custom table so that I can see these active flows, however the default solution thats used for RITMs obviously does not work.
How can this be modified to work correctly?
function showFlowContext () {
var url = new GlideURL('catalog_flow_context.do');
url.addParam('sysparm_sys_id', g_form.getUniqueValue());
url.addParam('sysparm_ck', g_form.getValue("sysparm_ck"));
g_navigation.open(url.getURL(), "_blank");
}
Currently it obviously does not redirect me to the correct place, the custom table does not have a sysparm_ck value.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-20-2021 06:08 PM
I managed to resolve this myself with an Ajax call.
function showFlowContext() {
var id = g_form.getUniqueValue();
var ga = new GlideAjax('AjaxUtils');
ga.addParam('sysparm_name', 'getFlowContext');
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");
}
}
}
var AjaxUtils = Class.create();
AjaxUtils.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
getFlowContext: function(){
var id = this.getParameter('sysparm_id');
var ctx = new GlideRecord("sys_flow_context");
ctx.addEncodedQuery("source_table=table_name_here^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'
});
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2022 08:27 PM
Yeah this was a script include in global scope, script include was named
AjaxUtils
Apologies for the hella late reply.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-16-2022 12:48 PM
This worked perfectly for me. Thank you!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2023 01:43 AM - edited 01-17-2023 02:23 AM
Hello @Community Alums,
It is really useful but I'm wondering if it is possible to use this script for All tables instead of every table having its script.
So for example use a variable to get the name of the current table.
I've tried but it doesn't work.
Do you know how I can find out?
Thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2023 04:07 PM
I would imagine you don't have access to g_form in your script include (your code line 4), I would harvest the table name in the client script first, and then pass the table name value to your ajax call.
Hopefully that should work for you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2023 10:29 AM
Could you possibly share screen shots of your UI action? I cant seem to get mine working and not sure what is off. Thanks!
