snow-flow 3.6.19 → 3.6.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -799,12 +799,15 @@ ${args.help_text ? `❓ Help: ${args.help_text}` : ''}
|
|
|
799
799
|
* Create Catalog UI Policy with Actions
|
|
800
800
|
* Creates records in 2 tables: sys_ui_policy and catalog_ui_policy_action
|
|
801
801
|
*
|
|
802
|
-
* ✅
|
|
802
|
+
* ✅ FINAL CORRECT STRUCTURE (v3.6.20):
|
|
803
803
|
* - Main policy goes in sys_ui_policy table (NOT catalog_ui_policy!)
|
|
804
|
-
* - Actions go in catalog_ui_policy_action table
|
|
805
|
-
* - Actions reference sys_ui_policy via ui_policy field (using policy
|
|
804
|
+
* - Actions go in catalog_ui_policy_action table (inherits from sys_ui_policy_action)
|
|
805
|
+
* - Actions reference sys_ui_policy via ui_policy field (using policy sys_id directly)
|
|
806
806
|
* - Conditions use IO:sys_id format for catalog variables
|
|
807
807
|
* - catalog_ui_policy_action.catalog_variable uses IO:sys_id format
|
|
808
|
+
* - visible/mandatory/disabled use "ignore" as default, not false or empty
|
|
809
|
+
* - Reference fields are set directly, not via setValue() for reliability
|
|
810
|
+
* - Enhanced verification ensures all critical fields are populated
|
|
808
811
|
*/
|
|
809
812
|
async createCatalogUIPolicy(args) {
|
|
810
813
|
try {
|
|
@@ -1034,39 +1037,56 @@ ${args.help_text ? `❓ Help: ${args.help_text}` : ''}
|
|
|
1034
1037
|
// Actions structure in ServiceNow:
|
|
1035
1038
|
// - catalog_ui_policy_action.catalog_variable -> "IO:" + variable_sys_id (required format)
|
|
1036
1039
|
// - catalog_ui_policy_action.ui_policy -> catalog_ui_policy.sys_id
|
|
1037
|
-
// ✅ CRITICAL
|
|
1038
|
-
//
|
|
1039
|
-
//
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1040
|
+
// ✅ CRITICAL: Build action data according to ServiceNow's exact structure
|
|
1041
|
+
// catalog_ui_policy_action inherits from sys_ui_policy_action
|
|
1042
|
+
// We must set fields in the correct way for ServiceNow to accept them
|
|
1043
|
+
const actionData = {};
|
|
1044
|
+
// STEP 1: Set reference fields (MUST be set first for ServiceNow)
|
|
1045
|
+
// ✅ ui_policy is a reference to sys_ui_policy - use sys_id directly
|
|
1046
|
+
actionData.ui_policy = policyId;
|
|
1047
|
+
// ✅ catalog_item is a reference to sc_cat_item - use sys_id directly
|
|
1048
|
+
actionData.catalog_item = args.cat_item;
|
|
1049
|
+
// STEP 2: Set the catalog_variable with IO: prefix (STRING field, not reference)
|
|
1050
|
+
actionData.catalog_variable = catalogVariableWithPrefix;
|
|
1051
|
+
// STEP 3: Set action properties with correct values
|
|
1052
|
+
// ✅ CRITICAL: Use "ignore" instead of not setting or using false
|
|
1053
|
+
// This is how ServiceNow differentiates between "don't change" and "set to false"
|
|
1054
|
+
if (action.visible !== undefined) {
|
|
1055
|
+
actionData.visible = action.visible === true ? 'true' :
|
|
1056
|
+
action.visible === false ? 'false' : 'ignore';
|
|
1057
|
+
}
|
|
1058
|
+
else {
|
|
1059
|
+
actionData.visible = 'ignore'; // Default to ignore if not specified
|
|
1060
|
+
}
|
|
1054
1061
|
if (action.mandatory !== undefined) {
|
|
1055
|
-
actionData.mandatory = action.mandatory === true ? 'true' :
|
|
1062
|
+
actionData.mandatory = action.mandatory === true ? 'true' :
|
|
1063
|
+
action.mandatory === false ? 'false' : 'ignore';
|
|
1056
1064
|
}
|
|
1057
|
-
|
|
1058
|
-
actionData.
|
|
1065
|
+
else {
|
|
1066
|
+
actionData.mandatory = 'ignore'; // Default to ignore if not specified
|
|
1059
1067
|
}
|
|
1060
1068
|
if (action.readonly !== undefined) {
|
|
1061
|
-
actionData.disabled = action.readonly === true ? 'true' :
|
|
1069
|
+
actionData.disabled = action.readonly === true ? 'true' :
|
|
1070
|
+
action.readonly === false ? 'false' : 'ignore';
|
|
1071
|
+
}
|
|
1072
|
+
else {
|
|
1073
|
+
actionData.disabled = 'ignore'; // Default to ignore if not specified
|
|
1062
1074
|
}
|
|
1063
|
-
|
|
1064
|
-
|
|
1075
|
+
// STEP 4: Set optional value field
|
|
1076
|
+
if (action.value !== undefined && action.value !== null && action.value !== '') {
|
|
1077
|
+
actionData.value = String(action.value);
|
|
1065
1078
|
}
|
|
1066
|
-
//
|
|
1079
|
+
// STEP 5: Set other metadata
|
|
1067
1080
|
actionData.order = (i + 1) * 100;
|
|
1068
1081
|
actionData.active = true;
|
|
1069
|
-
this.logger.info(
|
|
1082
|
+
this.logger.info(`🔗 Creating action with proper structure:`);
|
|
1083
|
+
this.logger.info(` - ui_policy (ref): ${policyId}`);
|
|
1084
|
+
this.logger.info(` - catalog_item (ref): ${args.cat_item}`);
|
|
1085
|
+
this.logger.info(` - catalog_variable: ${catalogVariableWithPrefix}`);
|
|
1086
|
+
this.logger.info(` - visible: ${actionData.visible}`);
|
|
1087
|
+
this.logger.info(` - mandatory: ${actionData.mandatory}`);
|
|
1088
|
+
this.logger.info(` - disabled: ${actionData.disabled}`);
|
|
1089
|
+
this.logger.info(`🎯 Attempting to create action ${i + 1} in catalog_ui_policy_action table...`);
|
|
1070
1090
|
const actionResponse = await this.client.createRecord('catalog_ui_policy_action', actionData);
|
|
1071
1091
|
if (actionResponse.success) {
|
|
1072
1092
|
const createdActionId = actionResponse.data.sys_id;
|
|
@@ -1089,19 +1109,42 @@ ${args.help_text ? `❓ Help: ${args.help_text}` : ''}
|
|
|
1089
1109
|
mandatory: createdAction.mandatory,
|
|
1090
1110
|
disabled: createdAction.disabled
|
|
1091
1111
|
});
|
|
1092
|
-
// Check if critical fields are populated
|
|
1093
|
-
|
|
1112
|
+
// ✅ ENHANCED VERIFICATION: Check if critical fields are populated correctly
|
|
1113
|
+
const uiPolicyValue = createdAction.ui_policy;
|
|
1114
|
+
const catalogVariableValue = createdAction.catalog_variable;
|
|
1115
|
+
const catalogItemValue = createdAction.catalog_item;
|
|
1116
|
+
// Check ui_policy reference
|
|
1117
|
+
if (!uiPolicyValue || uiPolicyValue === '' || uiPolicyValue === '{}') {
|
|
1094
1118
|
this.logger.error(`❌ CRITICAL: ui_policy field is EMPTY for action ${i + 1}!`);
|
|
1119
|
+
this.logger.error(`❌ Expected: ${policyId}, Got: ${uiPolicyValue}`);
|
|
1095
1120
|
throw new Error(`Action ${i + 1} created but ui_policy field is empty - action will not work!`);
|
|
1096
1121
|
}
|
|
1097
|
-
|
|
1122
|
+
// For reference fields, ServiceNow might return an object - extract the value
|
|
1123
|
+
const uiPolicySysId = typeof uiPolicyValue === 'object' && uiPolicyValue.value ?
|
|
1124
|
+
uiPolicyValue.value : uiPolicyValue;
|
|
1125
|
+
if (uiPolicySysId !== policyId) {
|
|
1126
|
+
this.logger.warn(`⚠️ ui_policy mismatch - Expected: ${policyId}, Got: ${uiPolicySysId}`);
|
|
1127
|
+
}
|
|
1128
|
+
// Check catalog_variable (should have IO: prefix)
|
|
1129
|
+
if (!catalogVariableValue || catalogVariableValue === '') {
|
|
1098
1130
|
this.logger.error(`❌ CRITICAL: catalog_variable field is EMPTY for action ${i + 1}!`);
|
|
1131
|
+
this.logger.error(`❌ Expected: ${catalogVariableWithPrefix}, Got: ${catalogVariableValue}`);
|
|
1099
1132
|
throw new Error(`Action ${i + 1} created but catalog_variable field is empty - action will not work!`);
|
|
1100
1133
|
}
|
|
1101
|
-
if (!
|
|
1134
|
+
if (!catalogVariableValue.startsWith('IO:')) {
|
|
1135
|
+
this.logger.warn(`⚠️ catalog_variable missing IO: prefix - Got: ${catalogVariableValue}`);
|
|
1136
|
+
}
|
|
1137
|
+
// Check catalog_item reference
|
|
1138
|
+
if (!catalogItemValue || catalogItemValue === '' || catalogItemValue === '{}') {
|
|
1102
1139
|
this.logger.error(`❌ CRITICAL: catalog_item field is EMPTY for action ${i + 1}!`);
|
|
1140
|
+
this.logger.error(`❌ Expected: ${args.cat_item}, Got: ${catalogItemValue}`);
|
|
1103
1141
|
throw new Error(`Action ${i + 1} created but catalog_item field is empty - action will not work!`);
|
|
1104
1142
|
}
|
|
1143
|
+
const catalogItemSysId = typeof catalogItemValue === 'object' && catalogItemValue.value ?
|
|
1144
|
+
catalogItemValue.value : catalogItemValue;
|
|
1145
|
+
if (catalogItemSysId !== args.cat_item) {
|
|
1146
|
+
this.logger.warn(`⚠️ catalog_item mismatch - Expected: ${args.cat_item}, Got: ${catalogItemSysId}`);
|
|
1147
|
+
}
|
|
1105
1148
|
this.logger.info(`✅ Action ${i + 1} verified in database with all fields populated`);
|
|
1106
1149
|
createdActions.push({
|
|
1107
1150
|
sys_id: createdActionId,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "snow-flow",
|
|
3
|
-
"version": "3.6.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "3.6.20",
|
|
4
|
+
"description": "COMPLETE CATALOG UI POLICY FIX - v3.6.20 implements Snow-Flow's complete analysis: proper parent-child table inheritance (sys_ui_policy_action → catalog_ui_policy_action), direct assignment for references, 'ignore' values for visible/mandatory/disabled, enhanced verification, IO: prefix validation. Based on extensive ServiceNow structure analysis.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"type": "commonjs",
|
|
7
7
|
"bin": {
|