snow-flow 3.6.18 → 3.6.19

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.
@@ -1034,21 +1034,22 @@ ${args.help_text ? `❓ Help: ${args.help_text}` : ''}
1034
1034
  // Actions structure in ServiceNow:
1035
1035
  // - catalog_ui_policy_action.catalog_variable -> "IO:" + variable_sys_id (required format)
1036
1036
  // - catalog_ui_policy_action.ui_policy -> catalog_ui_policy.sys_id
1037
+ // ✅ CRITICAL FIX: Reference fields MUST be objects or sys_ids, not names!
1038
+ // ServiceNow reference fields expect either:
1039
+ // 1. Just the sys_id as a string
1040
+ // 2. An object with { value: sys_id, link: url }
1037
1041
  const actionData = {
1038
- // ✅ Main connection: to the variable with required IO: prefix (if valid sys_id)
1039
- catalog_variable: catalogVariableWithPrefix
1042
+ // ✅ catalog_variable uses IO:sys_id format (this is a STRING field, not a reference)
1043
+ catalog_variable: catalogVariableWithPrefix,
1044
+ // ✅ ui_policy is a REFERENCE field - use the sys_id directly!
1045
+ ui_policy: policyId, // Use the policy sys_id from sys_ui_policy
1046
+ // ✅ catalog_item is also a REFERENCE field - use the sys_id
1047
+ catalog_item: args.cat_item // The catalog item sys_id
1040
1048
  };
1041
- // CRITICAL FIX: ui_policy field expects the NAME (short_description), NOT the sys_id!
1042
- // ServiceNow uses the policy name as the reference value
1043
- if (args.short_description) {
1044
- actionData.ui_policy = args.short_description; // ✅ Use the policy NAME, not sys_id!
1045
- this.logger.info(`🔗 Linking action to policy by NAME: "${args.short_description}"`);
1046
- }
1047
- else {
1048
- // Fallback if somehow we don't have the name
1049
- this.logger.error(`❌ CRITICAL: No policy name (short_description) available for linking!`);
1050
- actionData.ui_policy = policyId; // Use sys_id as last resort
1051
- }
1049
+ this.logger.info(`🔗 Linking action to:`);
1050
+ this.logger.info(` - Policy: ${policyId} (sys_ui_policy sys_id)`);
1051
+ this.logger.info(` - Variable: ${catalogVariableWithPrefix} (with IO: prefix)`);
1052
+ this.logger.info(` - Catalog Item: ${args.cat_item}`);
1052
1053
  // Voeg alleen GEDEFINIEERDE action properties toe
1053
1054
  if (action.mandatory !== undefined) {
1054
1055
  actionData.mandatory = action.mandatory === true ? 'true' : action.mandatory === false ? 'false' : 'ignore';
@@ -1070,14 +1071,38 @@ ${args.help_text ? `❓ Help: ${args.help_text}` : ''}
1070
1071
  if (actionResponse.success) {
1071
1072
  const createdActionId = actionResponse.data.sys_id;
1072
1073
  this.logger.info(`✅ Created action with sys_id: ${createdActionId}`);
1073
- // 🔍 VERIFICATION: Check if action was actually created
1074
- this.logger.info(`🔍 Verifying action ${i + 1} creation...`);
1074
+ // 🔍 VERIFICATION: Check if action was actually created AND fields are populated
1075
+ this.logger.info(`🔍 Verifying action ${i + 1} creation and field population...`);
1075
1076
  const actionVerification = await this.client.searchRecords('catalog_ui_policy_action', `sys_id=${createdActionId}`, 1);
1076
1077
  if (!actionVerification.success || actionVerification.data.result.length === 0) {
1077
1078
  this.logger.error('❌ ACTION VERIFICATION FAILED: Action not found after creation!');
1078
1079
  throw new Error(`Action creation verification failed - action ${i + 1} not found in database`);
1079
1080
  }
1080
- this.logger.info(`✅ Action ${i + 1} verified in database`);
1081
+ // NEW: Verify that critical fields are actually populated
1082
+ const createdAction = actionVerification.data.result[0];
1083
+ this.logger.info(`📋 Created action data:`, {
1084
+ sys_id: createdAction.sys_id,
1085
+ ui_policy: createdAction.ui_policy || '❌ EMPTY',
1086
+ catalog_variable: createdAction.catalog_variable || '❌ EMPTY',
1087
+ catalog_item: createdAction.catalog_item || '❌ EMPTY',
1088
+ visible: createdAction.visible,
1089
+ mandatory: createdAction.mandatory,
1090
+ disabled: createdAction.disabled
1091
+ });
1092
+ // Check if critical fields are populated
1093
+ if (!createdAction.ui_policy || createdAction.ui_policy === '') {
1094
+ this.logger.error(`❌ CRITICAL: ui_policy field is EMPTY for action ${i + 1}!`);
1095
+ throw new Error(`Action ${i + 1} created but ui_policy field is empty - action will not work!`);
1096
+ }
1097
+ if (!createdAction.catalog_variable || createdAction.catalog_variable === '') {
1098
+ this.logger.error(`❌ CRITICAL: catalog_variable field is EMPTY for action ${i + 1}!`);
1099
+ throw new Error(`Action ${i + 1} created but catalog_variable field is empty - action will not work!`);
1100
+ }
1101
+ if (!createdAction.catalog_item || createdAction.catalog_item === '') {
1102
+ this.logger.error(`❌ CRITICAL: catalog_item field is EMPTY for action ${i + 1}!`);
1103
+ throw new Error(`Action ${i + 1} created but catalog_item field is empty - action will not work!`);
1104
+ }
1105
+ this.logger.info(`✅ Action ${i + 1} verified in database with all fields populated`);
1081
1106
  createdActions.push({
1082
1107
  sys_id: createdActionId,
1083
1108
  variable: action.catalog_variable,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "snow-flow",
3
- "version": "3.6.18",
4
- "description": "FUNDAMENTAL TABLE FIX - v3.6.18 corrects critical table structure: policies now created in sys_ui_policy (NOT catalog_ui_policy), conditions use IO:sys_id format, actions properly link to sys_ui_policy. This matches ServiceNow's actual catalog UI policy structure where catalog_ui_policy_action references sys_ui_policy, not catalog_ui_policy.",
3
+ "version": "3.6.19",
4
+ "description": "CRITICAL REFERENCE FIELD FIX - v3.6.19 fixes empty action fields by using sys_ids directly for reference fields (ui_policy, catalog_item) instead of names/objects. Added comprehensive verification to ensure all critical fields are populated. Actions now correctly link to sys_ui_policy with actual sys_id values, not empty strings.",
5
5
  "main": "dist/index.js",
6
6
  "type": "commonjs",
7
7
  "bin": {