snow-flow 3.6.21 â 3.6.23
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.
package/dist/dynamic-version.js
CHANGED
|
@@ -36,7 +36,7 @@ function getDynamicVersion() {
|
|
|
36
36
|
console.warn('Warning: Could not read version from package.json:', error);
|
|
37
37
|
}
|
|
38
38
|
// Fallback to hardcoded version
|
|
39
|
-
return '3.
|
|
39
|
+
return '3.6.23';
|
|
40
40
|
}
|
|
41
41
|
// Export a constant that uses the dynamic version
|
|
42
42
|
exports.VERSION = getDynamicVersion();
|
|
@@ -752,8 +752,8 @@ ${args.recurring_price && args.recurring_price !== '0' ? `đ Recurring: $${arg
|
|
|
752
752
|
tooltip: args.tooltip || ''
|
|
753
753
|
};
|
|
754
754
|
this.logger.info('đ¯ Creating variable with payload:', variableData);
|
|
755
|
-
// â
|
|
756
|
-
const response = await this.client.createRecord('
|
|
755
|
+
// â
FIXED TABLE NAME: Use item_option_new (the correct table for catalog variables)
|
|
756
|
+
const response = await this.client.createRecord('item_option_new', variableData);
|
|
757
757
|
if (!response.success) {
|
|
758
758
|
this.logger.error('â Variable creation failed:', {
|
|
759
759
|
error: response.error,
|
|
@@ -766,7 +766,7 @@ ${args.recurring_price && args.recurring_price !== '0' ? `đ Recurring: $${arg
|
|
|
766
766
|
this.logger.info(`â
Variable created with sys_id: ${createdSysId}`);
|
|
767
767
|
// đ VERIFICATION: Check if variable was actually created
|
|
768
768
|
this.logger.info('đ Verifying variable creation...');
|
|
769
|
-
const verification = await this.client.searchRecords('
|
|
769
|
+
const verification = await this.client.searchRecords('item_option_new', `sys_id=${createdSysId}`, 1);
|
|
770
770
|
if (!verification.success || verification.data.result.length === 0) {
|
|
771
771
|
this.logger.error('â VERIFICATION FAILED: Variable not found after creation!');
|
|
772
772
|
throw new Error(`Variable creation verification failed - not found in database`);
|
|
@@ -1040,14 +1040,39 @@ ${args.help_text ? `â Help: ${args.help_text}` : ''}
|
|
|
1040
1040
|
// catalog_ui_policy_action inherits from sys_ui_policy_action
|
|
1041
1041
|
// We must set fields in the correct way for ServiceNow to accept them
|
|
1042
1042
|
const actionData = {};
|
|
1043
|
-
// STEP 1:
|
|
1044
|
-
|
|
1043
|
+
// STEP 1: ENHANCED VERIFICATION - Verify policy exists before creating actions
|
|
1044
|
+
this.logger.info(`đ ENHANCED DEBUG: Verifying policy ${policyId} exists before creating action...`);
|
|
1045
|
+
if (!policyId) {
|
|
1046
|
+
this.logger.error(`â CRITICAL: No policyId available for action ${i + 1}!`);
|
|
1047
|
+
throw new Error(`Cannot create action without valid policy ID`);
|
|
1048
|
+
}
|
|
1049
|
+
// â
NEW: Test policy existence before action creation
|
|
1050
|
+
const policyExists = await this.client.searchRecords('catalog_ui_policy', `sys_id=${policyId}`, 1);
|
|
1051
|
+
if (!policyExists.success || policyExists.data.result.length === 0) {
|
|
1052
|
+
this.logger.error(`â CRITICAL: Policy ${policyId} does not exist in catalog_ui_policy table!`);
|
|
1053
|
+
throw new Error(`Policy verification failed - cannot create action without valid policy`);
|
|
1054
|
+
}
|
|
1055
|
+
const existingPolicy = policyExists.data.result[0];
|
|
1056
|
+
this.logger.info(`â
Policy verification successful:`);
|
|
1057
|
+
this.logger.info(` - Policy sys_id: ${existingPolicy.sys_id}`);
|
|
1058
|
+
this.logger.info(` - Policy name: ${existingPolicy.short_description || 'N/A'}`);
|
|
1059
|
+
this.logger.info(` - Policy active: ${existingPolicy.active}`);
|
|
1060
|
+
// STEP 2: Set reference fields with enhanced validation
|
|
1061
|
+
// â
ui_policy is a reference to catalog_ui_policy - test multiple formats
|
|
1062
|
+
this.logger.info(`đ Setting ui_policy reference to: ${policyId}`);
|
|
1063
|
+
// Try setting the reference in the most explicit way possible
|
|
1045
1064
|
actionData.ui_policy = policyId;
|
|
1046
1065
|
// â
catalog_item is a reference to sc_cat_item - use sys_id directly
|
|
1066
|
+
if (!args.cat_item) {
|
|
1067
|
+
this.logger.error(`â CRITICAL: No catalog item ID provided!`);
|
|
1068
|
+
throw new Error(`Cannot create action without catalog item ID`);
|
|
1069
|
+
}
|
|
1070
|
+
this.logger.info(`đ Setting catalog_item reference to: ${args.cat_item}`);
|
|
1047
1071
|
actionData.catalog_item = args.cat_item;
|
|
1048
|
-
// STEP
|
|
1072
|
+
// STEP 3: Set the catalog_variable with IO: prefix (STRING field, not reference)
|
|
1073
|
+
this.logger.info(`đ Setting catalog_variable to: ${catalogVariableWithPrefix}`);
|
|
1049
1074
|
actionData.catalog_variable = catalogVariableWithPrefix;
|
|
1050
|
-
// STEP
|
|
1075
|
+
// STEP 4: Set action properties with correct values
|
|
1051
1076
|
// â
CRITICAL: Use "ignore" instead of not setting or using false
|
|
1052
1077
|
// This is how ServiceNow differentiates between "don't change" and "set to false"
|
|
1053
1078
|
if (action.visible !== undefined) {
|
|
@@ -1071,20 +1096,22 @@ ${args.help_text ? `â Help: ${args.help_text}` : ''}
|
|
|
1071
1096
|
else {
|
|
1072
1097
|
actionData.disabled = 'ignore'; // Default to ignore if not specified
|
|
1073
1098
|
}
|
|
1074
|
-
// STEP
|
|
1099
|
+
// STEP 5: Set optional value field
|
|
1075
1100
|
if (action.value !== undefined && action.value !== null && action.value !== '') {
|
|
1076
1101
|
actionData.value = String(action.value);
|
|
1077
1102
|
}
|
|
1078
|
-
// STEP
|
|
1103
|
+
// STEP 6: Set other metadata
|
|
1079
1104
|
actionData.order = (i + 1) * 100;
|
|
1080
1105
|
actionData.active = true;
|
|
1081
|
-
this.logger.info(`đ Creating action with
|
|
1082
|
-
this.logger.info(` - ui_policy (ref): ${policyId}`);
|
|
1106
|
+
this.logger.info(`đ Creating action with VALIDATED structure:`);
|
|
1107
|
+
this.logger.info(` - ui_policy (ref): ${policyId} [VERIFIED EXISTS]`);
|
|
1083
1108
|
this.logger.info(` - catalog_item (ref): ${args.cat_item}`);
|
|
1084
1109
|
this.logger.info(` - catalog_variable: ${catalogVariableWithPrefix}`);
|
|
1085
1110
|
this.logger.info(` - visible: ${actionData.visible}`);
|
|
1086
1111
|
this.logger.info(` - mandatory: ${actionData.mandatory}`);
|
|
1087
1112
|
this.logger.info(` - disabled: ${actionData.disabled}`);
|
|
1113
|
+
// â
ENHANCED DEBUG: Log complete action data being sent
|
|
1114
|
+
this.logger.info(`đ Complete action data being sent to ServiceNow:`, JSON.stringify(actionData, null, 2));
|
|
1088
1115
|
this.logger.info(`đ¯ Attempting to create action ${i + 1} in catalog_ui_policy_action table...`);
|
|
1089
1116
|
const actionResponse = await this.client.createRecord('catalog_ui_policy_action', actionData);
|
|
1090
1117
|
if (actionResponse.success) {
|
|
@@ -1112,18 +1139,55 @@ ${args.help_text ? `â Help: ${args.help_text}` : ''}
|
|
|
1112
1139
|
const uiPolicyValue = createdAction.ui_policy;
|
|
1113
1140
|
const catalogVariableValue = createdAction.catalog_variable;
|
|
1114
1141
|
const catalogItemValue = createdAction.catalog_item;
|
|
1115
|
-
//
|
|
1116
|
-
|
|
1142
|
+
// Log the raw response to understand what ServiceNow returns
|
|
1143
|
+
this.logger.info(`đ Raw action verification response:`, JSON.stringify(createdAction, null, 2));
|
|
1144
|
+
// Check ui_policy reference - ServiceNow might return it as an object
|
|
1145
|
+
let actualUiPolicyId = uiPolicyValue;
|
|
1146
|
+
if (typeof uiPolicyValue === 'object' && uiPolicyValue !== null) {
|
|
1147
|
+
actualUiPolicyId = uiPolicyValue.value || uiPolicyValue.sys_id || '';
|
|
1148
|
+
this.logger.info(`đ ui_policy returned as object: ${JSON.stringify(uiPolicyValue)}`);
|
|
1149
|
+
}
|
|
1150
|
+
if (!actualUiPolicyId || actualUiPolicyId === '' || actualUiPolicyId === '{}') {
|
|
1117
1151
|
this.logger.error(`â CRITICAL: ui_policy field is EMPTY for action ${i + 1}!`);
|
|
1118
|
-
this.logger.error(`â Expected
|
|
1119
|
-
|
|
1152
|
+
this.logger.error(`â Expected policy ID: ${policyId}`);
|
|
1153
|
+
this.logger.error(`â Raw ui_policy value: ${JSON.stringify(uiPolicyValue)}`);
|
|
1154
|
+
this.logger.error(`â Parsed ui_policy value: ${actualUiPolicyId}`);
|
|
1155
|
+
this.logger.error(`â Action data sent:`, JSON.stringify(actionData, null, 2));
|
|
1156
|
+
this.logger.error(`â Full action verification response:`, JSON.stringify(createdAction, null, 2));
|
|
1157
|
+
// â
ENHANCED ERROR: Try to understand ServiceNow's response pattern
|
|
1158
|
+
this.logger.error(`âšī¸ DIAGNOSTIC INFO:`);
|
|
1159
|
+
this.logger.error(` - Policy verified to exist: YES (${policyId})`);
|
|
1160
|
+
this.logger.error(` - Action created successfully: YES (${createdActionId})`);
|
|
1161
|
+
this.logger.error(` - ui_policy field type: ${typeof uiPolicyValue}`);
|
|
1162
|
+
this.logger.error(` - ui_policy field value length: ${String(uiPolicyValue || '').length}`);
|
|
1163
|
+
this.logger.error(` - All action fields:`, Object.keys(createdAction));
|
|
1164
|
+
// Check if it's a ServiceNow API timing issue
|
|
1165
|
+
this.logger.warn(`đ ATTEMPTING SECONDARY VERIFICATION (possible timing issue)...`);
|
|
1166
|
+
// Wait a moment and try again
|
|
1167
|
+
await new Promise(resolve => setTimeout(resolve, 1000));
|
|
1168
|
+
const secondVerification = await this.client.searchRecords('catalog_ui_policy_action', `sys_id=${createdActionId}`, 1);
|
|
1169
|
+
if (secondVerification.success && secondVerification.data.result.length > 0) {
|
|
1170
|
+
const reCheckedAction = secondVerification.data.result[0];
|
|
1171
|
+
const reCheckedUiPolicy = reCheckedAction.ui_policy;
|
|
1172
|
+
this.logger.error(`đ Secondary verification ui_policy: ${JSON.stringify(reCheckedUiPolicy)}`);
|
|
1173
|
+
if (reCheckedUiPolicy && reCheckedUiPolicy !== '' && reCheckedUiPolicy !== '{}') {
|
|
1174
|
+
this.logger.warn(`â ī¸ This was a timing issue - ui_policy populated after delay`);
|
|
1175
|
+
// Continue with the re-checked value
|
|
1176
|
+
return; // Skip the error throwing
|
|
1177
|
+
}
|
|
1178
|
+
}
|
|
1179
|
+
throw new Error(`Action ${i + 1} created but ui_policy field is empty - action will not work! This may be a ServiceNow API or table structure issue.`);
|
|
1120
1180
|
}
|
|
1121
1181
|
// For reference fields, ServiceNow might return an object - extract the value
|
|
1122
1182
|
const uiPolicySysId = typeof uiPolicyValue === 'object' && uiPolicyValue.value ?
|
|
1123
1183
|
uiPolicyValue.value : uiPolicyValue;
|
|
1184
|
+
this.logger.info(`â
ui_policy field populated successfully: ${actualUiPolicyId}`);
|
|
1124
1185
|
if (uiPolicySysId !== policyId) {
|
|
1125
1186
|
this.logger.warn(`â ī¸ ui_policy mismatch - Expected: ${policyId}, Got: ${uiPolicySysId}`);
|
|
1126
1187
|
}
|
|
1188
|
+
else {
|
|
1189
|
+
this.logger.info(`â
ui_policy reference matches expected value`);
|
|
1190
|
+
}
|
|
1127
1191
|
// Check catalog_variable (should have IO: prefix)
|
|
1128
1192
|
if (!catalogVariableValue || catalogVariableValue === '') {
|
|
1129
1193
|
this.logger.error(`â CRITICAL: catalog_variable field is EMPTY for action ${i + 1}!`);
|
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.23",
|
|
4
|
+
"description": "CATALOG VARIABLE TABLE FIX - v3.6.23 fixes critical issue: catalog variables now created in correct table 'item_option_new' instead of wrong table 'sc_cat_item_option'. This ensures variables are actually visible and functional in catalog items.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"type": "commonjs",
|
|
7
7
|
"bin": {
|