From d6435f641e5c0cf938587f9792eb13eb5d22d5ec Mon Sep 17 00:00:00 2001 From: admin Date: Thu, 23 Oct 2025 02:08:58 -0700 Subject: [PATCH 1/2] =?UTF-8?q?Get=20GlideAggregate(Multiple)=20Flow=20Act?= =?UTF-8?q?ion=20=E2=80=94=20initial=20commit=20by=20@NowSharif?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- b812ceb69337a210633378917cba10bc/README.md | 2 +- ...ition_32a1c1c5477cba10ca05a464116d43da.xml | 5163 +++++++++++++++++ 2 files changed, 5164 insertions(+), 1 deletion(-) create mode 100644 b812ceb69337a210633378917cba10bc/update/sys_hub_action_type_definition_32a1c1c5477cba10ca05a464116d43da.xml diff --git a/b812ceb69337a210633378917cba10bc/README.md b/b812ceb69337a210633378917cba10bc/README.md index 1aa7e3e..05cd6fa 100644 --- a/b812ceb69337a210633378917cba10bc/README.md +++ b/b812ceb69337a210633378917cba10bc/README.md @@ -24,4 +24,4 @@ If you find yourself unable to import your repository due to the presence of fil 2.2 Activate/install all required dependencies 2.3 Re-import the application from source control Currently listed dependencies: - * ServiceNow IntegrationHub Enterprise Pack Installer + * diff --git a/b812ceb69337a210633378917cba10bc/update/sys_hub_action_type_definition_32a1c1c5477cba10ca05a464116d43da.xml b/b812ceb69337a210633378917cba10bc/update/sys_hub_action_type_definition_32a1c1c5477cba10ca05a464116d43da.xml new file mode 100644 index 0000000..d96a512 --- /dev/null +++ b/b812ceb69337a210633378917cba10bc/update/sys_hub_action_type_definition_32a1c1c5477cba10ca05a464116d43da.xml @@ -0,0 +1,5163 @@ + + + public + + + + true + + {labelCacheCleanUpExecuted=true} + 28100 + false + + + + Execute statistical calculations on any ServiceNow table by providing a table name, query conditions, and field to aggregate. The action returns comprehensive metrics including count, sum, average, minimum, maximum, and standard deviation in a single execution. Eliminates the need for custom GlideAggregate scripts, making advanced data analytics accessible to administrators and low-code developers. + + false + get_glideaggregatemultiple + [{"name":"{{action.table}}","label":"action➛Table","type":"action","ref":"","reference_display":"","base_type":"table_name","parent_table_name":"","column_name":"","choices":null,"attributes":{}},{"name":"{{action.conditions}}","label":"action➛Conditions","type":"action","ref":"","reference_display":"","base_type":"conditions","parent_table_name":"","column_name":"","choices":null,"attributes":{}},{"name":"{{action.variable1}}","label":"action➛Field","type":"action","ref":"","reference_display":"","base_type":"string","parent_table_name":"","column_name":"","choices":null,"attributes":{"uiTypeLabel":"String","element_mapping_provider":"com.glide.flow_design.action.data.FlowDesignVariableMapper","uiType":"string","uiUniqueId":"ca036a30-09ea-4457-808d-87fd93c4e891"}},{"name":"{{action.field}}","label":"action➛Field","type":"action","ref":"","reference_display":"","base_type":"string","parent_table_name":"","column_name":"","choices":null,"attributes":{}},{"name":"{{action.variable}}","label":"action➛variable","type":"action","ref":"","reference_display":"","base_type":"string","parent_table_name":"","column_name":"","choices":null,"attributes":{}},{"name":"{{action.aggregate_by}}","label":"action➛Aggregate by","type":"action","ref":"","reference_display":"","base_type":"string","parent_table_name":"","column_name":"","choices":null,"attributes":{}},{"name":"{{action.aggregate_type}}","label":"action➛Aggregate Type","type":"action","ref":"","reference_display":"","base_type":"choice","parent_table_name":"","column_name":"","choices":[{"label":"COUNT","value":"COUNT","order":0.0},{"label":"SUM","value":"SUM","order":1.0},{"label":"AVG","value":"AVG","order":2.0},{"label":"MIN","value":"MIN","order":3.0},{"label":"MAX","value":"MAX","order":4.0},{"label":"STDDEV","value":"STDDEV","order":5.0},{"label":"GROUP_CONCAT","value":"GROUP_CONCAT","order":6.0},{"label":"GROUP_CONCAT_DISTINCT","value":"GROUP_CONCAT_DISTINCT","order":7.0},{"label":"All Aggregates","value":"ALL","order":8.0}],"attributes":{"uiTypeLabel":"Choice","element_mapping_provider":"com.glide.flow_design.action.data.FlowDesignVariableMapper","uiType":"choice","uiUniqueId":"e4b7df3a-04ed-4067-a1af-c976821ca762"}},{"name":"{{step[b9c2c56e-4f59-44aa-b717-00cb3a915d34].success}}","label":"step➛Aggregation Script➛Success","type":"step","ref":"","reference_display":"","base_type":"boolean","parent_table_name":"","column_name":"","choices":null,"attributes":{"uiTypeLabel":"True/False","element_mapping_provider":"com.glide.flow_design.action.data.FlowDesignVariableMapper","uiType":"boolean","uiUniqueId":"db2cbe69-41cc-4244-9cf5-4430d7cc4a61"}},{"name":"{{step[b9c2c56e-4f59-44aa-b717-00cb3a915d34].error}}","label":"step➛Aggregation Script➛Error","type":"step","ref":"","reference_display":"","base_type":"string","parent_table_name":"","column_name":"","choices":null,"attributes":{"uiTypeLabel":"String","element_mapping_provider":"com.glide.flow_design.action.data.FlowDesignVariableMapper","uiType":"string","uiUniqueId":"5a1548bc-bca9-412a-bffe-5e75e1da5c42"}},{"name":"{{step[b9c2c56e-4f59-44aa-b717-00cb3a915d34].aggregates}}","label":"step➛Aggregation Script➛Aggregates","type":"step","ref":"","reference_display":"","base_type":"json","parent_table_name":"","column_name":"","choices":null,"attributes":{"sourceId":"","uiTypeLabel":"Object","co_type_name":"","element_mapping_provider":"com.glide.flow_design.action.data.FlowDesignVariableMapper","sourceUiUniqueId":"","sourceType":"","uiType":"object","uiUniqueId":"7209ca22-5861-41e0-af52-b6df525b3284"}},{"name":"{{step[b9c2c56e-4f59-44aa-b717-00cb3a915d34].message}}","label":"step➛Aggregation Script➛Message","type":"step","ref":"","reference_display":"","base_type":"string","parent_table_name":"","column_name":"","choices":null,"attributes":{"sourceId":"","sourceUiUniqueId":"","sourceType":""}}] + a18cd9cd4730fa10ca05a464116d436d + + Get GlideAggregate(Multiple) + + + + false + published + sys_hub_action_type_definition + admin + 2025-10-23 07:09:03 + global + / + 32a1c1c5477cba10ca05a464116d43da + 23 + Get GlideAggregate(Multiple) + + b812ceb69337a210633378917cba10bc + + b812ceb69337a210633378917cba10bc + sys_hub_action_type_definition_32a1c1c5477cba10ca05a464116d43da + admin + 2025-10-23 09:06:25 + false + + + + + + sys_hub_action_type_definition + 32a1c1c5477cba10ca05a464116d43da + 1 + sys_variable_value + admin + 2025-10-23 07:09:57 + 77d18589477cba10ca05a464116d43e9 + 1 + admin + 2025-10-23 09:00:53 + {"version":"1.0","serializationFormat":"JSON","complexObjectSchema":{"FlowDesigner:FDACTIONSTATUS":{"code":"Integer","code.$field_facets":{"SimpleMapFacet":"{\"uiTypeLabel\":\"Integer\",\"read_only\":\"false\",\"hint\":\"\",\"uiType\":\"integer\",\"default_value\":\"\",\"label\":\"Code\",\"action_error_output\":\"true\",\"mandatory\":\"false\",\"order\":\"1\",\"max_length\":\"40\"}"},"message":"String","message.$field_facets":{"SimpleMapFacet":"{\"uiTypeLabel\":\"String\",\"read_only\":\"false\",\"hint\":\"\",\"uiType\":\"string\",\"mapped\":\"{}\",\"default_value\":\"\",\"label\":\"Message\",\"action_error_output\":\"true\",\"mandatory\":\"false\",\"order\":\"2\",\"max_length\":\"4000\"}"}},"FlowDesigner:FDACTIONSTATUS.$type_facets":{"SimpleMapFacet":"{\"default_value\":\"\",\"label\":\"Action Status\",\"action_error_output\":\"true\",\"mandatory\":\"false\",\"uiUniqueId\":\"4adfb7bc-9d67-498d-88d0-8d6c3d584fed\",\"uiTypeLabel\":\"Object\",\"co_type_name\":\"FDACTIONSTATUS\",\"element_mapping_provider\":\"com.glide.flow_design.action.data.FlowDesignVariableMapper\",\"read_only\":\"false\",\"hint\":null,\"uiType\":\"object\",\"order\":\"1\",\"max_length\":\"65000\"}"}},"complexObject":{"code":{"$cv":{"$c":"java.lang.String","$v":""}},"message":{"$cv":{"$c":"java.lang.String","$v":""}}}} + 73d18589477cba10ca05a464116d439d + + + sys_hub_action_type_definition + 32a1c1c5477cba10ca05a464116d43da + 1 + sys_variable_value + admin + 2025-10-23 07:50:08 + a01b410d47bcba10ca05a464116d4373 + 0 + admin + 2025-10-23 07:50:08 + 0 + 87fa4dc947bcba10ca05a464116d43bc + + + sys_hub_action_type_definition + 32a1c1c5477cba10ca05a464116d43da + 2 + sys_variable_value + admin + 2025-10-23 07:09:57 + b7d18589477cba10ca05a464116d43e8 + 0 + admin + 2025-10-23 07:09:57 + 0 + f3d18589477cba10ca05a464116d43d7 + + + sys_hub_action_type_definition + 32a1c1c5477cba10ca05a464116d43da + 5 + sys_variable_value + admin + 2025-10-23 07:49:46 + cbfa8dc947bcba10ca05a464116d4308 + 3 + admin + 2025-10-23 07:54:45 + + 0ffa4dc947bcba10ca05a464116d43ee + + + + aggregates + 32a1c1c5477cba10ca05a464116d43da + admin + 2025-10-23 07:49:46 + 0bfa8dc947bcba10ca05a464116d4308 + 3 + admin + 2025-10-23 07:54:45 + var__m_sys_hub_action_output_32a1c1c5477cba10ca05a464116d43da
+ {{step[b9c2c56e-4f59-44aa-b717-00cb3a915d34].aggregates}} +
+ + error + 32a1c1c5477cba10ca05a464116d43da + admin + 2025-10-23 07:50:08 + a81b410d47bcba10ca05a464116d4372 + 0 + admin + 2025-10-23 07:50:08 + var__m_sys_hub_action_output_32a1c1c5477cba10ca05a464116d43da
+ {{step[b9c2c56e-4f59-44aa-b717-00cb3a915d34].error}} +
+ + message + 32a1c1c5477cba10ca05a464116d43da + admin + 2025-10-23 07:51:52 + 067bcd0d47bcba10ca05a464116d43eb + 0 + admin + 2025-10-23 07:51:52 + var__m_sys_hub_action_output_32a1c1c5477cba10ca05a464116d43da
+ {{step[b9c2c56e-4f59-44aa-b717-00cb3a915d34].message}} +
+ + success + 32a1c1c5477cba10ca05a464116d43da + admin + 2025-10-23 07:50:08 + ec1b410d47bcba10ca05a464116d4372 + 0 + admin + 2025-10-23 07:50:08 + var__m_sys_hub_action_output_32a1c1c5477cba10ca05a464116d43da
+ {{step[b9c2c56e-4f59-44aa-b717-00cb3a915d34].success}} +
+ + __action_status__ + 32a1c1c5477cba10ca05a464116d43da + admin + 2025-10-23 07:09:57 + f3d18589477cba10ca05a464116d43e8 + 0 + admin + 2025-10-23 07:09:57 + var__m_sys_hub_action_output_32a1c1c5477cba10ca05a464116d43da
+ +
+ + __dont_treat_as_error__ + 32a1c1c5477cba10ca05a464116d43da + admin + 2025-10-23 07:09:57 + b7d18589477cba10ca05a464116d43e7 + 0 + admin + 2025-10-23 07:09:57 + var__m_sys_hub_action_output_32a1c1c5477cba10ca05a464116d43da
+ +
+ + + 32a1c1c5477cba10ca05a464116d43da + b9c2c56e-4f59-44aa-b717-00cb3a915d34 + 1 + + + + + + + 1 + +
+ 106afb6647032200b4fad7527c9a71e7 + admin + 2025-10-23 07:12:24 + 676249c9477cba10ca05a464116d4340 + 9 + b812ceb69337a210633378917cba10bc + admin + 2025-10-23 09:00:51 + + + + sys_hub_step_instance + 676249c9477cba10ca05a464116d4340 + 600 + sys_variable_value + admin + 2025-10-23 07:12:24 + 376249c9477cba10ca05a464116d4356 + 5 + admin + 2025-10-23 09:00:51 + (function execute(inputs, outputs) { + try { + // Normalize and validate required inputs + var tableName = String(inputs.table_name || '').trim(); + var conditions = String(inputs.conditions || '').trim(); + var fieldName = String(inputs.field || '').trim(); + var aggregateType = String(inputs.aggregate_type || '').trim().toUpperCase(); + + // Input validation + if (!tableName) { + outputs.success = false; + outputs.error = 'Missing required input: table_name'; + return; + } + if (!fieldName) { + outputs.success = false; + outputs.error = 'Missing required input: field'; + return; + } + if (!aggregateType) { + outputs.success = false; + outputs.error = 'Missing required input: aggregate_type'; + return; + } + + // Validate table exists + var tableValidator = new GlideRecord(tableName); + if (!tableValidator.isValid()) { + outputs.success = false; + outputs.error = 'Invalid table: ' + tableName; + return; + } + + // Validate field exists on the table + if (!tableValidator.isValidField(fieldName)) { + outputs.success = false; + outputs.error = 'Invalid field: ' + fieldName + ' on table: ' + tableName; + return; + } + + // Get field type from sys_dictionary + var fieldType = null; + var fieldInfo = new GlideRecord('sys_dictionary'); + fieldInfo.addQuery('name', tableName); + fieldInfo.addQuery('element', fieldName); + fieldInfo.setLimit(1); + fieldInfo.query(); + if (fieldInfo.next()) { + fieldType = fieldInfo.getValue('internal_type'); + } + + + + // Initialize result object with all possible aggregates + var aggregateResult = { + count: null, + sum: null, + avg: null, + max: null, + min: null, + stddev: null, + group_concat: null, + group_concat_distinct: null, + aggregate_type_requested: aggregateType + }; + + // Validate aggregate type is one of the allowed values + var allowedTypes = ['COUNT', 'SUM', 'AVG', 'MAX', 'MIN', 'STDDEV', 'GROUP_CONCAT', 'GROUP_CONCAT_DISTINCT', 'ALL']; + if (allowedTypes.indexOf(aggregateType) === -1) { + outputs.success = false; + outputs.error = 'Invalid aggregate_type: ' + aggregateType + '. Allowed values: ' + allowedTypes.join(', '); + return; + } + + // Determine which aggregates are applicable based on field type + var isNumericField = ['integer', 'decimal', 'float', 'currency', 'percent', 'price'].indexOf(fieldType) !== -1; + var skippedAggregates = []; + var applicableAggregates = []; + + // Numeric aggregates only work on numeric fields + var numericAggregates = ['SUM', 'AVG', 'STDDEV', 'MAX', 'MIN']; + var stringAggregates = ['GROUP_CONCAT', 'GROUP_CONCAT_DISTINCT', 'COUNT']; + + if (aggregateType === 'ALL') { + // For ALL, add only applicable aggregates based on field type + aggregateResult.count = 0; // COUNT always works + applicableAggregates.push('COUNT'); + + if (isNumericField) { + numericAggregates.forEach(function(agg) { + applicableAggregates.push(agg); + }); + } else { + numericAggregates.forEach(function(agg) { + skippedAggregates.push(agg + ' (not applicable for ' + fieldType + ' field)'); + }); + } + + stringAggregates.filter(function(agg) { + return agg !== 'COUNT'; + }).forEach(function(agg) { + applicableAggregates.push(agg); + }); + } else { + // Single aggregate requested + if (aggregateType === 'COUNT') { + applicableAggregates.push('COUNT'); + } else if (numericAggregates.indexOf(aggregateType) !== -1 && !isNumericField) { + skippedAggregates.push(aggregateType + ' (not applicable for ' + fieldType + ' field)'); + } else { + applicableAggregates.push(aggregateType); + } + } + + // If no applicable aggregates, return error + if (applicableAggregates.length === 0) { + outputs.success = false; + outputs.error = 'No applicable aggregates for field type: ' + fieldType + '. Requested: ' + aggregateType; + outputs.skipped_aggregates = skippedAggregates; + return; + } + + // Create GlideAggregate instance + var aggregator = new GlideAggregate(tableName); + if (conditions) { + aggregator.addEncodedQuery(conditions); + } + aggregator.setGroup(false); + + // Add only applicable aggregates + applicableAggregates.forEach(function(agg) { + aggregator.addAggregate(agg, fieldName); + }); + + // Execute the aggregate query + aggregator.query(); + + // Process results + if (aggregator.next()) { + applicableAggregates.forEach(function(agg) { + var rawValue = aggregator.getAggregate(agg, fieldName); + + switch (agg) { + case 'COUNT': + aggregateResult.count = parseInt(rawValue) || 0; + break; + case 'SUM': + aggregateResult.sum = parseFloat(rawValue) || 0; + break; + case 'AVG': + aggregateResult.avg = parseFloat(rawValue) || 0; + break; + case 'MAX': + aggregateResult.max = isNumericField ? (parseFloat(rawValue) || null) : (rawValue || null); + break; + case 'MIN': + aggregateResult.min = isNumericField ? (parseFloat(rawValue) || null) : (rawValue || null); + break; + case 'STDDEV': + aggregateResult.stddev = parseFloat(rawValue) || 0; + break; + case 'GROUP_CONCAT': + aggregateResult.group_concat = String(rawValue || ''); + break; + case 'GROUP_CONCAT_DISTINCT': + aggregateResult.group_concat_distinct = String(rawValue || ''); + break; + } + }); + + outputs.success = true; + outputs.message = 'Aggregate(s) calculated successfully. Field type: ' + fieldType; + if (skippedAggregates.length > 0) { + outputs.message += '. Skipped: ' + skippedAggregates.join('; '); + } + outputs.aggregates = aggregateResult; + outputs.skipped_aggregates = skippedAggregates; + } else { + // No records matched the conditions + outputs.success = true; + outputs.message = 'No records found matching the specified conditions. Field type: ' + fieldType; + if (skippedAggregates.length > 0) { + outputs.message += '. Skipped: ' + skippedAggregates.join('; '); + } + outputs.aggregates = aggregateResult; + outputs.skipped_aggregates = skippedAggregates; + } + + } catch (error) { + gs.error('GlideAggregate Execution Error: ' + error); + outputs.success = false; + outputs.error = 'Error during aggregation: ' + error.toString(); + } +})(inputs, outputs); + + 71aa7f6647032200b4fad7527c9a719b + + + sys_hub_step_instance + 676249c9477cba10ca05a464116d4340 + 400 + sys_variable_value + admin + 2025-10-23 07:12:24 + ff6249c9477cba10ca05a464116d4355 + 0 + admin + 2025-10-23 07:12:24 + 35aa573fd7802200bdbaee5b5e610375 + f5e56d79b3101300176b051a16a8dce4 + + + + aggregate_type + 676249c9477cba10ca05a464116d4340 + admin + 2025-10-23 07:49:45 + 0ffa4dc947bcba10ca05a464116d43b5 + 0 + admin + 2025-10-23 07:49:45 + var__m_sys_hub_step_ext_input_676249c9477cba10ca05a464116d4340
+ {{action.aggregate_type}} +
+ + application + 676249c9477cba10ca05a464116d4340 + admin + 2025-10-23 07:12:24 + f76249c9477cba10ca05a464116d4355 + 0 + admin + 2025-10-23 07:12:24 + var__m_sys_flow_step_definition_input_106afb6647032200b4fad7527c9a71e7
+ +
+ + conditions + 676249c9477cba10ca05a464116d4340 + admin + 2025-10-23 07:25:37 + 5575094147bcba10ca05a464116d4351 + 0 + admin + 2025-10-23 07:25:37 + var__m_sys_hub_step_ext_input_676249c9477cba10ca05a464116d4340
+ {{action.conditions}} +
+ + field + 676249c9477cba10ca05a464116d4340 + admin + 2025-10-23 07:25:37 + 1175094147bcba10ca05a464116d4351 + 0 + admin + 2025-10-23 07:25:37 + var__m_sys_hub_step_ext_input_676249c9477cba10ca05a464116d4340
+ {{action.field}} +
+ + script + 676249c9477cba10ca05a464116d4340 + admin + 2025-10-23 07:12:24 + 3f6249c9477cba10ca05a464116d4355 + 0 + admin + 2025-10-23 07:12:24 + var__m_sys_flow_step_definition_input_106afb6647032200b4fad7527c9a71e7
+ +
+ + table_name + 676249c9477cba10ca05a464116d4340 + admin + 2025-10-23 07:25:37 + 9975094147bcba10ca05a464116d4351 + 0 + admin + 2025-10-23 07:25:37 + var__m_sys_hub_step_ext_input_676249c9477cba10ca05a464116d4340
+ {{action.table}} +
+ + + + + + true + false + false + element_mapping_provider=com.glide.flow_design.action.data.FlowDesignVariableMapper,uiType=table_name,uiTypeLabel=Table Name + false + + + + + + + + + + + + + false + false + + + + table_name + false + + + + false + + + table_name + + + true + false + false + element_mapping_provider=com.glide.flow_design.action.data.FlowDesignVariableMapper,uiType=string,uiTypeLabel=String + false + + + + + + + + + + + + + false + false + + + + field + false + + + + false + + + string + + + true + false + false + element_mapping_provider=com.glide.flow_design.action.data.FlowDesignVariableMapper,uiType=conditions,uiTypeLabel=Conditions + false + + + + + + + + + + + + + false + false + + + + conditions + false + + + + false + + + conditions + + + true + false + false + element_mapping_provider=com.glide.flow_design.action.data.FlowDesignVariableMapper,uiType=choice,uiTypeLabel=Choice + false + + 1 + + + + + + + + + + + false + false + + + + aggregate_type + false + + + + false + + + choice + + + + true + false + false + element_mapping_provider=com.glide.flow_design.action.data.FlowDesignVariableMapper,uiType=string,uiTypeLabel=String,uiUniqueId=5a1548bc-bca9-412a-bffe-5e75e1da5c42 + false + + + + + + + + + + + + + false + false + + + + error + false + + + + false + + + string + + false + 8000 + 676249c9477cba10ca05a464116d4340 + 676249c9477cba10ca05a464116d4340 + sys_hub_step_instance + var__m_sys_hub_step_ext_output_676249c9477cba10ca05a464116d4340 + + 2 + false + false + + + + false + + + + + + false + false + sys_hub_step_ext_output + admin + 2025-10-23 07:49:45 + 32fa4dc947bcba10ca05a464116d43a0 + 0 + + + + b812ceb69337a210633378917cba10bc + + admin + 2025-10-23 07:49:45 + false + false + false + false + false + simple + false + script + + + false + + + true + false + false + element_mapping_provider=com.glide.flow_design.action.data.FlowDesignVariableMapper,uiType=boolean,uiTypeLabel=True/False,uiUniqueId=db2cbe69-41cc-4244-9cf5-4430d7cc4a61 + false + + + + + + + + + + + + + false + false + + + + success + false + + + + false + + + boolean + + false + 40 + 676249c9477cba10ca05a464116d4340 + 676249c9477cba10ca05a464116d4340 + sys_hub_step_instance + var__m_sys_hub_step_ext_output_676249c9477cba10ca05a464116d4340 + + 1 + false + false + + + + false + + + + + + false + false + sys_hub_step_ext_output + admin + 2025-10-23 07:49:45 + 3afa4dc947bcba10ca05a464116d438c + 0 + + + + b812ceb69337a210633378917cba10bc + + admin + 2025-10-23 07:49:45 + false + false + false + false + false + simple + false + script + + + false + + + true + false + false + element_mapping_provider=com.glide.flow_design.action.data.FlowDesignVariableMapper,uiType=string,uiTypeLabel=String,uiUniqueId=b4f4a65e-162f-48c4-9128-dd746a97c3d5 + false + + + + + + + + + + + + + false + false + + + + message + false + + + + false + + + string + + false + 8000 + 676249c9477cba10ca05a464116d4340 + 676249c9477cba10ca05a464116d4340 + sys_hub_step_instance + var__m_sys_hub_step_ext_output_676249c9477cba10ca05a464116d4340 + + 4 + false + false + + + + false + + + + + + false + false + sys_hub_step_ext_output + admin + 2025-10-23 07:51:52 + b97bcd0d47bcba10ca05a464116d43ac + 0 + + + + b812ceb69337a210633378917cba10bc + + admin + 2025-10-23 07:51:52 + false + false + false + false + false + simple + false + script + + + false + + + true + false + false + element_mapping_provider=com.glide.flow_design.action.data.FlowDesignVariableMapper,uiType=json,uiTypeLabel=JSON,uiUniqueId=7209ca22-5861-41e0-af52-b6df525b3284 + false + + + + + + + + + + + + + false + false + + + + aggregates + false + + + + false + + + json + + false + 4000 + 676249c9477cba10ca05a464116d4340 + 676249c9477cba10ca05a464116d4340 + sys_hub_step_instance + var__m_sys_hub_step_ext_output_676249c9477cba10ca05a464116d4340 + + 3 + false + false + + + + false + + + + + + false + false + sys_hub_step_ext_output + admin + 2025-10-23 07:54:35 + e11c858d47bcba10ca05a464116d435b + 0 + + + + b812ceb69337a210633378917cba10bc + + admin + 2025-10-23 07:54:35 + false + false + false + false + false + simple + false + script + + + false + + + + aggregates + + + + en + var__m_sys_hub_step_ext_output_676249c9477cba10ca05a464116d4340 + + sys_documentation + admin + 2025-10-23 07:54:35 + 2d1c858d47bcba10ca05a464116d436b + 0 + + b812ceb69337a210633378917cba10bc + + b812ceb69337a210633378917cba10bc + + admin + 2025-10-23 07:54:35 + + + + + error + + + + en + var__m_sys_hub_step_ext_output_676249c9477cba10ca05a464116d4340 + + sys_documentation + admin + 2025-10-23 07:49:45 + 32fa4dc947bcba10ca05a464116d43a4 + 0 + + b812ceb69337a210633378917cba10bc + + b812ceb69337a210633378917cba10bc + + admin + 2025-10-23 07:49:45 + + + + + message + + + + en + var__m_sys_hub_step_ext_output_676249c9477cba10ca05a464116d4340 + + sys_documentation + admin + 2025-10-23 07:51:52 + 757bcd0d47bcba10ca05a464116d43bd + 0 + + b812ceb69337a210633378917cba10bc + + b812ceb69337a210633378917cba10bc + + admin + 2025-10-23 07:51:52 + + + + + success + + + + en + var__m_sys_hub_step_ext_output_676249c9477cba10ca05a464116d4340 + + sys_documentation + admin + 2025-10-23 07:49:45 + bafa4dc947bcba10ca05a464116d439e + 0 + + b812ceb69337a210633378917cba10bc + + b812ceb69337a210633378917cba10bc + + admin + 2025-10-23 07:49:45 + + + + + + true + false + false + element_mapping_provider=com.glide.flow_design.action.data.FlowDesignVariableMapper,uiType=choice,uiTypeLabel=Choice,uiUniqueId=e4b7df3a-04ed-4067-a1af-c976821ca762 + false + + 3 + + + + + + ALL + + + + + false + false + + + + aggregate_type + false + + + + false + + + choice + + true + 32 + 32a1c1c5477cba10ca05a464116d43da + 32a1c1c5477cba10ca05a464116d43da + sys_hub_action_type_definition + var__m_sys_hub_action_input_32a1c1c5477cba10ca05a464116d43da + + 4 + false + false + + + + false + + + + + + false + false + sys_hub_action_input + admin + 2025-10-23 07:25:36 + 1575094147bcba10ca05a464116d431a + 19 + + + + b812ceb69337a210633378917cba10bc + + admin + 2025-10-23 09:06:22 + false + false + false + false + false + simple + false + script + + + false + + + + true + false + false + element_mapping_provider=com.glide.flow_design.action.data.FlowDesignVariableMapper,uiType=conditions,uiTypeLabel=Conditions,uiUniqueId=29147458-ff23-4158-a526-e72ec2d07084 + false + + + + + + + + + + + inputs.table + inputs.table + false + false + + + + conditions + false + + + + false + + + conditions + + true + 4000 + 32a1c1c5477cba10ca05a464116d43da + 32a1c1c5477cba10ca05a464116d43da + sys_hub_action_type_definition + var__m_sys_hub_action_input_32a1c1c5477cba10ca05a464116d43da + + 2 + false + false + + + + false + + + + + + false + false + sys_hub_action_input + admin + 2025-10-23 07:09:57 + 3bd18589477cba10ca05a464116d436d + 12 + + + + b812ceb69337a210633378917cba10bc + + admin + 2025-10-23 09:06:22 + false + false + false + true + false + simple + false + script + + + false + + + + true + false + false + element_mapping_provider=com.glide.flow_design.action.data.FlowDesignVariableMapper,uiType=string,uiTypeLabel=String,uiUniqueId=278ea3e0-e158-419c-bdeb-9518a9fe5391 + false + + + + + + + + + + + + + false + false + + + + field + false + + + + false + + + string + + true + 8000 + 32a1c1c5477cba10ca05a464116d43da + 32a1c1c5477cba10ca05a464116d43da + sys_hub_action_type_definition + var__m_sys_hub_action_input_32a1c1c5477cba10ca05a464116d43da + + 3 + false + false + + + + false + + + + + + false + false + sys_hub_action_input + admin + 2025-10-23 07:25:36 + 5d75094147bcba10ca05a464116d4313 + 0 + + + + b812ceb69337a210633378917cba10bc + + admin + 2025-10-23 07:25:36 + false + false + false + false + false + simple + false + script + + + false + + + + true + false + false + element_mapping_provider=com.glide.flow_design.action.data.FlowDesignVariableMapper,uiType=table_name,uiTypeLabel=Table Name,uiUniqueId=7077a494-79b4-483b-b05f-036a62305122 + false + + + + + + + + + + + + + false + false + + + + table + false + + + + false + + + table_name + + true + 80 + 32a1c1c5477cba10ca05a464116d43da + 32a1c1c5477cba10ca05a464116d43da + sys_hub_action_type_definition + var__m_sys_hub_action_input_32a1c1c5477cba10ca05a464116d43da + + 1 + false + false + + + + false + + + + + + false + false + sys_hub_action_input + admin + 2025-10-23 07:09:57 + fbd1c189477cba10ca05a464116d43b3 + 0 + + + + b812ceb69337a210633378917cba10bc + + admin + 2025-10-23 07:09:57 + false + false + false + false + false + simple + false + script + + + false + + + + + + + true + false + false + co_type_name=FD43fa4dc9ebbcba1022198b286d6ad8bb,element_mapping_provider=com.glide.flow_design.action.data.FlowDesignVariableMapper,sourceId=b9c2c56e-4f59-44aa-b717-00cb3a915d34,sourceType=step,sourceUiUniqueId=7209ca22-5861-41e0-af52-b6df525b3284,uiType=object,uiTypeLabel=Object,uiUniqueId=665e9f16-0e14-485e-b3c3-a9114ee4fd41 + false + + + + + + + + + + + + + false + false + + + + aggregates + + false + + + + false + + + + string + + false + 65000 + 32a1c1c5477cba10ca05a464116d43da + 32a1c1c5477cba10ca05a464116d43da + sys_hub_action_type_definition + var__m_sys_hub_action_output_32a1c1c5477cba10ca05a464116d43da + + 5 + false + false + + + + false + + + + + + false + false + sys_hub_action_output + admin + 2025-10-23 07:49:46 + 0ffa4dc947bcba10ca05a464116d43ee + 1 + + + + b812ceb69337a210633378917cba10bc + + admin + 2025-10-23 07:50:08 + false + false + false + false + false + simple + false + script + + + false + + + + + true + false + false + element_mapping_provider=com.glide.flow_design.action.data.FlowDesignVariableMapper,pwd2droppable=true,uiType=string,uiTypeLabel=String,uiUniqueId=bec4ea0a-6563-4a03-be3b-cd162901e66f + false + + + + + + + + + + + + + false + false + + + + message + + false + + + + false + + + + string + + false + 8000 + 32a1c1c5477cba10ca05a464116d43da + 32a1c1c5477cba10ca05a464116d43da + sys_hub_action_type_definition + var__m_sys_hub_action_output_32a1c1c5477cba10ca05a464116d43da + + 6 + false + false + + + + false + + + + + + false + false + sys_hub_action_output + admin + 2025-10-23 07:51:52 + 4a7bcd0d47bcba10ca05a464116d43dd + 0 + + + + b812ceb69337a210633378917cba10bc + + admin + 2025-10-23 07:51:52 + false + false + false + false + false + simple + false + script + + + false + + + + + true + false + false + action_error_output=true,co_type_name=FDACTIONSTATUS,element_mapping_provider=com.glide.flow_design.action.data.FlowDesignVariableMapper,uiType=object,uiTypeLabel=Object,uiUniqueId=fde46073-a562-40a1-b0d3-402e93206bbf + false + + + + + + + + + + + + + false + false + + + + __action_status__ + + false + + + + false + + + + string + + false + 65000 + 32a1c1c5477cba10ca05a464116d43da + 32a1c1c5477cba10ca05a464116d43da + sys_hub_action_type_definition + var__m_sys_hub_action_output_32a1c1c5477cba10ca05a464116d43da + + 2 + false + false + + + + false + + + + + + false + false + sys_hub_action_output + admin + 2025-10-23 07:09:57 + 73d18589477cba10ca05a464116d439d + 1 + + + + b812ceb69337a210633378917cba10bc + + admin + 2025-10-23 07:49:45 + false + false + false + false + false + simple + false + script + + + false + + + + + true + false + false + element_mapping_provider=com.glide.flow_design.action.data.FlowDesignVariableMapper,uiType=boolean,uiTypeLabel=True/False,uiUniqueId=380103db-5413-4189-8bf7-47160aeff7b8 + false + + + + + + + + + + + + + false + false + + + + success + + false + + + + false + + + + boolean + + false + 40 + 32a1c1c5477cba10ca05a464116d43da + 32a1c1c5477cba10ca05a464116d43da + sys_hub_action_type_definition + var__m_sys_hub_action_output_32a1c1c5477cba10ca05a464116d43da + + 1 + false + false + + + + false + + + + + + false + false + sys_hub_action_output + admin + 2025-10-23 07:49:45 + 87fa4dc947bcba10ca05a464116d43bc + 0 + + + + b812ceb69337a210633378917cba10bc + + admin + 2025-10-23 07:49:45 + false + false + false + false + false + simple + false + script + + + false + + + + + true + false + false + element_mapping_provider=com.glide.flow_design.action.data.FlowDesignVariableMapper,pwd2droppable=true,uiType=string,uiTypeLabel=String,uiUniqueId=0bde9b86-6790-4d9f-b95e-de8d8bfb29fb + false + + + + + + + + + + + + + false + false + + + + error + + false + + + + false + + + + string + + false + 8000 + 32a1c1c5477cba10ca05a464116d43da + 32a1c1c5477cba10ca05a464116d43da + sys_hub_action_type_definition + var__m_sys_hub_action_output_32a1c1c5477cba10ca05a464116d43da + + 3 + false + false + + + + false + + + + + + false + false + sys_hub_action_output + admin + 2025-10-23 07:49:45 + c3fa4dc947bcba10ca05a464116d43c8 + 1 + + + + b812ceb69337a210633378917cba10bc + + admin + 2025-10-23 07:50:08 + false + false + false + false + false + simple + false + script + + + false + + + + + true + false + false + action_error_output=true,element_mapping_provider=com.glide.flow_design.action.data.FlowDesignVariableMapper,uiType=boolean,uiTypeLabel=True/False,uiUniqueId=4f5bc7c1-ef3b-4b5e-9264-492393f8a9e4,visible_in_ui=false + false + + + + + + + + true + + + + + false + false + + + + __dont_treat_as_error__ + + false + + + + false + + + + boolean + + false + 40 + 32a1c1c5477cba10ca05a464116d43da + 32a1c1c5477cba10ca05a464116d43da + sys_hub_action_type_definition + var__m_sys_hub_action_output_32a1c1c5477cba10ca05a464116d43da + + 4 + false + false + + + + false + + + + + + false + false + sys_hub_action_output + admin + 2025-10-23 07:09:57 + f3d18589477cba10ca05a464116d43d7 + 25 + + + + b812ceb69337a210633378917cba10bc + + admin + 2025-10-23 09:06:23 + false + false + false + false + false + simple + false + script + + + false + + + + + + + 32a1c1c5477cba10ca05a464116d43da + admin + 2025-10-23 07:09:57 + 7bd18589477cba10ca05a464116d43eb + 0 + admin + 2025-10-23 07:09:57 + + + + 7bd18589477cba10ca05a464116d43eb + {{step[b9c2c56e-4f59-44aa-b717-00cb3a915d34].error}}ISNOTEMPTY + false + + 1 + {"version":"1.0","serializationFormat":"JSON","complexObjectSchema":{"FlowDesigner:FDACTIONSTATUS":{"code":"Integer","code.$field_facets":{"SimpleMapFacet":"{\"uiTypeLabel\":\"Integer\",\"read_only\":\"false\",\"hint\":\"\",\"uiType\":\"integer\",\"default_value\":\"\",\"label\":\"Code\",\"action_error_output\":\"true\",\"mandatory\":\"false\",\"order\":\"1\",\"max_length\":\"40\"}"},"message":"String","message.$field_facets":{"SimpleMapFacet":"{\"uiTypeLabel\":\"String\",\"read_only\":\"false\",\"hint\":\"\",\"uiType\":\"string\",\"mapped\":\"{\\\"message\\\":\\\"{{step[b9c2c56e-4f59-44aa-b717-00cb3a915d34].error}}\\\"}\",\"default_value\":\"\",\"label\":\"Message\",\"action_error_output\":\"true\",\"mandatory\":\"false\",\"order\":\"2\",\"max_length\":\"4000\"}"}},"FlowDesigner:FDACTIONSTATUS.$type_facets":{"SimpleMapFacet":"{\"default_value\":\"\",\"label\":\"Action Status\",\"action_error_output\":\"true\",\"mandatory\":\"false\",\"uiUniqueId\":\"4adfb7bc-9d67-498d-88d0-8d6c3d584fed\",\"uiTypeLabel\":\"Object\",\"co_type_name\":\"FDACTIONSTATUS\",\"element_mapping_provider\":\"com.glide.flow_design.action.data.FlowDesignVariableMapper\",\"read_only\":\"false\",\"hint\":null,\"uiType\":\"object\",\"order\":\"1\",\"max_length\":\"65000\"}"}},"complexObject":{"code":{"$cv":{"$c":"java.lang.String","$v":"1"}},"message":{"$cv":{"$c":"java.lang.String","$v":""}}}} + admin + 2025-10-23 08:53:06 + c379ddc54730fa10ca05a464116d43f2 + 0 + admin + 2025-10-23 08:53:06 + + + aggregate_type + + + + en + var__m_sys_hub_action_input_32a1c1c5477cba10ca05a464116d43da + + sys_documentation + admin + 2025-10-23 07:25:36 + 1d75094147bcba10ca05a464116d4328 + 1 + + b812ceb69337a210633378917cba10bc + + b812ceb69337a210633378917cba10bc + + admin + 2025-10-23 07:49:45 + + + + + conditions + + + + en + var__m_sys_hub_action_input_32a1c1c5477cba10ca05a464116d43da + + sys_documentation + admin + 2025-10-23 07:09:57 + 33d18589477cba10ca05a464116d437f + 0 + + b812ceb69337a210633378917cba10bc + + b812ceb69337a210633378917cba10bc + + admin + 2025-10-23 07:09:57 + + + + + field + + + + en + var__m_sys_hub_action_input_32a1c1c5477cba10ca05a464116d43da + + sys_documentation + admin + 2025-10-23 07:25:36 + 9d75094147bcba10ca05a464116d4318 + 0 + + b812ceb69337a210633378917cba10bc + + b812ceb69337a210633378917cba10bc + + admin + 2025-10-23 07:25:36 + + + + + table + + + + en + var__m_sys_hub_action_input_32a1c1c5477cba10ca05a464116d43da + + sys_documentation + admin + 2025-10-23 07:09:57 + b3d18589477cba10ca05a464116d436c + 0 + + b812ceb69337a210633378917cba10bc + + b812ceb69337a210633378917cba10bc + + admin + 2025-10-23 07:09:57 + + + + + + + + aggregate_type + + false + + en + var__m_sys_hub_action_input_32a1c1c5477cba10ca05a464116d43da + 8 + + admin + 2025-10-23 07:25:36 + global + / + 1575094147bcba10ca05a464116d4324 + 1 + admin + 2025-10-23 07:49:45 + ALL + + + + aggregate_type + + false + + en + var__m_sys_hub_action_input_32a1c1c5477cba10ca05a464116d43da + 4 + + admin + 2025-10-23 07:25:36 + global + / + 1975094147bcba10ca05a464116d4321 + 1 + admin + 2025-10-23 07:49:44 + MAX + + + + aggregate_type + + false + + en + var__m_sys_hub_action_input_32a1c1c5477cba10ca05a464116d43da + 0 + + admin + 2025-10-23 07:25:36 + global + / + 1d75094147bcba10ca05a464116d431e + 1 + admin + 2025-10-23 07:49:44 + COUNT + + + + aggregate_type + + false + + en + var__m_sys_hub_action_input_32a1c1c5477cba10ca05a464116d43da + 7 + + admin + 2025-10-23 07:25:36 + global + / + 5975094147bcba10ca05a464116d4323 + 1 + admin + 2025-10-23 07:49:45 + GROUP_CONCAT_DISTINCT + + + + aggregate_type + + false + + en + var__m_sys_hub_action_input_32a1c1c5477cba10ca05a464116d43da + 3 + + admin + 2025-10-23 07:25:36 + global + / + 5d75094147bcba10ca05a464116d4320 + 1 + admin + 2025-10-23 07:49:44 + MIN + + + + aggregate_type + + false + + en + var__m_sys_hub_action_input_32a1c1c5477cba10ca05a464116d43da + 2 + + admin + 2025-10-23 07:25:36 + global + / + 9175094147bcba10ca05a464116d4320 + 1 + admin + 2025-10-23 07:49:44 + AVG + + + + aggregate_type + + false + + en + var__m_sys_hub_action_input_32a1c1c5477cba10ca05a464116d43da + 6 + + admin + 2025-10-23 07:25:36 + global + / + 9d75094147bcba10ca05a464116d4322 + 1 + admin + 2025-10-23 07:49:44 + GROUP_CONCAT + + + + aggregate_type + + false + + en + var__m_sys_hub_action_input_32a1c1c5477cba10ca05a464116d43da + 5 + + admin + 2025-10-23 07:25:36 + global + / + d175094147bcba10ca05a464116d4322 + 1 + admin + 2025-10-23 07:49:44 + STDDEV + + + + aggregate_type + + false + + en + var__m_sys_hub_action_input_32a1c1c5477cba10ca05a464116d43da + 1 + + admin + 2025-10-23 07:25:36 + global + / + d575094147bcba10ca05a464116d431f + 1 + admin + 2025-10-23 07:49:44 + SUM + + + + message + + + + en + var__m_sys_hub_action_output_32a1c1c5477cba10ca05a464116d43da + + sys_documentation + admin + 2025-10-23 07:51:52 + 0e7bcd0d47bcba10ca05a464116d43e2 + 0 + + b812ceb69337a210633378917cba10bc + + b812ceb69337a210633378917cba10bc + + admin + 2025-10-23 07:51:52 + + + + + __action_status__ + + + + en + var__m_sys_hub_action_output_32a1c1c5477cba10ca05a464116d43da + + sys_documentation + admin + 2025-10-23 07:09:57 + 7fd18589477cba10ca05a464116d43d5 + 0 + + b812ceb69337a210633378917cba10bc + + b812ceb69337a210633378917cba10bc + + admin + 2025-10-23 07:09:57 + + + + + error + + + + en + var__m_sys_hub_action_output_32a1c1c5477cba10ca05a464116d43da + + sys_documentation + admin + 2025-10-23 07:49:45 + 83fa4dc947bcba10ca05a464116d43e6 + 0 + + b812ceb69337a210633378917cba10bc + + b812ceb69337a210633378917cba10bc + + admin + 2025-10-23 07:49:45 + + + + + success + + + + en + var__m_sys_hub_action_output_32a1c1c5477cba10ca05a464116d43da + + sys_documentation + admin + 2025-10-23 07:49:45 + 87fa4dc947bcba10ca05a464116d43c2 + 0 + + b812ceb69337a210633378917cba10bc + + b812ceb69337a210633378917cba10bc + + admin + 2025-10-23 07:49:45 + + + + + aggregates + + + + en + var__m_sys_hub_action_output_32a1c1c5477cba10ca05a464116d43da + + sys_documentation + admin + 2025-10-23 07:49:46 + 87fa8dc947bcba10ca05a464116d4300 + 0 + + b812ceb69337a210633378917cba10bc + + b812ceb69337a210633378917cba10bc + + admin + 2025-10-23 07:49:46 + + + + + __dont_treat_as_error__ + + + + en + var__m_sys_hub_action_output_32a1c1c5477cba10ca05a464116d43da + + sys_documentation + admin + 2025-10-23 07:09:57 + f3d18589477cba10ca05a464116d43e1 + 0 + + b812ceb69337a210633378917cba10bc + + b812ceb69337a210633378917cba10bc + + admin + 2025-10-23 07:09:57 + + + + + + + 32a1c1c5477cba10ca05a464116d43da + {"type":"PlanProxy","persistor":{"@class":".ChunkingPlanPersistor","table":"sys_hub_action_plan","id":"c68c1dcd4730fa10ca05a464116d43e8","name":"plan","plan_signature":null}} + fd8c1dcd4730fa10ca05a464116d4377 + admin + 2025-10-23 09:06:26 + global + / + c68c1dcd4730fa10ca05a464116d43e8 + 0 + + + admin + 2025-10-23 09:06:26 + + + public + + + + + {labelCacheCleanUpExecuted=true} + 28100 + false + + + + Execute statistical calculations on any ServiceNow table by providing a table name, query conditions, and field to aggregate. The action returns comprehensive metrics including count, sum, average, minimum, maximum, and standard deviation in a single execution. Eliminates the need for custom GlideAggregate scripts, making advanced data analytics accessible to administrators and low-code developers. + + get_glideaggregatemultiple + [{"name":"{{action.table}}","label":"action➛Table","type":"action","ref":"","reference_display":"","base_type":"table_name","parent_table_name":"","column_name":"","choices":null,"attributes":{}},{"name":"{{action.conditions}}","label":"action➛Conditions","type":"action","ref":"","reference_display":"","base_type":"conditions","parent_table_name":"","column_name":"","choices":null,"attributes":{}},{"name":"{{action.variable1}}","label":"action➛Field","type":"action","ref":"","reference_display":"","base_type":"string","parent_table_name":"","column_name":"","choices":null,"attributes":{"uiTypeLabel":"String","element_mapping_provider":"com.glide.flow_design.action.data.FlowDesignVariableMapper","uiType":"string","uiUniqueId":"ca036a30-09ea-4457-808d-87fd93c4e891"}},{"name":"{{action.field}}","label":"action➛Field","type":"action","ref":"","reference_display":"","base_type":"string","parent_table_name":"","column_name":"","choices":null,"attributes":{}},{"name":"{{action.variable}}","label":"action➛variable","type":"action","ref":"","reference_display":"","base_type":"string","parent_table_name":"","column_name":"","choices":null,"attributes":{}},{"name":"{{action.aggregate_by}}","label":"action➛Aggregate by","type":"action","ref":"","reference_display":"","base_type":"string","parent_table_name":"","column_name":"","choices":null,"attributes":{}},{"name":"{{action.aggregate_type}}","label":"action➛Aggregate Type","type":"action","ref":"","reference_display":"","base_type":"choice","parent_table_name":"","column_name":"","choices":[{"label":"COUNT","value":"COUNT","order":0.0},{"label":"SUM","value":"SUM","order":1.0},{"label":"AVG","value":"AVG","order":2.0},{"label":"MIN","value":"MIN","order":3.0},{"label":"MAX","value":"MAX","order":4.0},{"label":"STDDEV","value":"STDDEV","order":5.0},{"label":"GROUP_CONCAT","value":"GROUP_CONCAT","order":6.0},{"label":"GROUP_CONCAT_DISTINCT","value":"GROUP_CONCAT_DISTINCT","order":7.0},{"label":"All Aggregates","value":"ALL","order":8.0}],"attributes":{"uiTypeLabel":"Choice","element_mapping_provider":"com.glide.flow_design.action.data.FlowDesignVariableMapper","uiType":"choice","uiUniqueId":"e4b7df3a-04ed-4067-a1af-c976821ca762"}},{"name":"{{step[b9c2c56e-4f59-44aa-b717-00cb3a915d34].success}}","label":"step➛Aggregation Script➛Success","type":"step","ref":"","reference_display":"","base_type":"boolean","parent_table_name":"","column_name":"","choices":null,"attributes":{"uiTypeLabel":"True/False","element_mapping_provider":"com.glide.flow_design.action.data.FlowDesignVariableMapper","uiType":"boolean","uiUniqueId":"db2cbe69-41cc-4244-9cf5-4430d7cc4a61"}},{"name":"{{step[b9c2c56e-4f59-44aa-b717-00cb3a915d34].error}}","label":"step➛Aggregation Script➛Error","type":"step","ref":"","reference_display":"","base_type":"string","parent_table_name":"","column_name":"","choices":null,"attributes":{"uiTypeLabel":"String","element_mapping_provider":"com.glide.flow_design.action.data.FlowDesignVariableMapper","uiType":"string","uiUniqueId":"5a1548bc-bca9-412a-bffe-5e75e1da5c42"}},{"name":"{{step[b9c2c56e-4f59-44aa-b717-00cb3a915d34].aggregates}}","label":"step➛Aggregation Script➛Aggregates","type":"step","ref":"","reference_display":"","base_type":"json","parent_table_name":"","column_name":"","choices":null,"attributes":{"sourceId":"","uiTypeLabel":"Object","co_type_name":"","element_mapping_provider":"com.glide.flow_design.action.data.FlowDesignVariableMapper","sourceUiUniqueId":"","sourceType":"","uiType":"object","uiUniqueId":"7209ca22-5861-41e0-af52-b6df525b3284"}},{"name":"{{step[b9c2c56e-4f59-44aa-b717-00cb3a915d34].message}}","label":"step➛Aggregation Script➛Message","type":"step","ref":"","reference_display":"","base_type":"string","parent_table_name":"","column_name":"","choices":null,"attributes":{"sourceId":"","sourceUiUniqueId":"","sourceType":""}}] + true + Get GlideAggregate(Multiple) + + + + 32a1c1c5477cba10ca05a464116d43da + sys_hub_action_type_snapshot + admin + 2025-10-23 09:06:24 + global + / + a18cd9cd4730fa10ca05a464116d436d + 0 + + + + + b812ceb69337a210633378917cba10bc + + admin + 2025-10-23 09:06:24 + false + + + + + + sys_hub_action_type_snapshot + a18cd9cd4730fa10ca05a464116d436d + 1 + sys_variable_value + admin + 2025-10-23 09:06:25 + 3d8c1dcd4730fa10ca05a464116d4372 + 0 + admin + 2025-10-23 09:06:25 + 0 + bd8c1dcd4730fa10ca05a464116d4330 + + + sys_hub_action_type_snapshot + a18cd9cd4730fa10ca05a464116d436d + 2 + sys_variable_value + admin + 2025-10-23 09:06:25 + 718c1dcd4730fa10ca05a464116d4373 + 0 + admin + 2025-10-23 09:06:25 + {"version":"1.0","serializationFormat":"JSON","complexObjectSchema":{"FlowDesigner:FDACTIONSTATUS":{"code":"Integer","code.$field_facets":{"SimpleMapFacet":"{\"uiTypeLabel\":\"Integer\",\"read_only\":\"false\",\"hint\":\"\",\"uiType\":\"integer\",\"default_value\":\"\",\"label\":\"Code\",\"action_error_output\":\"true\",\"mandatory\":\"false\",\"order\":\"1\",\"max_length\":\"40\"}"},"message":"String","message.$field_facets":{"SimpleMapFacet":"{\"uiTypeLabel\":\"String\",\"read_only\":\"false\",\"hint\":\"\",\"uiType\":\"string\",\"mapped\":\"{}\",\"default_value\":\"\",\"label\":\"Message\",\"action_error_output\":\"true\",\"mandatory\":\"false\",\"order\":\"2\",\"max_length\":\"4000\"}"}},"FlowDesigner:FDACTIONSTATUS.$type_facets":{"SimpleMapFacet":"{\"default_value\":\"\",\"label\":\"Action Status\",\"action_error_output\":\"true\",\"mandatory\":\"false\",\"uiUniqueId\":\"4adfb7bc-9d67-498d-88d0-8d6c3d584fed\",\"uiTypeLabel\":\"Object\",\"co_type_name\":\"FDACTIONSTATUS\",\"element_mapping_provider\":\"com.glide.flow_design.action.data.FlowDesignVariableMapper\",\"read_only\":\"false\",\"hint\":null,\"uiType\":\"object\",\"order\":\"1\",\"max_length\":\"65000\"}"}},"complexObject":{"code":{"$cv":{"$c":"java.lang.String","$v":""}},"message":{"$cv":{"$c":"java.lang.String","$v":""}}}} + 358c1dcd4730fa10ca05a464116d4338 + + + sys_hub_action_type_snapshot + a18cd9cd4730fa10ca05a464116d436d + 4 + sys_variable_value + admin + 2025-10-23 09:06:25 + f58c1dcd4730fa10ca05a464116d4372 + 0 + admin + 2025-10-23 09:06:25 + 0 + b98c1dcd4730fa10ca05a464116d4345 + + + + aggregates + a18cd9cd4730fa10ca05a464116d436d + admin + 2025-10-23 09:06:25 + 758c1dcd4730fa10ca05a464116d4371 + 0 + admin + 2025-10-23 09:06:25 + var__m_sys_hub_action_output_a18cd9cd4730fa10ca05a464116d436d
+ {{step[b9c2c56e-4f59-44aa-b717-00cb3a915d34].aggregates}} +
+ + error + a18cd9cd4730fa10ca05a464116d436d + admin + 2025-10-23 09:06:25 + b98c1dcd4730fa10ca05a464116d4371 + 0 + admin + 2025-10-23 09:06:25 + var__m_sys_hub_action_output_a18cd9cd4730fa10ca05a464116d436d
+ {{step[b9c2c56e-4f59-44aa-b717-00cb3a915d34].error}} +
+ + message + a18cd9cd4730fa10ca05a464116d436d + admin + 2025-10-23 09:06:25 + fd8c1dcd4730fa10ca05a464116d4371 + 0 + admin + 2025-10-23 09:06:25 + var__m_sys_hub_action_output_a18cd9cd4730fa10ca05a464116d436d
+ {{step[b9c2c56e-4f59-44aa-b717-00cb3a915d34].message}} +
+ + success + a18cd9cd4730fa10ca05a464116d436d + admin + 2025-10-23 09:06:25 + 318c1dcd4730fa10ca05a464116d4371 + 0 + admin + 2025-10-23 09:06:25 + var__m_sys_hub_action_output_a18cd9cd4730fa10ca05a464116d436d
+ {{step[b9c2c56e-4f59-44aa-b717-00cb3a915d34].success}} +
+ + __action_status__ + a18cd9cd4730fa10ca05a464116d436d + admin + 2025-10-23 09:06:25 + 358c1dcd4730fa10ca05a464116d4372 + 0 + admin + 2025-10-23 09:06:25 + var__m_sys_hub_action_output_a18cd9cd4730fa10ca05a464116d436d
+ +
+ + __dont_treat_as_error__ + a18cd9cd4730fa10ca05a464116d436d + admin + 2025-10-23 09:06:25 + f98c1dcd4730fa10ca05a464116d4370 + 0 + admin + 2025-10-23 09:06:25 + var__m_sys_hub_action_output_a18cd9cd4730fa10ca05a464116d436d
+ +
+ + + a18cd9cd4730fa10ca05a464116d436d + b9c2c56e-4f59-44aa-b717-00cb3a915d34 + 1 + + + + + + + 1 + +
+ 106afb6647032200b4fad7527c9a71e7 + admin + 2025-10-23 09:06:24 + a58cd9cd4730fa10ca05a464116d43ce + 1 + b812ceb69337a210633378917cba10bc + admin + 2025-10-23 09:06:24 + + + + sys_hub_step_instance + a58cd9cd4730fa10ca05a464116d43ce + 400 + sys_variable_value + admin + 2025-10-23 09:06:24 + b98c1dcd4730fa10ca05a464116d4327 + 0 + admin + 2025-10-23 09:06:24 + 35aa573fd7802200bdbaee5b5e610375 + f5e56d79b3101300176b051a16a8dce4 + + + sys_hub_step_instance + a58cd9cd4730fa10ca05a464116d43ce + 600 + sys_variable_value + admin + 2025-10-23 09:06:24 + fd8c1dcd4730fa10ca05a464116d4327 + 0 + admin + 2025-10-23 09:06:24 + (function execute(inputs, outputs) { + try { + // Normalize and validate required inputs + var tableName = String(inputs.table_name || '').trim(); + var conditions = String(inputs.conditions || '').trim(); + var fieldName = String(inputs.field || '').trim(); + var aggregateType = String(inputs.aggregate_type || '').trim().toUpperCase(); + + // Input validation + if (!tableName) { + outputs.success = false; + outputs.error = 'Missing required input: table_name'; + return; + } + if (!fieldName) { + outputs.success = false; + outputs.error = 'Missing required input: field'; + return; + } + if (!aggregateType) { + outputs.success = false; + outputs.error = 'Missing required input: aggregate_type'; + return; + } + + // Validate table exists + var tableValidator = new GlideRecord(tableName); + if (!tableValidator.isValid()) { + outputs.success = false; + outputs.error = 'Invalid table: ' + tableName; + return; + } + + // Validate field exists on the table + if (!tableValidator.isValidField(fieldName)) { + outputs.success = false; + outputs.error = 'Invalid field: ' + fieldName + ' on table: ' + tableName; + return; + } + + // Get field type from sys_dictionary + var fieldType = null; + var fieldInfo = new GlideRecord('sys_dictionary'); + fieldInfo.addQuery('name', tableName); + fieldInfo.addQuery('element', fieldName); + fieldInfo.setLimit(1); + fieldInfo.query(); + if (fieldInfo.next()) { + fieldType = fieldInfo.getValue('internal_type'); + } + + + + // Initialize result object with all possible aggregates + var aggregateResult = { + count: null, + sum: null, + avg: null, + max: null, + min: null, + stddev: null, + group_concat: null, + group_concat_distinct: null, + aggregate_type_requested: aggregateType + }; + + // Validate aggregate type is one of the allowed values + var allowedTypes = ['COUNT', 'SUM', 'AVG', 'MAX', 'MIN', 'STDDEV', 'GROUP_CONCAT', 'GROUP_CONCAT_DISTINCT', 'ALL']; + if (allowedTypes.indexOf(aggregateType) === -1) { + outputs.success = false; + outputs.error = 'Invalid aggregate_type: ' + aggregateType + '. Allowed values: ' + allowedTypes.join(', '); + return; + } + + // Determine which aggregates are applicable based on field type + var isNumericField = ['integer', 'decimal', 'float', 'currency', 'percent', 'price'].indexOf(fieldType) !== -1; + var skippedAggregates = []; + var applicableAggregates = []; + + // Numeric aggregates only work on numeric fields + var numericAggregates = ['SUM', 'AVG', 'STDDEV', 'MAX', 'MIN']; + var stringAggregates = ['GROUP_CONCAT', 'GROUP_CONCAT_DISTINCT', 'COUNT']; + + if (aggregateType === 'ALL') { + // For ALL, add only applicable aggregates based on field type + aggregateResult.count = 0; // COUNT always works + applicableAggregates.push('COUNT'); + + if (isNumericField) { + numericAggregates.forEach(function(agg) { + applicableAggregates.push(agg); + }); + } else { + numericAggregates.forEach(function(agg) { + skippedAggregates.push(agg + ' (not applicable for ' + fieldType + ' field)'); + }); + } + + stringAggregates.filter(function(agg) { + return agg !== 'COUNT'; + }).forEach(function(agg) { + applicableAggregates.push(agg); + }); + } else { + // Single aggregate requested + if (aggregateType === 'COUNT') { + applicableAggregates.push('COUNT'); + } else if (numericAggregates.indexOf(aggregateType) !== -1 && !isNumericField) { + skippedAggregates.push(aggregateType + ' (not applicable for ' + fieldType + ' field)'); + } else { + applicableAggregates.push(aggregateType); + } + } + + // If no applicable aggregates, return error + if (applicableAggregates.length === 0) { + outputs.success = false; + outputs.error = 'No applicable aggregates for field type: ' + fieldType + '. Requested: ' + aggregateType; + outputs.skipped_aggregates = skippedAggregates; + return; + } + + // Create GlideAggregate instance + var aggregator = new GlideAggregate(tableName); + if (conditions) { + aggregator.addEncodedQuery(conditions); + } + aggregator.setGroup(false); + + // Add only applicable aggregates + applicableAggregates.forEach(function(agg) { + aggregator.addAggregate(agg, fieldName); + }); + + // Execute the aggregate query + aggregator.query(); + + // Process results + if (aggregator.next()) { + applicableAggregates.forEach(function(agg) { + var rawValue = aggregator.getAggregate(agg, fieldName); + + switch (agg) { + case 'COUNT': + aggregateResult.count = parseInt(rawValue) || 0; + break; + case 'SUM': + aggregateResult.sum = parseFloat(rawValue) || 0; + break; + case 'AVG': + aggregateResult.avg = parseFloat(rawValue) || 0; + break; + case 'MAX': + aggregateResult.max = isNumericField ? (parseFloat(rawValue) || null) : (rawValue || null); + break; + case 'MIN': + aggregateResult.min = isNumericField ? (parseFloat(rawValue) || null) : (rawValue || null); + break; + case 'STDDEV': + aggregateResult.stddev = parseFloat(rawValue) || 0; + break; + case 'GROUP_CONCAT': + aggregateResult.group_concat = String(rawValue || ''); + break; + case 'GROUP_CONCAT_DISTINCT': + aggregateResult.group_concat_distinct = String(rawValue || ''); + break; + } + }); + + outputs.success = true; + outputs.message = 'Aggregate(s) calculated successfully. Field type: ' + fieldType; + if (skippedAggregates.length > 0) { + outputs.message += '. Skipped: ' + skippedAggregates.join('; '); + } + outputs.aggregates = aggregateResult; + outputs.skipped_aggregates = skippedAggregates; + } else { + // No records matched the conditions + outputs.success = true; + outputs.message = 'No records found matching the specified conditions. Field type: ' + fieldType; + if (skippedAggregates.length > 0) { + outputs.message += '. Skipped: ' + skippedAggregates.join('; '); + } + outputs.aggregates = aggregateResult; + outputs.skipped_aggregates = skippedAggregates; + } + + } catch (error) { + gs.error('GlideAggregate Execution Error: ' + error); + outputs.success = false; + outputs.error = 'Error during aggregation: ' + error.toString(); + } +})(inputs, outputs); + + 71aa7f6647032200b4fad7527c9a719b + + + + aggregate_type + a58cd9cd4730fa10ca05a464116d43ce + admin + 2025-10-23 09:06:24 + fd8c1dcd4730fa10ca05a464116d4329 + 0 + admin + 2025-10-23 09:06:24 + var__m_sys_hub_step_ext_input_a58cd9cd4730fa10ca05a464116d43ce
+ {{action.aggregate_type}} +
+ + application + a58cd9cd4730fa10ca05a464116d43ce + admin + 2025-10-23 09:06:24 + b18c1dcd4730fa10ca05a464116d4327 + 0 + admin + 2025-10-23 09:06:24 + var__m_sys_flow_step_definition_input_106afb6647032200b4fad7527c9a71e7
+ +
+ + conditions + a58cd9cd4730fa10ca05a464116d43ce + admin + 2025-10-23 09:06:24 + 758c1dcd4730fa10ca05a464116d4329 + 0 + admin + 2025-10-23 09:06:24 + var__m_sys_hub_step_ext_input_a58cd9cd4730fa10ca05a464116d43ce
+ {{action.conditions}} +
+ + field + a58cd9cd4730fa10ca05a464116d43ce + admin + 2025-10-23 09:06:24 + 318c1dcd4730fa10ca05a464116d4329 + 0 + admin + 2025-10-23 09:06:24 + var__m_sys_hub_step_ext_input_a58cd9cd4730fa10ca05a464116d43ce
+ {{action.field}} +
+ + script + a58cd9cd4730fa10ca05a464116d43ce + admin + 2025-10-23 09:06:24 + f58c1dcd4730fa10ca05a464116d4327 + 0 + admin + 2025-10-23 09:06:24 + var__m_sys_flow_step_definition_input_106afb6647032200b4fad7527c9a71e7
+ +
+ + table_name + a58cd9cd4730fa10ca05a464116d43ce + admin + 2025-10-23 09:06:24 + b98c1dcd4730fa10ca05a464116d4329 + 0 + admin + 2025-10-23 09:06:24 + var__m_sys_hub_step_ext_input_a58cd9cd4730fa10ca05a464116d43ce
+ {{action.table}} +
+ + + + + + true + false + false + element_mapping_provider=com.glide.flow_design.action.data.FlowDesignVariableMapper,uiType=table_name,uiTypeLabel=Table Name + false + + + + + + + + + + + + + false + false + + + + table_name + false + + + + false + + + table_name + + true + 80 + a58cd9cd4730fa10ca05a464116d43ce + a58cd9cd4730fa10ca05a464116d43ce + sys_hub_step_instance + var__m_sys_hub_step_ext_input_a58cd9cd4730fa10ca05a464116d43ce + + 0 + false + false + + + + false + + + + + + false + false + sys_hub_step_ext_input + admin + 2025-10-23 09:06:24 + 298cd9cd4730fa10ca05a464116d43e1 + 0 + + + + b812ceb69337a210633378917cba10bc + + admin + 2025-10-23 09:06:24 + false + false + false + false + false + simple + false + script + + + false + + + true + false + false + element_mapping_provider=com.glide.flow_design.action.data.FlowDesignVariableMapper,uiType=string,uiTypeLabel=String + false + + + + + + + + + + + + + false + false + + + + field + false + + + + false + + + string + + true + 8000 + a58cd9cd4730fa10ca05a464116d43ce + a58cd9cd4730fa10ca05a464116d43ce + sys_hub_step_instance + var__m_sys_hub_step_ext_input_a58cd9cd4730fa10ca05a464116d43ce + + 200 + false + false + + + + false + + + + + + false + false + sys_hub_step_ext_input + admin + 2025-10-23 09:06:24 + 398cd9cd4730fa10ca05a464116d43ed + 0 + + + + b812ceb69337a210633378917cba10bc + + admin + 2025-10-23 09:06:24 + false + false + false + false + false + simple + false + script + + + false + + + true + false + false + element_mapping_provider=com.glide.flow_design.action.data.FlowDesignVariableMapper,uiType=conditions,uiTypeLabel=Conditions + false + + + + + + + + + + + + + false + false + + + + conditions + false + + + + false + + + conditions + + true + 4000 + a58cd9cd4730fa10ca05a464116d43ce + a58cd9cd4730fa10ca05a464116d43ce + sys_hub_step_instance + var__m_sys_hub_step_ext_input_a58cd9cd4730fa10ca05a464116d43ce + + 100 + false + false + + + + false + + + + + + false + false + sys_hub_step_ext_input + admin + 2025-10-23 09:06:24 + 718cd9cd4730fa10ca05a464116d43e8 + 0 + + + + b812ceb69337a210633378917cba10bc + + admin + 2025-10-23 09:06:24 + false + false + false + false + false + simple + false + script + + + false + + + true + false + false + element_mapping_provider=com.glide.flow_design.action.data.FlowDesignVariableMapper,uiType=choice,uiTypeLabel=Choice + false + + 1 + + + + + + + + + + + false + false + + + + aggregate_type + false + + + + false + + + choice + + true + 40 + a58cd9cd4730fa10ca05a464116d43ce + a58cd9cd4730fa10ca05a464116d43ce + sys_hub_step_instance + var__m_sys_hub_step_ext_input_a58cd9cd4730fa10ca05a464116d43ce + + 300 + false + false + + + + false + + + + + + false + false + sys_hub_step_ext_input + admin + 2025-10-23 09:06:24 + fd8cd9cd4730fa10ca05a464116d43f2 + 0 + + + + b812ceb69337a210633378917cba10bc + + admin + 2025-10-23 09:06:24 + false + false + false + false + false + simple + false + script + + + false + + + + true + false + false + element_mapping_provider=com.glide.flow_design.action.data.FlowDesignVariableMapper,uiType=json,uiTypeLabel=JSON,uiUniqueId=7209ca22-5861-41e0-af52-b6df525b3284 + false + + + + + + + + + + + + + false + false + + + + aggregates + false + + + + false + + + json + + false + 4000 + a58cd9cd4730fa10ca05a464116d43ce + a58cd9cd4730fa10ca05a464116d43ce + sys_hub_step_instance + var__m_sys_hub_step_ext_output_a58cd9cd4730fa10ca05a464116d43ce + + 3 + false + false + + + + false + + + + + + false + false + sys_hub_step_ext_output + admin + 2025-10-23 09:06:24 + 318c1dcd4730fa10ca05a464116d4306 + 0 + + + + b812ceb69337a210633378917cba10bc + + admin + 2025-10-23 09:06:24 + false + false + false + false + false + simple + false + script + + + false + + + true + false + false + element_mapping_provider=com.glide.flow_design.action.data.FlowDesignVariableMapper,uiType=boolean,uiTypeLabel=True/False,uiUniqueId=db2cbe69-41cc-4244-9cf5-4430d7cc4a61 + false + + + + + + + + + + + + + false + false + + + + success + false + + + + false + + + boolean + + false + 40 + a58cd9cd4730fa10ca05a464116d43ce + a58cd9cd4730fa10ca05a464116d43ce + sys_hub_step_instance + var__m_sys_hub_step_ext_output_a58cd9cd4730fa10ca05a464116d43ce + + 1 + false + false + + + + false + + + + + + false + false + sys_hub_step_ext_output + admin + 2025-10-23 09:06:24 + 318cd9cd4730fa10ca05a464116d43fa + 0 + + + + b812ceb69337a210633378917cba10bc + + admin + 2025-10-23 09:06:24 + false + false + false + false + false + simple + false + script + + + false + + + true + false + false + element_mapping_provider=com.glide.flow_design.action.data.FlowDesignVariableMapper,uiType=string,uiTypeLabel=String,uiUniqueId=b4f4a65e-162f-48c4-9128-dd746a97c3d5 + false + + + + + + + + + + + + + false + false + + + + message + false + + + + false + + + string + + false + 8000 + a58cd9cd4730fa10ca05a464116d43ce + a58cd9cd4730fa10ca05a464116d43ce + sys_hub_step_instance + var__m_sys_hub_step_ext_output_a58cd9cd4730fa10ca05a464116d43ce + + 4 + false + false + + + + false + + + + + + false + false + sys_hub_step_ext_output + admin + 2025-10-23 09:06:24 + 798c1dcd4730fa10ca05a464116d430b + 0 + + + + b812ceb69337a210633378917cba10bc + + admin + 2025-10-23 09:06:24 + false + false + false + false + false + simple + false + script + + + false + + + true + false + false + element_mapping_provider=com.glide.flow_design.action.data.FlowDesignVariableMapper,uiType=string,uiTypeLabel=String,uiUniqueId=5a1548bc-bca9-412a-bffe-5e75e1da5c42 + false + + + + + + + + + + + + + false + false + + + + error + false + + + + false + + + string + + false + 8000 + a58cd9cd4730fa10ca05a464116d43ce + a58cd9cd4730fa10ca05a464116d43ce + sys_hub_step_instance + var__m_sys_hub_step_ext_output_a58cd9cd4730fa10ca05a464116d43ce + + 2 + false + false + + + + false + + + + + + false + false + sys_hub_step_ext_output + admin + 2025-10-23 09:06:24 + f58c1dcd4730fa10ca05a464116d4300 + 0 + + + + b812ceb69337a210633378917cba10bc + + admin + 2025-10-23 09:06:24 + false + false + false + false + false + simple + false + script + + + false + + + + error + + + + en + var__m_sys_hub_step_ext_output_a58cd9cd4730fa10ca05a464116d43ce + + sys_documentation + admin + 2025-10-23 09:06:24 + 398c1dcd4730fa10ca05a464116d4304 + 0 + + b812ceb69337a210633378917cba10bc + + b812ceb69337a210633378917cba10bc + + admin + 2025-10-23 09:06:24 + + + + + aggregates + + + + en + var__m_sys_hub_step_ext_output_a58cd9cd4730fa10ca05a464116d43ce + + sys_documentation + admin + 2025-10-23 09:06:24 + 718c1dcd4730fa10ca05a464116d430a + 0 + + b812ceb69337a210633378917cba10bc + + b812ceb69337a210633378917cba10bc + + admin + 2025-10-23 09:06:24 + + + + + message + + + + en + var__m_sys_hub_step_ext_output_a58cd9cd4730fa10ca05a464116d43ce + + sys_documentation + admin + 2025-10-23 09:06:24 + b98c1dcd4730fa10ca05a464116d430f + 0 + + b812ceb69337a210633378917cba10bc + + b812ceb69337a210633378917cba10bc + + admin + 2025-10-23 09:06:24 + + + + + success + + + + en + var__m_sys_hub_step_ext_output_a58cd9cd4730fa10ca05a464116d43ce + + sys_documentation + admin + 2025-10-23 09:06:24 + fd8cd9cd4730fa10ca05a464116d43fe + 0 + + b812ceb69337a210633378917cba10bc + + b812ceb69337a210633378917cba10bc + + admin + 2025-10-23 09:06:24 + + + + + + true + false + false + element_mapping_provider=com.glide.flow_design.action.data.FlowDesignVariableMapper,uiType=table_name,uiTypeLabel=Table Name,uiUniqueId=7077a494-79b4-483b-b05f-036a62305122 + false + + + + + + + + + + + + + false + false + + + + table + false + + + + false + + + table_name + + true + 80 + a18cd9cd4730fa10ca05a464116d436d + a18cd9cd4730fa10ca05a464116d436d + sys_hub_action_type_snapshot + var__m_sys_hub_action_input_a18cd9cd4730fa10ca05a464116d436d + + 1 + false + false + + + + false + + + + + + false + false + sys_hub_action_input + admin + 2025-10-23 09:06:24 + 298cd9cd4730fa10ca05a464116d437e + 0 + + + + b812ceb69337a210633378917cba10bc + + admin + 2025-10-23 09:06:24 + false + false + false + false + false + simple + false + script + + + false + + + + true + false + false + element_mapping_provider=com.glide.flow_design.action.data.FlowDesignVariableMapper,uiType=conditions,uiTypeLabel=Conditions,uiUniqueId=29147458-ff23-4158-a526-e72ec2d07084 + false + + + + + + + + + + + inputs.table + inputs.table + false + false + + + + conditions + false + + + + false + + + conditions + + true + 4000 + a18cd9cd4730fa10ca05a464116d436d + a18cd9cd4730fa10ca05a464116d436d + sys_hub_action_type_snapshot + var__m_sys_hub_action_input_a18cd9cd4730fa10ca05a464116d436d + + 2 + false + false + + + + false + + + + + + false + false + sys_hub_action_input + admin + 2025-10-23 09:06:24 + e18cd9cd4730fa10ca05a464116d4386 + 0 + + + + b812ceb69337a210633378917cba10bc + + admin + 2025-10-23 09:06:24 + false + false + false + true + false + simple + false + script + + + false + + + + true + false + false + element_mapping_provider=com.glide.flow_design.action.data.FlowDesignVariableMapper,uiType=choice,uiTypeLabel=Choice,uiUniqueId=e4b7df3a-04ed-4067-a1af-c976821ca762 + false + + 3 + + + + + + ALL + + + + + false + false + + + + aggregate_type + false + + + + false + + + choice + + true + 32 + a18cd9cd4730fa10ca05a464116d436d + a18cd9cd4730fa10ca05a464116d436d + sys_hub_action_type_snapshot + var__m_sys_hub_action_input_a18cd9cd4730fa10ca05a464116d436d + + 4 + false + false + + + + false + + + + + + false + false + sys_hub_action_input + admin + 2025-10-23 09:06:24 + e18cd9cd4730fa10ca05a464116d4393 + 1 + + + + b812ceb69337a210633378917cba10bc + + admin + 2025-10-23 09:06:24 + false + false + false + false + false + simple + false + script + + + false + + + + true + false + false + element_mapping_provider=com.glide.flow_design.action.data.FlowDesignVariableMapper,uiType=string,uiTypeLabel=String,uiUniqueId=278ea3e0-e158-419c-bdeb-9518a9fe5391 + false + + + + + + + + + + + + + false + false + + + + field + false + + + + false + + + string + + true + 8000 + a18cd9cd4730fa10ca05a464116d436d + a18cd9cd4730fa10ca05a464116d436d + sys_hub_action_type_snapshot + var__m_sys_hub_action_input_a18cd9cd4730fa10ca05a464116d436d + + 3 + false + false + + + + false + + + + + + false + false + sys_hub_action_input + admin + 2025-10-23 09:06:24 + e98cd9cd4730fa10ca05a464116d438c + 0 + + + + b812ceb69337a210633378917cba10bc + + admin + 2025-10-23 09:06:24 + false + false + false + false + false + simple + false + script + + + false + + + + + true + false + false + element_mapping_provider=com.glide.flow_design.action.data.FlowDesignVariableMapper,pwd2droppable=true,uiType=string,uiTypeLabel=String,uiUniqueId=0bde9b86-6790-4d9f-b95e-de8d8bfb29fb + false + + + + + + + + + + + + + false + false + + + + error + + false + + + + false + + + + string + + false + 8000 + a18cd9cd4730fa10ca05a464116d436d + a18cd9cd4730fa10ca05a464116d436d + sys_hub_action_type_snapshot + var__m_sys_hub_action_output_a18cd9cd4730fa10ca05a464116d436d + + 3 + false + false + + + + false + + + + + + false + false + sys_hub_action_output + admin + 2025-10-23 09:06:25 + 318c1dcd4730fa10ca05a464116d433f + 0 + + + + b812ceb69337a210633378917cba10bc + + admin + 2025-10-23 09:06:25 + false + false + false + false + false + simple + false + script + + + false + + + + + true + false + false + action_error_output=true,co_type_name=FDACTIONSTATUS,element_mapping_provider=com.glide.flow_design.action.data.FlowDesignVariableMapper,uiType=object,uiTypeLabel=Object,uiUniqueId=fde46073-a562-40a1-b0d3-402e93206bbf + false + + + + + + + + + + + + + false + false + + + + __action_status__ + + false + + + + false + + + + string + + false + 65000 + a18cd9cd4730fa10ca05a464116d436d + a18cd9cd4730fa10ca05a464116d436d + sys_hub_action_type_snapshot + var__m_sys_hub_action_output_a18cd9cd4730fa10ca05a464116d436d + + 2 + false + false + + + + false + + + + + + false + false + sys_hub_action_output + admin + 2025-10-23 09:06:25 + 358c1dcd4730fa10ca05a464116d4338 + 0 + + + + b812ceb69337a210633378917cba10bc + + admin + 2025-10-23 09:06:25 + false + false + false + false + false + simple + false + script + + + false + + + + + true + false + false + action_error_output=true,element_mapping_provider=com.glide.flow_design.action.data.FlowDesignVariableMapper,uiType=boolean,uiTypeLabel=True/False,uiUniqueId=4f5bc7c1-ef3b-4b5e-9264-492393f8a9e4,visible_in_ui=false + false + + + + + + + + true + + + + + false + false + + + + __dont_treat_as_error__ + + false + + + + false + + + + boolean + + false + 40 + a18cd9cd4730fa10ca05a464116d436d + a18cd9cd4730fa10ca05a464116d436d + sys_hub_action_type_snapshot + var__m_sys_hub_action_output_a18cd9cd4730fa10ca05a464116d436d + + 4 + false + false + + + + false + + + + + + false + false + sys_hub_action_output + admin + 2025-10-23 09:06:25 + b98c1dcd4730fa10ca05a464116d4345 + 1 + + + + b812ceb69337a210633378917cba10bc + + admin + 2025-10-23 09:06:25 + false + false + false + false + false + simple + false + script + + + false + + + + + true + false + false + element_mapping_provider=com.glide.flow_design.action.data.FlowDesignVariableMapper,uiType=boolean,uiTypeLabel=True/False,uiUniqueId=380103db-5413-4189-8bf7-47160aeff7b8 + false + + + + + + + + + + + + + false + false + + + + success + + false + + + + false + + + + boolean + + false + 40 + a18cd9cd4730fa10ca05a464116d436d + a18cd9cd4730fa10ca05a464116d436d + sys_hub_action_type_snapshot + var__m_sys_hub_action_output_a18cd9cd4730fa10ca05a464116d436d + + 1 + false + false + + + + false + + + + + + false + false + sys_hub_action_output + admin + 2025-10-23 09:06:24 + bd8c1dcd4730fa10ca05a464116d4330 + 0 + + + + b812ceb69337a210633378917cba10bc + + admin + 2025-10-23 09:06:24 + false + false + false + false + false + simple + false + script + + + false + + + + + + + true + false + false + co_type_name=FD798c1dcd8230fa100056d2c8fde4fa2f,element_mapping_provider=com.glide.flow_design.action.data.FlowDesignVariableMapper,sourceId=b9c2c56e-4f59-44aa-b717-00cb3a915d34,sourceType=step,sourceUiUniqueId=7209ca22-5861-41e0-af52-b6df525b3284,uiType=object,uiTypeLabel=Object,uiUniqueId=665e9f16-0e14-485e-b3c3-a9114ee4fd41 + false + + + + + + + + + + + + + false + false + + + + aggregates + + false + + + + false + + + + string + + false + 65000 + a18cd9cd4730fa10ca05a464116d436d + a18cd9cd4730fa10ca05a464116d436d + sys_hub_action_type_snapshot + var__m_sys_hub_action_output_a18cd9cd4730fa10ca05a464116d436d + + 5 + false + false + + + + false + + + + + + false + false + sys_hub_action_output + admin + 2025-10-23 09:06:25 + f98c1dcd4730fa10ca05a464116d435b + 0 + + + + b812ceb69337a210633378917cba10bc + + admin + 2025-10-23 09:06:25 + false + false + false + false + false + simple + false + script + + + false + + + + + true + false + false + element_mapping_provider=com.glide.flow_design.action.data.FlowDesignVariableMapper,pwd2droppable=true,uiType=string,uiTypeLabel=String,uiUniqueId=bec4ea0a-6563-4a03-be3b-cd162901e66f + false + + + + + + + + + + + + + false + false + + + + message + + false + + + + false + + + + string + + false + 8000 + a18cd9cd4730fa10ca05a464116d436d + a18cd9cd4730fa10ca05a464116d436d + sys_hub_action_type_snapshot + var__m_sys_hub_action_output_a18cd9cd4730fa10ca05a464116d436d + + 6 + false + false + + + + false + + + + + + false + false + sys_hub_action_output + admin + 2025-10-23 09:06:25 + f98c1dcd4730fa10ca05a464116d4362 + 0 + + + + b812ceb69337a210633378917cba10bc + + admin + 2025-10-23 09:06:25 + false + false + false + false + false + simple + false + script + + + false + + + + + + + a18cd9cd4730fa10ca05a464116d436d + admin + 2025-10-23 09:06:25 + f58c1dcd4730fa10ca05a464116d4377 + 0 + admin + 2025-10-23 09:06:25 + + + + f58c1dcd4730fa10ca05a464116d4377 + {{step[b9c2c56e-4f59-44aa-b717-00cb3a915d34].error}}ISNOTEMPTY + false + + 1 + {"version":"1.0","serializationFormat":"JSON","complexObjectSchema":{"FlowDesigner:FDACTIONSTATUS":{"code":"Integer","code.$field_facets":{"SimpleMapFacet":"{\"uiTypeLabel\":\"Integer\",\"read_only\":\"false\",\"hint\":\"\",\"uiType\":\"integer\",\"default_value\":\"\",\"label\":\"Code\",\"action_error_output\":\"true\",\"mandatory\":\"false\",\"order\":\"1\",\"max_length\":\"40\"}"},"message":"String","message.$field_facets":{"SimpleMapFacet":"{\"uiTypeLabel\":\"String\",\"read_only\":\"false\",\"hint\":\"\",\"uiType\":\"string\",\"mapped\":\"{\\\"message\\\":\\\"{{step[b9c2c56e-4f59-44aa-b717-00cb3a915d34].error}}\\\"}\",\"default_value\":\"\",\"label\":\"Message\",\"action_error_output\":\"true\",\"mandatory\":\"false\",\"order\":\"2\",\"max_length\":\"4000\"}"}},"FlowDesigner:FDACTIONSTATUS.$type_facets":{"SimpleMapFacet":"{\"default_value\":\"\",\"label\":\"Action Status\",\"action_error_output\":\"true\",\"mandatory\":\"false\",\"uiUniqueId\":\"4adfb7bc-9d67-498d-88d0-8d6c3d584fed\",\"uiTypeLabel\":\"Object\",\"co_type_name\":\"FDACTIONSTATUS\",\"element_mapping_provider\":\"com.glide.flow_design.action.data.FlowDesignVariableMapper\",\"read_only\":\"false\",\"hint\":null,\"uiType\":\"object\",\"order\":\"1\",\"max_length\":\"65000\"}"}},"complexObject":{"code":{"$cv":{"$c":"java.lang.String","$v":"1"}},"message":{"$cv":{"$c":"java.lang.String","$v":""}}}} + admin + 2025-10-23 09:06:25 + 3d8c1dcd4730fa10ca05a464116d4377 + 0 + admin + 2025-10-23 09:06:25 + + + aggregate_type + + + + en + var__m_sys_hub_action_input_a18cd9cd4730fa10ca05a464116d436d + + sys_documentation + admin + 2025-10-23 09:06:24 + 698cd9cd4730fa10ca05a464116d43c6 + 0 + + b812ceb69337a210633378917cba10bc + + b812ceb69337a210633378917cba10bc + + admin + 2025-10-23 09:06:24 + + + + + conditions + + + + en + var__m_sys_hub_action_input_a18cd9cd4730fa10ca05a464116d436d + + sys_documentation + admin + 2025-10-23 09:06:24 + e18cd9cd4730fa10ca05a464116d438b + 0 + + b812ceb69337a210633378917cba10bc + + b812ceb69337a210633378917cba10bc + + admin + 2025-10-23 09:06:24 + + + + + table + + + + en + var__m_sys_hub_action_input_a18cd9cd4730fa10ca05a464116d436d + + sys_documentation + admin + 2025-10-23 09:06:24 + e98cd9cd4730fa10ca05a464116d4384 + 0 + + b812ceb69337a210633378917cba10bc + + b812ceb69337a210633378917cba10bc + + admin + 2025-10-23 09:06:24 + + + + + field + + + + en + var__m_sys_hub_action_input_a18cd9cd4730fa10ca05a464116d436d + + sys_documentation + admin + 2025-10-23 09:06:24 + e98cd9cd4730fa10ca05a464116d4391 + 0 + + b812ceb69337a210633378917cba10bc + + b812ceb69337a210633378917cba10bc + + admin + 2025-10-23 09:06:24 + + + + + + + + aggregate_type + + false + + en + var__m_sys_hub_action_input_a18cd9cd4730fa10ca05a464116d436d + 2 + + admin + 2025-10-23 09:06:24 + global + / + 218cd9cd4730fa10ca05a464116d43a5 + 0 + admin + 2025-10-23 09:06:24 + AVG + + + + aggregate_type + + false + + en + var__m_sys_hub_action_input_a18cd9cd4730fa10ca05a464116d436d + 6 + + admin + 2025-10-23 09:06:24 + global + / + 2d8cd9cd4730fa10ca05a464116d43a7 + 0 + admin + 2025-10-23 09:06:24 + GROUP_CONCAT + + + + aggregate_type + + false + + en + var__m_sys_hub_action_input_a18cd9cd4730fa10ca05a464116d436d + 5 + + admin + 2025-10-23 09:06:24 + global + / + 618cd9cd4730fa10ca05a464116d43a7 + 0 + admin + 2025-10-23 09:06:24 + STDDEV + + + + aggregate_type + + false + + en + var__m_sys_hub_action_input_a18cd9cd4730fa10ca05a464116d436d + 1 + + admin + 2025-10-23 09:06:24 + global + / + 658cd9cd4730fa10ca05a464116d43a4 + 0 + admin + 2025-10-23 09:06:24 + SUM + + + + aggregate_type + + false + + en + var__m_sys_hub_action_input_a18cd9cd4730fa10ca05a464116d436d + 8 + + admin + 2025-10-23 09:06:24 + global + / + a18cd9cd4730fa10ca05a464116d43a9 + 0 + admin + 2025-10-23 09:06:24 + ALL + + + + aggregate_type + + false + + en + var__m_sys_hub_action_input_a18cd9cd4730fa10ca05a464116d436d + 4 + + admin + 2025-10-23 09:06:24 + global + / + a58cd9cd4730fa10ca05a464116d43a6 + 0 + admin + 2025-10-23 09:06:24 + MAX + + + + aggregate_type + + false + + en + var__m_sys_hub_action_input_a18cd9cd4730fa10ca05a464116d436d + 0 + + admin + 2025-10-23 09:06:24 + global + / + a98cd9cd4730fa10ca05a464116d43a3 + 0 + admin + 2025-10-23 09:06:24 + COUNT + + + + aggregate_type + + false + + en + var__m_sys_hub_action_input_a18cd9cd4730fa10ca05a464116d436d + 7 + + admin + 2025-10-23 09:06:24 + global + / + e58cd9cd4730fa10ca05a464116d43a8 + 0 + admin + 2025-10-23 09:06:24 + GROUP_CONCAT_DISTINCT + + + + aggregate_type + + false + + en + var__m_sys_hub_action_input_a18cd9cd4730fa10ca05a464116d436d + 3 + + admin + 2025-10-23 09:06:24 + global + / + e98cd9cd4730fa10ca05a464116d43a5 + 0 + admin + 2025-10-23 09:06:24 + MIN + + + + __action_status__ + + + + en + var__m_sys_hub_action_output_a18cd9cd4730fa10ca05a464116d436d + + sys_documentation + admin + 2025-10-23 09:06:25 + 398c1dcd4730fa10ca05a464116d433d + 0 + + b812ceb69337a210633378917cba10bc + + b812ceb69337a210633378917cba10bc + + admin + 2025-10-23 09:06:25 + + + + + success + + + + en + var__m_sys_hub_action_output_a18cd9cd4730fa10ca05a464116d436d + + sys_documentation + admin + 2025-10-23 09:06:25 + 3d8c1dcd4730fa10ca05a464116d4336 + 0 + + b812ceb69337a210633378917cba10bc + + b812ceb69337a210633378917cba10bc + + admin + 2025-10-23 09:06:25 + + + + + __dont_treat_as_error__ + + + + en + var__m_sys_hub_action_output_a18cd9cd4730fa10ca05a464116d436d + + sys_documentation + admin + 2025-10-23 09:06:25 + 3d8c1dcd4730fa10ca05a464116d434d + 0 + + b812ceb69337a210633378917cba10bc + + b812ceb69337a210633378917cba10bc + + admin + 2025-10-23 09:06:25 + + + + + message + + + + en + var__m_sys_hub_action_output_a18cd9cd4730fa10ca05a464116d436d + + sys_documentation + admin + 2025-10-23 09:06:25 + 7d8c1dcd4730fa10ca05a464116d4367 + 0 + + b812ceb69337a210633378917cba10bc + + b812ceb69337a210633378917cba10bc + + admin + 2025-10-23 09:06:25 + + + + + error + + + + en + var__m_sys_hub_action_output_a18cd9cd4730fa10ca05a464116d436d + + sys_documentation + admin + 2025-10-23 09:06:25 + b18c1dcd4730fa10ca05a464116d4344 + 0 + + b812ceb69337a210633378917cba10bc + + b812ceb69337a210633378917cba10bc + + admin + 2025-10-23 09:06:25 + + + + + aggregates + + + + en + var__m_sys_hub_action_output_a18cd9cd4730fa10ca05a464116d436d + + sys_documentation + admin + 2025-10-23 09:06:25 + f18c1dcd4730fa10ca05a464116d4361 + 0 + + b812ceb69337a210633378917cba10bc + + b812ceb69337a210633378917cba10bc + + admin + 2025-10-23 09:06:25 + + + + + + 32a1c1c5477cba10ca05a464116d43da + a18cd9cd4730fa10ca05a464116d436d + glide-zurich-07-01-2025__patch2-09-24-2025_10-12-2025_0904.zip + + From 48c9e90ffd8f63fc3c5a5e1e7c332da11c78408e Mon Sep 17 00:00:00 2001 From: admin Date: Thu, 23 Oct 2025 03:56:32 -0700 Subject: [PATCH 2/2] =?UTF-8?q?Get=20GlideAggregate(Multiple)=20Flow=20Act?= =?UTF-8?q?ion=20=E2=80=94=20updated=20commit=20by=20@NowSharif?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ition_32a1c1c5477cba10ca05a464116d43da.xml | 318 ++++++++++-------- 1 file changed, 173 insertions(+), 145 deletions(-) diff --git a/b812ceb69337a210633378917cba10bc/update/sys_hub_action_type_definition_32a1c1c5477cba10ca05a464116d43da.xml b/b812ceb69337a210633378917cba10bc/update/sys_hub_action_type_definition_32a1c1c5477cba10ca05a464116d43da.xml index d96a512..0288cd0 100644 --- a/b812ceb69337a210633378917cba10bc/update/sys_hub_action_type_definition_32a1c1c5477cba10ca05a464116d43da.xml +++ b/b812ceb69337a210633378917cba10bc/update/sys_hub_action_type_definition_32a1c1c5477cba10ca05a464116d43da.xml @@ -31,7 +31,7 @@ global / 32a1c1c5477cba10ca05a464116d43da - 23 + 35 Get GlideAggregate(Multiple) b812ceb69337a210633378917cba10bc @@ -39,7 +39,7 @@ b812ceb69337a210633378917cba10bc sys_hub_action_type_definition_32a1c1c5477cba10ca05a464116d43da admin - 2025-10-23 09:06:25 + 2025-10-23 10:46:07 false @@ -192,10 +192,10 @@ admin 2025-10-23 07:12:24 676249c9477cba10ca05a464116d4340 - 9 + 17 b812ceb69337a210633378917cba10bc admin - 2025-10-23 09:00:51 + 2025-10-23 10:45:06 @@ -206,18 +206,16 @@ admin 2025-10-23 07:12:24 376249c9477cba10ca05a464116d4356 - 5 + 13 admin - 2025-10-23 09:00:51 + 2025-10-23 10:45:06 (function execute(inputs, outputs) { try { - // Normalize and validate required inputs var tableName = String(inputs.table_name || '').trim(); var conditions = String(inputs.conditions || '').trim(); var fieldName = String(inputs.field || '').trim(); var aggregateType = String(inputs.aggregate_type || '').trim().toUpperCase(); - // Input validation if (!tableName) { outputs.success = false; outputs.error = 'Missing required input: table_name'; @@ -234,48 +232,61 @@ return; } - // Validate table exists var tableValidator = new GlideRecord(tableName); if (!tableValidator.isValid()) { outputs.success = false; outputs.error = 'Invalid table: ' + tableName; return; } - - // Validate field exists on the table if (!tableValidator.isValidField(fieldName)) { outputs.success = false; outputs.error = 'Invalid field: ' + fieldName + ' on table: ' + tableName; return; } - // Get field type from sys_dictionary - var fieldType = null; - var fieldInfo = new GlideRecord('sys_dictionary'); - fieldInfo.addQuery('name', tableName); - fieldInfo.addQuery('element', fieldName); - fieldInfo.setLimit(1); - fieldInfo.query(); - if (fieldInfo.next()) { - fieldType = fieldInfo.getValue('internal_type'); + function getParentTables(tableName) { + var parents = []; + var sysTable = new GlideRecord('sys_db_object'); + sysTable.addQuery('name', tableName); + sysTable.setLimit(1); + sysTable.query(); + if (sysTable.next()) { + var superClass = sysTable.getValue('super_class'); + if (superClass && superClass != tableName) { + parents.push(superClass); + parents = parents.concat(getParentTables(superClass)); + } + } + return parents; } + function getFieldType(tableName, fieldName) { + var fieldType = null; + var dict = new GlideRecord('sys_dictionary'); + dict.addQuery('name', tableName); + dict.addQuery('element', fieldName); + dict.setLimit(1); + dict.query(); + if (dict.next()) { + fieldType = dict.getValue('internal_type'); + if (fieldType) return fieldType; + } + var parents = getParentTables(tableName); + for (var i = 0; i < parents.length; i++) { + var dictParent = new GlideRecord('sys_dictionary'); + dictParent.addQuery('name', parents[i]); + dictParent.addQuery('element', fieldName); + dictParent.setLimit(1); + dictParent.query(); + if (dictParent.next()) { + fieldType = dictParent.getValue('internal_type'); + if (fieldType) return fieldType; + } + } + return 'string'; + } + var fieldType = getFieldType(tableName, fieldName); - - // Initialize result object with all possible aggregates - var aggregateResult = { - count: null, - sum: null, - avg: null, - max: null, - min: null, - stddev: null, - group_concat: null, - group_concat_distinct: null, - aggregate_type_requested: aggregateType - }; - - // Validate aggregate type is one of the allowed values var allowedTypes = ['COUNT', 'SUM', 'AVG', 'MAX', 'MIN', 'STDDEV', 'GROUP_CONCAT', 'GROUP_CONCAT_DISTINCT', 'ALL']; if (allowedTypes.indexOf(aggregateType) === -1) { outputs.success = false; @@ -283,37 +294,36 @@ return; } - // Determine which aggregates are applicable based on field type - var isNumericField = ['integer', 'decimal', 'float', 'currency', 'percent', 'price'].indexOf(fieldType) !== -1; + var numericTypes = ['integer', 'decimal', 'float', 'currency', 'percent', 'price']; + var isNumericField = numericTypes.indexOf(fieldType) !== -1; var skippedAggregates = []; var applicableAggregates = []; - - // Numeric aggregates only work on numeric fields var numericAggregates = ['SUM', 'AVG', 'STDDEV', 'MAX', 'MIN']; var stringAggregates = ['GROUP_CONCAT', 'GROUP_CONCAT_DISTINCT', 'COUNT']; + var referenceAggregates = ['GROUP_CONCAT', 'GROUP_CONCAT_DISTINCT', 'COUNT']; if (aggregateType === 'ALL') { - // For ALL, add only applicable aggregates based on field type - aggregateResult.count = 0; // COUNT always works applicableAggregates.push('COUNT'); - if (isNumericField) { + applicableAggregates = applicableAggregates.concat(numericAggregates); + } else if (fieldType === 'reference') { + referenceAggregates.forEach(function(agg) { + if (applicableAggregates.indexOf(agg) === -1) { + applicableAggregates.push(agg); + } + }); numericAggregates.forEach(function(agg) { - applicableAggregates.push(agg); + skippedAggregates.push(agg + ' (not applicable for reference field)'); }); } else { + stringAggregates.forEach(function(agg) { + if (agg !== 'COUNT') applicableAggregates.push(agg); + }); numericAggregates.forEach(function(agg) { skippedAggregates.push(agg + ' (not applicable for ' + fieldType + ' field)'); }); } - - stringAggregates.filter(function(agg) { - return agg !== 'COUNT'; - }).forEach(function(agg) { - applicableAggregates.push(agg); - }); } else { - // Single aggregate requested if (aggregateType === 'COUNT') { applicableAggregates.push('COUNT'); } else if (numericAggregates.indexOf(aggregateType) !== -1 && !isNumericField) { @@ -323,7 +333,6 @@ } } - // If no applicable aggregates, return error if (applicableAggregates.length === 0) { outputs.success = false; outputs.error = 'No applicable aggregates for field type: ' + fieldType + '. Requested: ' + aggregateType; @@ -331,25 +340,27 @@ return; } - // Create GlideAggregate instance var aggregator = new GlideAggregate(tableName); if (conditions) { aggregator.addEncodedQuery(conditions); } aggregator.setGroup(false); - // Add only applicable aggregates applicableAggregates.forEach(function(agg) { - aggregator.addAggregate(agg, fieldName); + if (agg === 'COUNT') { + aggregator.addAggregate('COUNT'); + } else { + aggregator.addAggregate(agg, fieldName); + } }); - // Execute the aggregate query aggregator.query(); - // Process results + var aggregateResult = {}; + if (aggregator.next()) { applicableAggregates.forEach(function(agg) { - var rawValue = aggregator.getAggregate(agg, fieldName); + var rawValue = (agg === 'COUNT') ? aggregator.getAggregate('COUNT') : aggregator.getAggregate(agg, fieldName); switch (agg) { case 'COUNT': @@ -380,18 +391,21 @@ }); outputs.success = true; - outputs.message = 'Aggregate(s) calculated successfully. Field type: ' + fieldType; + outputs.message = '\nAggregate(s) calculated successfully. ' + + '\nField type detected: ' + fieldType + '. ' + + '\nAggregate type requested: ' + aggregateType + '.'; if (skippedAggregates.length > 0) { - outputs.message += '. Skipped: ' + skippedAggregates.join('; '); + outputs.message += '\nSkipped aggregates: ' + skippedAggregates.join('; '); } outputs.aggregates = aggregateResult; outputs.skipped_aggregates = skippedAggregates; } else { - // No records matched the conditions outputs.success = true; - outputs.message = 'No records found matching the specified conditions. Field type: ' + fieldType; + outputs.message = '\nNo records found matching the specified conditions. ' + + '\nField type detected: ' + fieldType + '. ' + + '\nAggregate type requested: ' + aggregateType + '.'; if (skippedAggregates.length > 0) { - outputs.message += '. Skipped: ' + skippedAggregates.join('; '); + outputs.message += '\nSkipped aggregates: ' + skippedAggregates.join('; '); } outputs.aggregates = aggregateResult; outputs.skipped_aggregates = skippedAggregates; @@ -809,14 +823,14 @@ admin 2025-10-23 07:49:45 bafa4dc947bcba10ca05a464116d4382 - 9 + 18 b812ceb69337a210633378917cba10bc admin - 2025-10-23 09:06:23 + 2025-10-23 10:46:05 false false false @@ -1319,14 +1333,14 @@ admin 2025-10-23 07:25:36 1575094147bcba10ca05a464116d431a - 19 + 37 b812ceb69337a210633378917cba10bc admin - 2025-10-23 09:06:22 + 2025-10-23 10:46:05 false false false @@ -1403,14 +1417,14 @@ admin 2025-10-23 07:09:57 3bd18589477cba10ca05a464116d436d - 12 + 21 b812ceb69337a210633378917cba10bc admin - 2025-10-23 09:06:22 + 2025-10-23 10:46:05 false false false @@ -1605,7 +1619,7 @@ global / 47fa4dc947bcba10ca05a464116d43bb - 8 + 17 @@ -1613,7 +1627,7 @@ b812ceb69337a210633378917cba10bc admin - 2025-10-23 09:06:23 + 2025-10-23 10:46:05 complex_object_schema @@ -2116,14 +2130,14 @@ admin 2025-10-23 07:09:57 f3d18589477cba10ca05a464116d43d7 - 25 + 43 b812ceb69337a210633378917cba10bc admin - 2025-10-23 09:06:23 + 2025-10-23 10:46:05 false false false @@ -2582,17 +2596,17 @@ 32a1c1c5477cba10ca05a464116d43da {"type":"PlanProxy","persistor":{"@class":".ChunkingPlanPersistor","table":"sys_hub_action_plan","id":"c68c1dcd4730fa10ca05a464116d43e8","name":"plan","plan_signature":null}} - fd8c1dcd4730fa10ca05a464116d4377 + da53f94d47f0fa10ca05a464116d4342 admin 2025-10-23 09:06:26 global / c68c1dcd4730fa10ca05a464116d43e8 - 0 + 1 admin - 2025-10-23 09:06:26 + 2025-10-23 10:46:08 public @@ -2769,10 +2783,10 @@ admin 2025-10-23 09:06:24 a58cd9cd4730fa10ca05a464116d43ce - 1 + 2 b812ceb69337a210633378917cba10bc admin - 2025-10-23 09:06:24 + 2025-10-23 10:46:07 @@ -2797,18 +2811,16 @@ admin 2025-10-23 09:06:24 fd8c1dcd4730fa10ca05a464116d4327 - 0 + 1 admin - 2025-10-23 09:06:24 + 2025-10-23 10:46:07 (function execute(inputs, outputs) { try { - // Normalize and validate required inputs var tableName = String(inputs.table_name || '').trim(); var conditions = String(inputs.conditions || '').trim(); var fieldName = String(inputs.field || '').trim(); var aggregateType = String(inputs.aggregate_type || '').trim().toUpperCase(); - // Input validation if (!tableName) { outputs.success = false; outputs.error = 'Missing required input: table_name'; @@ -2825,48 +2837,61 @@ return; } - // Validate table exists var tableValidator = new GlideRecord(tableName); if (!tableValidator.isValid()) { outputs.success = false; outputs.error = 'Invalid table: ' + tableName; return; } - - // Validate field exists on the table if (!tableValidator.isValidField(fieldName)) { outputs.success = false; outputs.error = 'Invalid field: ' + fieldName + ' on table: ' + tableName; return; } - // Get field type from sys_dictionary - var fieldType = null; - var fieldInfo = new GlideRecord('sys_dictionary'); - fieldInfo.addQuery('name', tableName); - fieldInfo.addQuery('element', fieldName); - fieldInfo.setLimit(1); - fieldInfo.query(); - if (fieldInfo.next()) { - fieldType = fieldInfo.getValue('internal_type'); + function getParentTables(tableName) { + var parents = []; + var sysTable = new GlideRecord('sys_db_object'); + sysTable.addQuery('name', tableName); + sysTable.setLimit(1); + sysTable.query(); + if (sysTable.next()) { + var superClass = sysTable.getValue('super_class'); + if (superClass && superClass != tableName) { + parents.push(superClass); + parents = parents.concat(getParentTables(superClass)); + } + } + return parents; } + function getFieldType(tableName, fieldName) { + var fieldType = null; + var dict = new GlideRecord('sys_dictionary'); + dict.addQuery('name', tableName); + dict.addQuery('element', fieldName); + dict.setLimit(1); + dict.query(); + if (dict.next()) { + fieldType = dict.getValue('internal_type'); + if (fieldType) return fieldType; + } + var parents = getParentTables(tableName); + for (var i = 0; i < parents.length; i++) { + var dictParent = new GlideRecord('sys_dictionary'); + dictParent.addQuery('name', parents[i]); + dictParent.addQuery('element', fieldName); + dictParent.setLimit(1); + dictParent.query(); + if (dictParent.next()) { + fieldType = dictParent.getValue('internal_type'); + if (fieldType) return fieldType; + } + } + return 'string'; + } + var fieldType = getFieldType(tableName, fieldName); - - // Initialize result object with all possible aggregates - var aggregateResult = { - count: null, - sum: null, - avg: null, - max: null, - min: null, - stddev: null, - group_concat: null, - group_concat_distinct: null, - aggregate_type_requested: aggregateType - }; - - // Validate aggregate type is one of the allowed values var allowedTypes = ['COUNT', 'SUM', 'AVG', 'MAX', 'MIN', 'STDDEV', 'GROUP_CONCAT', 'GROUP_CONCAT_DISTINCT', 'ALL']; if (allowedTypes.indexOf(aggregateType) === -1) { outputs.success = false; @@ -2874,37 +2899,36 @@ return; } - // Determine which aggregates are applicable based on field type - var isNumericField = ['integer', 'decimal', 'float', 'currency', 'percent', 'price'].indexOf(fieldType) !== -1; + var numericTypes = ['integer', 'decimal', 'float', 'currency', 'percent', 'price']; + var isNumericField = numericTypes.indexOf(fieldType) !== -1; var skippedAggregates = []; var applicableAggregates = []; - - // Numeric aggregates only work on numeric fields var numericAggregates = ['SUM', 'AVG', 'STDDEV', 'MAX', 'MIN']; var stringAggregates = ['GROUP_CONCAT', 'GROUP_CONCAT_DISTINCT', 'COUNT']; + var referenceAggregates = ['GROUP_CONCAT', 'GROUP_CONCAT_DISTINCT', 'COUNT']; if (aggregateType === 'ALL') { - // For ALL, add only applicable aggregates based on field type - aggregateResult.count = 0; // COUNT always works applicableAggregates.push('COUNT'); - if (isNumericField) { + applicableAggregates = applicableAggregates.concat(numericAggregates); + } else if (fieldType === 'reference') { + referenceAggregates.forEach(function(agg) { + if (applicableAggregates.indexOf(agg) === -1) { + applicableAggregates.push(agg); + } + }); numericAggregates.forEach(function(agg) { - applicableAggregates.push(agg); + skippedAggregates.push(agg + ' (not applicable for reference field)'); }); } else { + stringAggregates.forEach(function(agg) { + if (agg !== 'COUNT') applicableAggregates.push(agg); + }); numericAggregates.forEach(function(agg) { skippedAggregates.push(agg + ' (not applicable for ' + fieldType + ' field)'); }); } - - stringAggregates.filter(function(agg) { - return agg !== 'COUNT'; - }).forEach(function(agg) { - applicableAggregates.push(agg); - }); } else { - // Single aggregate requested if (aggregateType === 'COUNT') { applicableAggregates.push('COUNT'); } else if (numericAggregates.indexOf(aggregateType) !== -1 && !isNumericField) { @@ -2914,7 +2938,6 @@ } } - // If no applicable aggregates, return error if (applicableAggregates.length === 0) { outputs.success = false; outputs.error = 'No applicable aggregates for field type: ' + fieldType + '. Requested: ' + aggregateType; @@ -2922,25 +2945,27 @@ return; } - // Create GlideAggregate instance var aggregator = new GlideAggregate(tableName); if (conditions) { aggregator.addEncodedQuery(conditions); } aggregator.setGroup(false); - // Add only applicable aggregates applicableAggregates.forEach(function(agg) { - aggregator.addAggregate(agg, fieldName); + if (agg === 'COUNT') { + aggregator.addAggregate('COUNT'); + } else { + aggregator.addAggregate(agg, fieldName); + } }); - // Execute the aggregate query aggregator.query(); - // Process results + var aggregateResult = {}; + if (aggregator.next()) { applicableAggregates.forEach(function(agg) { - var rawValue = aggregator.getAggregate(agg, fieldName); + var rawValue = (agg === 'COUNT') ? aggregator.getAggregate('COUNT') : aggregator.getAggregate(agg, fieldName); switch (agg) { case 'COUNT': @@ -2971,18 +2996,21 @@ }); outputs.success = true; - outputs.message = 'Aggregate(s) calculated successfully. Field type: ' + fieldType; + outputs.message = '\nAggregate(s) calculated successfully. ' + + '\nField type detected: ' + fieldType + '. ' + + '\nAggregate type requested: ' + aggregateType + '.'; if (skippedAggregates.length > 0) { - outputs.message += '. Skipped: ' + skippedAggregates.join('; '); + outputs.message += '\nSkipped aggregates: ' + skippedAggregates.join('; '); } outputs.aggregates = aggregateResult; outputs.skipped_aggregates = skippedAggregates; } else { - // No records matched the conditions outputs.success = true; - outputs.message = 'No records found matching the specified conditions. Field type: ' + fieldType; + outputs.message = '\nNo records found matching the specified conditions. ' + + '\nField type detected: ' + fieldType + '. ' + + '\nAggregate type requested: ' + aggregateType + '.'; if (skippedAggregates.length > 0) { - outputs.message += '. Skipped: ' + skippedAggregates.join('; '); + outputs.message += '\nSkipped aggregates: ' + skippedAggregates.join('; '); } outputs.aggregates = aggregateResult; outputs.skipped_aggregates = skippedAggregates; @@ -4064,14 +4092,14 @@ admin 2025-10-23 09:06:24 e18cd9cd4730fa10ca05a464116d4393 - 1 + 3 b812ceb69337a210633378917cba10bc admin - 2025-10-23 09:06:24 + 2025-10-23 10:46:07 false false false @@ -4409,14 +4437,14 @@ admin 2025-10-23 09:06:25 b98c1dcd4730fa10ca05a464116d4345 - 1 + 3 b812ceb69337a210633378917cba10bc admin - 2025-10-23 09:06:25 + 2025-10-23 10:46:07 false false false @@ -4530,7 +4558,7 @@ global / 7d8c1dcd4730fa10ca05a464116d432f - 0 + 1 @@ -4538,7 +4566,7 @@ b812ceb69337a210633378917cba10bc admin - 2025-10-23 09:06:24 + 2025-10-23 10:46:07 complex_object_schema @@ -4726,7 +4754,7 @@ admin 2025-10-23 09:06:25 - + f58c1dcd4730fa10ca05a464116d4377 {{step[b9c2c56e-4f59-44aa-b717-00cb3a915d34].error}}ISNOTEMPTY @@ -4735,11 +4763,11 @@ 1 {"version":"1.0","serializationFormat":"JSON","complexObjectSchema":{"FlowDesigner:FDACTIONSTATUS":{"code":"Integer","code.$field_facets":{"SimpleMapFacet":"{\"uiTypeLabel\":\"Integer\",\"read_only\":\"false\",\"hint\":\"\",\"uiType\":\"integer\",\"default_value\":\"\",\"label\":\"Code\",\"action_error_output\":\"true\",\"mandatory\":\"false\",\"order\":\"1\",\"max_length\":\"40\"}"},"message":"String","message.$field_facets":{"SimpleMapFacet":"{\"uiTypeLabel\":\"String\",\"read_only\":\"false\",\"hint\":\"\",\"uiType\":\"string\",\"mapped\":\"{\\\"message\\\":\\\"{{step[b9c2c56e-4f59-44aa-b717-00cb3a915d34].error}}\\\"}\",\"default_value\":\"\",\"label\":\"Message\",\"action_error_output\":\"true\",\"mandatory\":\"false\",\"order\":\"2\",\"max_length\":\"4000\"}"}},"FlowDesigner:FDACTIONSTATUS.$type_facets":{"SimpleMapFacet":"{\"default_value\":\"\",\"label\":\"Action Status\",\"action_error_output\":\"true\",\"mandatory\":\"false\",\"uiUniqueId\":\"4adfb7bc-9d67-498d-88d0-8d6c3d584fed\",\"uiTypeLabel\":\"Object\",\"co_type_name\":\"FDACTIONSTATUS\",\"element_mapping_provider\":\"com.glide.flow_design.action.data.FlowDesignVariableMapper\",\"read_only\":\"false\",\"hint\":null,\"uiType\":\"object\",\"order\":\"1\",\"max_length\":\"65000\"}"}},"complexObject":{"code":{"$cv":{"$c":"java.lang.String","$v":"1"}},"message":{"$cv":{"$c":"java.lang.String","$v":""}}}} admin - 2025-10-23 09:06:25 - 3d8c1dcd4730fa10ca05a464116d4377 + 2025-10-23 10:46:07 + 1e53f94d47f0fa10ca05a464116d4341 0 admin - 2025-10-23 09:06:25 + 2025-10-23 10:46:07 aggregate_type