snow-flow 3.6.20 → 3.6.21

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.
@@ -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: sys_ui_policy and catalog_ui_policy_action
800
+ * Creates records in 2 tables: catalog_ui_policy and catalog_ui_policy_action
801
801
  *
802
- * ✅ FINAL CORRECT STRUCTURE (v3.6.20):
803
- * - Main policy goes in sys_ui_policy table (NOT catalog_ui_policy!)
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 sys_ui_policy via ui_policy field (using policy sys_id directly)
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, not via setValue() for reliability
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 sys_ui_policy table, NOT catalog_ui_policy!
985
- // The actions reference sys_ui_policy, not catalog_ui_policy
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
- // sys_ui_policy fields are different from catalog_ui_policy!
988
- name: args.short_description, // sys_ui_policy uses 'name' not 'short_description'
989
- table: 'sc_cat_item', // The table this policy applies to
990
- conditions: conditionString || args.condition || '', // Condition string
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
- on_load: args.on_load !== false, // Different field name in sys_ui_policy
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 sys_ui_policy table with data:', policyData);
1001
- const policyResponse = await this.client.createRecord('sys_ui_policy', policyData);
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}`);
@@ -1166,27 +1165,27 @@ ${args.help_text ? `❓ Help: ${args.help_text}` : ''}
1166
1165
  }
1167
1166
  }
1168
1167
  }
1169
- // 🔍 FINAL VERIFICATION: Policy creation in sys_ui_policy table
1170
- this.logger.info('🔍 Final verification: Checking policy in sys_ui_policy table...');
1171
- const policyVerification = await this.client.searchRecords('sys_ui_policy', `sys_id=${policyId}`, 1);
1168
+ // 🔍 FINAL VERIFICATION: Policy creation in catalog_ui_policy table
1169
+ this.logger.info('🔍 Final verification: Checking policy in catalog_ui_policy table...');
1170
+ const policyVerification = await this.client.searchRecords('catalog_ui_policy', `sys_id=${policyId}`, 1);
1172
1171
  if (!policyVerification.success || policyVerification.data.result.length === 0) {
1173
- this.logger.error('❌ POLICY VERIFICATION FAILED: Policy not found in sys_ui_policy table!');
1174
- throw new Error(`Policy creation verification failed - policy not found in sys_ui_policy table`);
1172
+ this.logger.error('❌ POLICY VERIFICATION FAILED: Policy not found in catalog_ui_policy table!');
1173
+ throw new Error(`Policy creation verification failed - policy not found in catalog_ui_policy table`);
1175
1174
  }
1176
- this.logger.info('✅ Policy verified in sys_ui_policy table');
1175
+ this.logger.info('✅ Policy verified in catalog_ui_policy table');
1177
1176
  // Build comprehensive response
1178
- let responseText = `✅ UI Policy created successfully in sys_ui_policy table!
1177
+ let responseText = `✅ Catalog UI Policy created successfully!
1179
1178
 
1180
1179
  📋 **${args.short_description}**
1181
1180
  🆔 Policy sys_id: ${policyId}
1182
- 📊 Table: sys_ui_policy (correct table for catalog UI policy actions)
1183
- 🎯 Target Table: sc_cat_item
1181
+ 📊 Table: catalog_ui_policy (correct table for catalog actions)
1182
+ 🎯 Catalog Item: ${args.cat_item}
1184
1183
  🔄 Active: ${args.active !== false ? 'Yes' : 'No'}
1185
- ⚡ On Load: ${args.on_load !== false ? 'Yes' : 'No'}
1184
+ Applies On: ${args.applies_on || 'true'}
1186
1185
  🔁 Reverse if False: ${args.reverse_if_false !== false ? 'Yes' : 'No'}
1187
1186
 
1188
1187
  🔍 **Verification Results:**
1189
- ✅ Policy record created in sys_ui_policy table
1188
+ ✅ Policy record created in catalog_ui_policy table
1190
1189
  ✅ ${createdActions.length} actions created in catalog_ui_policy_action table`;
1191
1190
  if (conditionString) {
1192
1191
  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.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.",
3
+ "version": "3.6.21",
4
+ "description": "CRITICAL TABLE FIX - v3.6.21 fixes fundamental issue: policies now created in catalog_ui_policy table (NOT sys_ui_policy!). Actions correctly reference catalog_ui_policy records. This matches ServiceNow's actual structure where catalog_ui_policy_action.ui_policy references catalog_ui_policy table, not sys_ui_policy.",
5
5
  "main": "dist/index.js",
6
6
  "type": "commonjs",
7
7
  "bin": {