Viewing the "Values" field of sys_hub_action_instance_v2

Biz-JoshM
Tera Contributor

We've done some automation where we are evaluating Flows, where we perform an action if any "action" and "inputs" are present.

 

To summarize we used to do this with a mixture of querying the "sys_hub_action_instance" and "sys_variable_value" tables.

 

However, when looking at "sys_hub_action_instance_v2" there is only one field, and it is the "Values" field, which contains what seems to be an encrypted string.

 

What is the best way to programmatically see what actions and values are assigned to a Flow / Subflow taking into consideration Xanadu seems to have introduced a V2 action that uses a different methodology?

1 ACCEPTED SOLUTION

-_MS_-
Tera Expert

Found the answer in the DiffAudit script include.

 

 

 

_decompress: function(value) {
        var encoded = value.substring(this.compressed_header.length, value.length);
        var cs = GlideStringUtil.base64DecodeAsBytes(encoded);
        return String(GlideCompressionUtil.expandToString(cs));
    },

 

View solution in original post

11 REPLIES 11

Biz-JoshM
Tera Contributor

I'm surprised! Usually, these questions are answered before I even close the browser. Are there no experts in the new V2 action / subflow space? I did find out that the "Values" field is not encrypted. It is encoded (base64) then compressed (gzip). However, I can't find a native way in ServiceNow to decompress (ungzip) the encoded string.

 

Any thoughts? Perheps these elements exist somewhere else? Here's an example of an OOB action.

 

GZIP Encoded String:

 

H4sIAAAAAAAA/+VVUW/aMBD+K5WfUeQkwIC3qagSUtdKpetLV0XGvhRrjpPZTluG+O87xwkgulVU6x7Q8oLu7jv7+y73kfs1YdzJUs+0dUxzmK/sTJAJGYtBn+b9hH/qJ2kc0yShIz4SwzzhyZCmY9Ij0uP6IGg8joc8jdM0oTQZ9ePFMF3EiUgZQIw4zQpApAFeGoHxE1O1T6zXXyvBHIgsjnhtDGgXVcz/bDYIE9JWiq3ujkPzpVQCIzK5f+gRLOClDgyZrA9Kx7JWbAEKoTcd7UMZblX5WJS8LpBFJrvkZds5bStnsylWsMnTiWmPwIsDLQCJ5ExZ6JGCaZRWmhWZOFNjwgAT11qttoil1A6PJB77YuVPvLlPPS4HVMYh1LbhLVsomIYBhlI+ZY7N8XTuatPC+bKUHGyYi4Cc1cqd7+cC4LryCxJanD+47S5VXeirMBWyPaB7X5ipLWQCKq/Vsw/S8vmyfL7piF5I3YyllalKztQ2Ys4Zuaidp7MmoKCZc8GqSurHrDLlk2yakUoRPSoMolyVz3inlY86Cosd4WRZdIH5aZO+Y0Z6EV/wGGze9Ihd2XPFrN1JwTlmP2rPJAhrJWTNFJoRZM02+GZuZOU+41VP0BLf9P7WVIvBW+vJx7tt3COzM5Zj9vtrA92G7PuMcgSTzijNzv2BWeuVV7nL/d6zq1BonTL4MKeMTs0prZSTt8o/MwhN3vz/3lvDxhN2zxx4oYNvNaWpSF+b5KD6PrMcwaozy4UEJexvaHZOgQJpOcgC7QO3tMWzu7a4/bZ8mGXiIW2eEzPOf/OJefgFuN55YLkJAAA=

 

Decompressed / Decoded: 

 

[{"actionInstanceSysId":"9d540f42c74231102208c8d6f2c26039","id":"4ed01916c31332002841b63b12d3aee1","name":"record","value":"{{Updated_1.current.parent}}","displayValue":"{{Updated_1.current.parent}}","children":[],"parameter":{"children":[],"id":"4ed01916c31332002841b63b12d3aee1","label":"Record","name":"record","type":"document_id","typeLabel":"Document ID","order":10,"extended":false,"mandatory":true,"readOnly":false,"hint":"","maxsize":40,"reference":"","referenceTableDisplay":"","fDataStructure":"","choices":[],"defaultChoices":[],"choiceOption":"","table":"","columnName":"","defaultValue":"","use_dependent":true,"fShowReferenceFinder":false,"local":false,"attributes":{"element_mapping_provider":"com.glide.flow_design.action.data.FlowDesignVariableMapper"},"sysClassName":"","ref_qual":"","dependent_on":"table_name"},"scriptActive":false},{"actionInstanceSysId":"9d540f42c74231102208c8d6f2c26039","id":"b5d01916c31332002841b63b12d3aec9","name":"table_name","value":"task","displayValue":"Task","children":[],"parameter":{"children":[],"id":"b5d01916c31332002841b63b12d3aec9","label":"Table","name":"table_name","type":"table_name","typeLabel":"Table Name","order":50,"extended":false,"mandatory":true,"readOnly":false,"hint":"","maxsize":80,"reference":"","referenceTableDisplay":"","fDataStructure":"","choices":[],"defaultChoices":[],"choiceOption":"","table":"","columnName":"","defaultValue":"","use_dependent":false,"fShowReferenceFinder":false,"local":false,"attributes":{"element_mapping_provider":"com.glide.flow_design.action.data.FlowDesignVariableMapper"},"sysClassName":"","ref_qual":"","dependent_on":""},"scriptActive":false},{"actionInstanceSysId":"9d540f42c74231102208c8d6f2c26039","id":"02d01916c31332002841b63b12d3aeee","name":"values","value":"state\u003d3","displayValue":"state\u003d3","children":[],"parameter":{"children":[],"id":"02d01916c31332002841b63b12d3aeee","label":"Fields","name":"values","type":"template_value","typeLabel":"Template Value","order":100,"extended":false,"mandatory":true,"readOnly":false,"hint":"","maxsize":16000000,"reference":"","referenceTableDisplay":"","fDataStructure":"","choices":[],"defaultChoices":[],"choiceOption":"","table":"","columnName":"","defaultValue":"","use_dependent":true,"fShowReferenceFinder":false,"local":false,"attributes":{"element_mapping_provider":"com.glide.flow_design.action.data.FlowDesignVariableMapper"},"sysClassName":"","ref_qual":"","dependent_on":"table_name"},"scriptActive":false}]

-_MS_-
Tera Expert

Found the answer in the DiffAudit script include.

 

 

 

_decompress: function(value) {
        var encoded = value.substring(this.compressed_header.length, value.length);
        var cs = GlideStringUtil.base64DecodeAsBytes(encoded);
        return String(GlideCompressionUtil.expandToString(cs));
    },

 

Biz-JoshM
Tera Contributor

This works! Thank you so much!

-_MS_-
Tera Expert

Another one that can be used to test from a scoped application:

 

 

new global.VAGlobalUtil().getDecompressedValue(str)