snow-flow 3.6.20 ā 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`);
|
|
@@ -797,16 +797,16 @@ ${args.help_text ? `ā Help: ${args.help_text}` : ''}
|
|
|
797
797
|
}
|
|
798
798
|
/**
|
|
799
799
|
* Create Catalog UI Policy with Actions
|
|
800
|
-
* Creates records in 2 tables:
|
|
800
|
+
* Creates records in 2 tables: catalog_ui_policy and catalog_ui_policy_action
|
|
801
801
|
*
|
|
802
|
-
* ā
|
|
803
|
-
* - Main policy goes in
|
|
802
|
+
* ā
CORRECTED STRUCTURE (v3.6.21):
|
|
803
|
+
* - Main policy goes in catalog_ui_policy table (NOT sys_ui_policy!)
|
|
804
804
|
* - Actions go in catalog_ui_policy_action table (inherits from sys_ui_policy_action)
|
|
805
|
-
* - Actions reference
|
|
805
|
+
* - Actions reference catalog_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
808
|
* - visible/mandatory/disabled use "ignore" as default, not false or empty
|
|
809
|
-
* - Reference fields are set directly
|
|
809
|
+
* - Reference fields are set directly for reliability
|
|
810
810
|
* - Enhanced verification ensures all critical fields are populated
|
|
811
811
|
*/
|
|
812
812
|
async createCatalogUIPolicy(args) {
|
|
@@ -981,24 +981,23 @@ ${args.help_text ? `ā Help: ${args.help_text}` : ''}
|
|
|
981
981
|
conditionString = conditionParts.join('^');
|
|
982
982
|
this.logger.info(`ā
Built conditions string: "${conditionString}"`);
|
|
983
983
|
}
|
|
984
|
-
// ā
CRITICAL FIX: Create in
|
|
985
|
-
// The actions reference
|
|
984
|
+
// ā
CRITICAL FIX: Create in catalog_ui_policy table!
|
|
985
|
+
// The actions reference catalog_ui_policy, NOT sys_ui_policy!
|
|
986
986
|
const policyData = {
|
|
987
|
-
//
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
987
|
+
// catalog_ui_policy fields
|
|
988
|
+
short_description: args.short_description,
|
|
989
|
+
catalog_item: args.cat_item, // Reference to the catalog item
|
|
990
|
+
catalog_conditions: conditionString || args.condition || '', // Conditions as string
|
|
991
|
+
applies_catalog: true, // This is a catalog policy
|
|
991
992
|
active: args.active !== false,
|
|
992
|
-
|
|
993
|
+
applies_on: args.applies_on || 'true', // When to apply: 'true', 'false', or 'both'
|
|
993
994
|
reverse_if_false: args.reverse_if_false !== false,
|
|
994
|
-
// Link to the catalog item via a different field
|
|
995
|
-
catalog_item: args.cat_item,
|
|
996
995
|
// Optional script fields
|
|
997
996
|
script_true: args.script_true || '',
|
|
998
997
|
script_false: args.script_false || ''
|
|
999
998
|
};
|
|
1000
|
-
this.logger.info('šÆ Creating main policy in
|
|
1001
|
-
const policyResponse = await this.client.createRecord('
|
|
999
|
+
this.logger.info('šÆ Creating main policy in catalog_ui_policy table with data:', policyData);
|
|
1000
|
+
const policyResponse = await this.client.createRecord('catalog_ui_policy', policyData);
|
|
1002
1001
|
if (!policyResponse.success) {
|
|
1003
1002
|
this.logger.error('ā Policy creation failed:', policyResponse.error);
|
|
1004
1003
|
throw new Error(`Failed to create catalog UI policy: ${policyResponse.error}`);
|
|
@@ -1041,14 +1040,39 @@ ${args.help_text ? `ā Help: ${args.help_text}` : ''}
|
|
|
1041
1040
|
// catalog_ui_policy_action inherits from sys_ui_policy_action
|
|
1042
1041
|
// We must set fields in the correct way for ServiceNow to accept them
|
|
1043
1042
|
const actionData = {};
|
|
1044
|
-
// STEP 1:
|
|
1045
|
-
|
|
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
|
|
1046
1064
|
actionData.ui_policy = policyId;
|
|
1047
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}`);
|
|
1048
1071
|
actionData.catalog_item = args.cat_item;
|
|
1049
|
-
// STEP
|
|
1072
|
+
// STEP 3: Set the catalog_variable with IO: prefix (STRING field, not reference)
|
|
1073
|
+
this.logger.info(`š Setting catalog_variable to: ${catalogVariableWithPrefix}`);
|
|
1050
1074
|
actionData.catalog_variable = catalogVariableWithPrefix;
|
|
1051
|
-
// STEP
|
|
1075
|
+
// STEP 4: Set action properties with correct values
|
|
1052
1076
|
// ā
CRITICAL: Use "ignore" instead of not setting or using false
|
|
1053
1077
|
// This is how ServiceNow differentiates between "don't change" and "set to false"
|
|
1054
1078
|
if (action.visible !== undefined) {
|
|
@@ -1072,20 +1096,22 @@ ${args.help_text ? `ā Help: ${args.help_text}` : ''}
|
|
|
1072
1096
|
else {
|
|
1073
1097
|
actionData.disabled = 'ignore'; // Default to ignore if not specified
|
|
1074
1098
|
}
|
|
1075
|
-
// STEP
|
|
1099
|
+
// STEP 5: Set optional value field
|
|
1076
1100
|
if (action.value !== undefined && action.value !== null && action.value !== '') {
|
|
1077
1101
|
actionData.value = String(action.value);
|
|
1078
1102
|
}
|
|
1079
|
-
// STEP
|
|
1103
|
+
// STEP 6: Set other metadata
|
|
1080
1104
|
actionData.order = (i + 1) * 100;
|
|
1081
1105
|
actionData.active = true;
|
|
1082
|
-
this.logger.info(`š Creating action with
|
|
1083
|
-
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]`);
|
|
1084
1108
|
this.logger.info(` - catalog_item (ref): ${args.cat_item}`);
|
|
1085
1109
|
this.logger.info(` - catalog_variable: ${catalogVariableWithPrefix}`);
|
|
1086
1110
|
this.logger.info(` - visible: ${actionData.visible}`);
|
|
1087
1111
|
this.logger.info(` - mandatory: ${actionData.mandatory}`);
|
|
1088
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));
|
|
1089
1115
|
this.logger.info(`šÆ Attempting to create action ${i + 1} in catalog_ui_policy_action table...`);
|
|
1090
1116
|
const actionResponse = await this.client.createRecord('catalog_ui_policy_action', actionData);
|
|
1091
1117
|
if (actionResponse.success) {
|
|
@@ -1113,18 +1139,55 @@ ${args.help_text ? `ā Help: ${args.help_text}` : ''}
|
|
|
1113
1139
|
const uiPolicyValue = createdAction.ui_policy;
|
|
1114
1140
|
const catalogVariableValue = createdAction.catalog_variable;
|
|
1115
1141
|
const catalogItemValue = createdAction.catalog_item;
|
|
1116
|
-
//
|
|
1117
|
-
|
|
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 === '{}') {
|
|
1118
1151
|
this.logger.error(`ā CRITICAL: ui_policy field is EMPTY for action ${i + 1}!`);
|
|
1119
|
-
this.logger.error(`ā Expected
|
|
1120
|
-
|
|
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.`);
|
|
1121
1180
|
}
|
|
1122
1181
|
// For reference fields, ServiceNow might return an object - extract the value
|
|
1123
1182
|
const uiPolicySysId = typeof uiPolicyValue === 'object' && uiPolicyValue.value ?
|
|
1124
1183
|
uiPolicyValue.value : uiPolicyValue;
|
|
1184
|
+
this.logger.info(`ā
ui_policy field populated successfully: ${actualUiPolicyId}`);
|
|
1125
1185
|
if (uiPolicySysId !== policyId) {
|
|
1126
1186
|
this.logger.warn(`ā ļø ui_policy mismatch - Expected: ${policyId}, Got: ${uiPolicySysId}`);
|
|
1127
1187
|
}
|
|
1188
|
+
else {
|
|
1189
|
+
this.logger.info(`ā
ui_policy reference matches expected value`);
|
|
1190
|
+
}
|
|
1128
1191
|
// Check catalog_variable (should have IO: prefix)
|
|
1129
1192
|
if (!catalogVariableValue || catalogVariableValue === '') {
|
|
1130
1193
|
this.logger.error(`ā CRITICAL: catalog_variable field is EMPTY for action ${i + 1}!`);
|
|
@@ -1166,27 +1229,27 @@ ${args.help_text ? `ā Help: ${args.help_text}` : ''}
|
|
|
1166
1229
|
}
|
|
1167
1230
|
}
|
|
1168
1231
|
}
|
|
1169
|
-
// š FINAL VERIFICATION: Policy creation in
|
|
1170
|
-
this.logger.info('š Final verification: Checking policy in
|
|
1171
|
-
const policyVerification = await this.client.searchRecords('
|
|
1232
|
+
// š FINAL VERIFICATION: Policy creation in catalog_ui_policy table
|
|
1233
|
+
this.logger.info('š Final verification: Checking policy in catalog_ui_policy table...');
|
|
1234
|
+
const policyVerification = await this.client.searchRecords('catalog_ui_policy', `sys_id=${policyId}`, 1);
|
|
1172
1235
|
if (!policyVerification.success || policyVerification.data.result.length === 0) {
|
|
1173
|
-
this.logger.error('ā POLICY VERIFICATION FAILED: Policy not found in
|
|
1174
|
-
throw new Error(`Policy creation verification failed - policy not found in
|
|
1236
|
+
this.logger.error('ā POLICY VERIFICATION FAILED: Policy not found in catalog_ui_policy table!');
|
|
1237
|
+
throw new Error(`Policy creation verification failed - policy not found in catalog_ui_policy table`);
|
|
1175
1238
|
}
|
|
1176
|
-
this.logger.info('ā
Policy verified in
|
|
1239
|
+
this.logger.info('ā
Policy verified in catalog_ui_policy table');
|
|
1177
1240
|
// Build comprehensive response
|
|
1178
|
-
let responseText = `ā
UI Policy created successfully
|
|
1241
|
+
let responseText = `ā
Catalog UI Policy created successfully!
|
|
1179
1242
|
|
|
1180
1243
|
š **${args.short_description}**
|
|
1181
1244
|
š Policy sys_id: ${policyId}
|
|
1182
|
-
š Table:
|
|
1183
|
-
šÆ
|
|
1245
|
+
š Table: catalog_ui_policy (correct table for catalog actions)
|
|
1246
|
+
šÆ Catalog Item: ${args.cat_item}
|
|
1184
1247
|
š Active: ${args.active !== false ? 'Yes' : 'No'}
|
|
1185
|
-
ā” On
|
|
1248
|
+
ā” Applies On: ${args.applies_on || 'true'}
|
|
1186
1249
|
š Reverse if False: ${args.reverse_if_false !== false ? 'Yes' : 'No'}
|
|
1187
1250
|
|
|
1188
1251
|
š **Verification Results:**
|
|
1189
|
-
ā
Policy record created in
|
|
1252
|
+
ā
Policy record created in catalog_ui_policy table
|
|
1190
1253
|
ā
${createdActions.length} actions created in catalog_ui_policy_action table`;
|
|
1191
1254
|
if (conditionString) {
|
|
1192
1255
|
responseText += `\n\nš **Conditions:**\n${conditionString}`;
|
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": {
|