Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

NA Subcategory Added Automatically in Record Producer

pawankumar1
Tera Contributor

Hello Community,

In my Record Producer, when I select an Incident Type, the corresponding Incident Subcategories are displayed correctly.

However, I’ve noticed that the last subcategory ("NA") is always being added automatically to the list of selected subcategories

 

pawankumar1_1-1760360779966.png

 

4 REPLIES 4

Ankur Bawiskar
Tera Patron
Tera Patron

@pawankumar1 

how is the dependency handled currently?

share the screenshots or script

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

pawankumar1
Tera Contributor
it is working for incident subcategory non-mandatory when make mandatory then add NA variable for all Incident type 
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading) return;
 
 
var allSubcats = [
'authentication_issues','user_management','security_errors',
'data_feeds_transactions','interface_failures','travel_external_integrations',
'payroll_accounting','rates_allowances','settlement_vat',
'approval_flows','compliance_sampling','workflow_issues',
'performance_stability','reporting_configuration','ui_mobility',
'expense_capture','receipts_attachments','cash_advances',
'email_delivery','content_formatting','notification_settings','na'
 
];
 
allSubcats.forEach(function(f) {
g_form.setDisplay(f, false);
g_form.setValue(f, false);
});
 
 g_form.setDisplay('na', false);
    g_form.setValue('na', false);
 
 
 
if (!newValue) {
g_form.setDisplay('none', true);
return;
}
 
 
var subcategoryMap = {
'Login & Access': ['authentication_issues','user_management','security_errors'],
'System Connections & Integrations': ['data_feeds_transactions','interface_failures','travel_external_integrations'],
'Payments & Calculations': ['payroll_accounting','rates_allowances','settlement_vat'],
'Approvals & Workflow': ['approval_flows','compliance_sampling','workflow_issues'],
'App Performance & Usability': ['performance_stability','reporting_configuration','ui_mobility'],
'Expenses & Receipts': ['expense_capture','receipts_attachments','cash_advances'],
'Emails & Notifications': ['email_delivery','content_formatting','notification_settings'],
'Other': ['na']
};
 
 
if (subcategoryMap[newValue]) {
subcategoryMap[newValue].forEach(function(f) {
g_form.setDisplay(f, true);
});
}
}
 

@pawankumar1 

try this

function onChange(control, oldValue, newValue, isLoading) {
  if (isLoading) return;

  var allSubcats = [
    'authentication_issues', 'user_management', 'security_errors',
    'data_feeds_transactions', 'interface_failures', 'travel_external_integrations',
    'payroll_accounting', 'rates_allowances', 'settlement_vat',
    'approval_flows', 'compliance_sampling', 'workflow_issues',
    'performance_stability', 'reporting_configuration', 'ui_mobility',
    'expense_capture', 'receipts_attachments', 'cash_advances',
    'email_delivery', 'content_formatting', 'notification_settings', 'na'
  ];

  allSubcats.forEach(function(f) {
    g_form.setDisplay(f, false);
    g_form.setValue(f, false); // Deselect
  });

  // Always clear the Subcategory variable value
  g_form.setValue('incident_subcategory', '');

  if (!newValue) {
    // Optionally display default or 'none' field if needed here
    return;
  }

  var subcategoryMap = {
    'Login & Access': ['authentication_issues', 'user_management', 'security_errors'],
    'System Connections & Integrations': ['data_feeds_transactions', 'interface_failures', 'travel_external_integrations'],
    'Payments & Calculations': ['payroll_accounting', 'rates_allowances', 'settlement_vat'],
    'Approvals & Workflow': ['approval_flows', 'compliance_sampling', 'workflow_issues'],
    'App Performance & Usability': ['performance_stability', 'reporting_configuration', 'ui_mobility'],
    'Expenses & Receipts': ['expense_capture', 'receipts_attachments', 'cash_advances'],
    'Emails & Notifications': ['email_delivery', 'content_formatting', 'notification_settings'],
    'Other': ['na']
  };

  if (subcategoryMap[newValue]) {
    subcategoryMap[newValue].forEach(function(f) {
      g_form.setDisplay(f, true);
    });
  }
}

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Not working