snow-flow 3.6.12 β†’ 3.6.13

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.
@@ -792,7 +792,14 @@ ${args.help_text ? `❓ Help: ${args.help_text}` : ''}
792
792
  };
793
793
  // Build condition string from conditions array
794
794
  let conditionString = '';
795
+ this.logger.info('Checking conditions parameter:', {
796
+ hasConditions: !!args.conditions,
797
+ isArray: Array.isArray(args.conditions),
798
+ length: args.conditions ? args.conditions.length : 0,
799
+ conditionsData: args.conditions
800
+ });
795
801
  if (args.conditions && Array.isArray(args.conditions)) {
802
+ this.logger.info(`🎯 Building conditions string from ${args.conditions.length} conditions...`);
796
803
  const conditionParts = [];
797
804
  for (const condition of args.conditions) {
798
805
  // Resolve variable name to sys_id
@@ -840,8 +847,9 @@ ${args.help_text ? `❓ Help: ${args.help_text}` : ''}
840
847
  }
841
848
  conditionParts.push(conditionPart);
842
849
  }
843
- // Join all conditions
844
- conditionString = conditionParts.join('');
850
+ // Join all conditions with ^ separator (ServiceNow query format)
851
+ conditionString = conditionParts.join('^');
852
+ this.logger.info(`βœ… Built conditions string: "${conditionString}"`);
845
853
  }
846
854
  // Step 1: Create main catalog UI policy record with embedded conditions
847
855
  const policyData = {
@@ -856,40 +864,62 @@ ${args.help_text ? `❓ Help: ${args.help_text}` : ''}
856
864
  script_true: args.script_true || '',
857
865
  script_false: args.script_false || ''
858
866
  };
867
+ this.logger.info('🎯 Creating main policy with data:', policyData);
859
868
  const policyResponse = await this.client.createRecord('catalog_ui_policy', policyData);
860
869
  if (!policyResponse.success) {
870
+ this.logger.error('❌ Policy creation failed:', policyResponse.error);
861
871
  throw new Error(`Failed to create catalog UI policy: ${policyResponse.error}`);
862
872
  }
863
873
  const policyId = policyResponse.data.sys_id;
864
- this.logger.info(`Created main policy with sys_id: ${policyId}`);
874
+ this.logger.info(`βœ… Created main policy with sys_id: ${policyId}`);
865
875
  const createdActions = [];
866
876
  // Step 2: Create action records (dit werkt wel met aparte tabel)
877
+ this.logger.info('Checking actions parameter:', {
878
+ hasActions: !!args.actions,
879
+ isArray: Array.isArray(args.actions),
880
+ length: args.actions ? args.actions.length : 0,
881
+ actionsData: args.actions
882
+ });
867
883
  if (args.actions && Array.isArray(args.actions)) {
868
- this.logger.info(`Creating ${args.actions.length} action records...`);
884
+ this.logger.info(`🎯 Starting to create ${args.actions.length} action records...`);
869
885
  for (let i = 0; i < args.actions.length; i++) {
870
886
  const action = args.actions[i];
871
887
  // Resolve variable name to sys_id
888
+ this.logger.info(`πŸ” Resolving variable: ${action.catalog_variable} for catalog item: ${args.cat_item}`);
872
889
  const variableId = await resolveVariableId(action.catalog_variable, args.cat_item);
890
+ this.logger.info(`βœ… Resolved to variable ID: ${variableId}`);
873
891
  // Actions structuur in ServiceNow:
874
892
  // - catalog_ui_policy_action.catalog_variable -> item_option_new (variable)
875
893
  // - item_option_new.cat_item -> sc_cat_item (catalog item)
876
894
  // - catalog_ui_policy.catalog_item -> sc_cat_item (catalog item)
877
895
  // Mogelijk is er toch een ui_policy veld, maar het lijkt niet verplicht
896
+ // MINIMAAL: Probeer eerst alleen de essentiΓ«le velden
878
897
  const actionData = {
879
- // Primaire koppeling: naar de variable
880
- catalog_variable: variableId, // Verplicht: koppeling naar variable
881
- // Mogelijk ook een policy koppeling (als het veld bestaat)
882
- ui_policy: policyId, // Probeer dit ook, kan optioneel zijn
883
- // Action settings - gebruik strings zoals ServiceNow verwacht
884
- mandatory: action.mandatory === true ? 'true' : action.mandatory === false ? 'false' : 'ignore',
885
- visible: action.visible === false ? 'false' : action.visible === true ? 'true' : 'ignore',
886
- disabled: action.readonly === true ? 'true' : action.readonly === false ? 'false' : 'ignore',
887
- // Waarde velden (voor set_value acties)
888
- value: action.value || '',
889
- // Metadata
890
- order: (i + 1) * 100,
891
- active: true
898
+ // Hoofdkoppeling: naar de variable (dit MOET kloppen)
899
+ catalog_variable: variableId
892
900
  };
901
+ // NIET: catalog_ui_policy - deze veld bestaat NIET (volgens error log)
902
+ // Probeer alleen ui_policy en policy als alternatief
903
+ if (policyId) {
904
+ // Probeer ui_policy (dit is waarschijnlijk correct)
905
+ actionData.ui_policy = policyId;
906
+ }
907
+ // Voeg alleen GEDEFINIEERDE action properties toe
908
+ if (action.mandatory !== undefined) {
909
+ actionData.mandatory = action.mandatory === true ? 'true' : action.mandatory === false ? 'false' : 'ignore';
910
+ }
911
+ if (action.visible !== undefined) {
912
+ actionData.visible = action.visible === false ? 'false' : action.visible === true ? 'true' : 'ignore';
913
+ }
914
+ if (action.readonly !== undefined) {
915
+ actionData.disabled = action.readonly === true ? 'true' : action.readonly === false ? 'false' : 'ignore';
916
+ }
917
+ if (action.value) {
918
+ actionData.value = action.value;
919
+ }
920
+ // Basis metadata
921
+ actionData.order = (i + 1) * 100;
922
+ actionData.active = true;
893
923
  this.logger.info(`Attempting to create action ${i + 1}:`, actionData);
894
924
  const actionResponse = await this.client.createRecord('catalog_ui_policy_action', actionData);
895
925
  if (actionResponse.success) {
@@ -940,27 +970,6 @@ ${args.help_text ? `❓ Help: ${args.help_text}` : ''}
940
970
  throw new types_js_1.McpError(types_js_1.ErrorCode.InternalError, `Failed to create catalog UI policy: ${error}`);
941
971
  }
942
972
  }
943
- /**
944
- * Helper function to determine action type based on provided fields
945
- * Note: ServiceNow might not use 'type' field, actions are determined by field values
946
- */
947
- determineActionType(action) {
948
- // ServiceNow bepaalt het type waarschijnlijk op basis van de velden zelf
949
- // Dit is alleen voor logging/display
950
- if (action.value !== undefined && action.value !== '') {
951
- return 'set_value';
952
- }
953
- if (action.mandatory === true) {
954
- return 'set_mandatory';
955
- }
956
- if (action.visible === false) {
957
- return 'set_hidden';
958
- }
959
- if (action.readonly === true) {
960
- return 'set_readonly';
961
- }
962
- return 'default';
963
- }
964
973
  /**
965
974
  * Helper function to format action details for display
966
975
  */
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "snow-flow",
3
- "version": "3.6.12",
4
- "description": "COMPLETE UI POLICY FIX - v3.6.12 fixes both policy and actions. Policy uses catalog_item + applies_to fields. Actions link to catalog_variable. Conditions stored as query string. Based on actual ServiceNow table structure.",
3
+ "version": "3.6.13",
4
+ "description": "DEBUG UI POLICY - v3.6.13 adds extensive debugging to find why actions/conditions fail. Fixed condition string joining with ^ separator. Removed catalog_ui_policy field (doesn't exist). Added detailed logging for troubleshooting.",
5
5
  "main": "dist/index.js",
6
6
  "type": "commonjs",
7
7
  "bin": {