Flow Action Input Type for Generic Sys_id

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-25-2023 05:30 AM
I'm developing a 'Cancel Workflow' flow designer action. I need to be able to pass the 'current' gliderecord into the action inputs. I can't predict which table the 'current' gliderecord belongs to so I need to pass a reference to the record. In the past I've used 'Reference.xxxxxx' input types but that requires specifying the table which in this case needs to be open to any type of table (not necessarily an extension of 'task').
I tried to use type Sys_Id (GUID) but it doesn't seem to represent a true GlideRecord. Any suggestions on what input type to use?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-25-2023 06:01 AM
Hi @William Busby ,
Try to use a document ID field to reference any record on any table. You need to pair it with a Table Name field.
Basically pass the table name i.e. incident to Table Name field and sys_id to Document id field.
You can find more details on it below -
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-25-2023 06:07 AM
Hi @William Busby ,
Hope you are doing great.
1. Create an input variable of type 'Reference' in your flow designer action's inputs. Let's name it 'currentRecord' for demonstration purposes
2. Modify the action script to handle the 'current' GlideRecord:
- Within the flow designer action's script, retrieve the value of the 'currentRecord' input variable.
- Since the table for the 'current' GlideRecord can vary, you'll need to use generic GlideRecord methods to perform operations on the record.
(function execute(inputs) {
var currentRecord = inputs.currentRecord;
// Use generic GlideRecord methods to work with the 'current' record
var gr = new GlideRecord(currentRecord.sys_class_name);
gr.get(currentRecord.sys_id);
// Perform operations on the 'current' record
gr.setValue('state', 3); // Example: Set 'state' field to '3'
gr.update();
})(inputs);
This can help you idynamically handling from any table without specifying the table name in advance.
Regards,
Riya Verma

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-25-2023 11:33 AM
I thought I'd post my eventual solution here, inspired partly by both replies. I created two input variables 'id' [Sys ID (GUID)] and 'table' [string]. I also created an output variable 'success' [True/False]. My script is below:
(function execute(inputs, outputs) {
try {
// find record workflow(s) are attached to...
var gr = new GlideRecord(inputs.table);
if (gr.get(inputs.id)) {
new global.Workflow().cancel(gr);
outputs.message = "Workflows sucessfully canceled";
outputs.success = true;
}
else {
var msg = 'Flow action Cancel Workflow unable to find record ' + inputs.id+ ' in table ' + inputs.table;
gs.warn(msg);
outputs.message = msg;
outputs.success = false;
}
}
catch (ex) {
var msg = 'Exception thrown from flow action Cancel Workflow - ' + ex.message;
gs.error(msg);
outputs.message = msg;
outputs.success = false;
}
})(inputs, outputs);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-07-2025 05:15 AM
Hi William,
you have to configure your Input like this:
then you can take any record as a data pill and the table will be automatically filled in as soon as you drag the data pill in there