Populate subcategory basis on category | Catalog Client Scripts | DEV

PHOTO EMBED

Sat Jun 17 2023 20:33:04 GMT+0000 (Coordinated Universal Time)

Saved by @Piyush #undefined

function onChange(control, oldValue, newValue, isLoading) {

    if (isLoading || newValue == '') {

        return;

    }

​

    g_form.clearOptions('category_sub_process');

​

    if (newValue == '1') {

        g_form.addOption('category_sub_process', 'fb60', 'FB60');

        g_form.addOption('category_sub_process', 'write_off', 'Write off');

        g_form.addOption('category_sub_process', 'recurrent', 'Recurrent');

        g_form.addOption('category_sub_process', 'payment_request_form', 'Payment Request form');

        g_form.addOption('category_sub_process', 'workflow_changes', 'Workflow changes');

        g_form.addOption('category_sub_process', 'offset', 'Offset');

        g_form.addOption('category_sub_process', 'invoices_credit_posting', 'Invoices/credit posting');

        g_form.addOption('category_sub_process', 'deletion_request', 'Deletion request');

        g_form.removeOption('category_sub_process', 'urgent_posting');

        g_form.removeOption('category_sub_process', 'payment_changes');

        g_form.removeOption('category_sub_process', 'payment_issues');

        g_form.removeOption('category_sub_process', 'other_inquiries');

        g_form.removeOption('category_sub_process', 'other_request');

    } else if (newValue == '2') {

        g_form.removeOption('category_sub_process', 'fb60', 'FB60');

        g_form.removeOption('category_sub_process', 'write_off', 'Write off');

        g_form.removeOption('category_sub_process', 'recurrent', 'Recurrent');

        g_form.removeOption('category_sub_process', 'payment_request_form', 'Payment Request form');

        g_form.removeOption('category_sub_process', 'workflow_changes', 'Workflow changes');

        g_form.removeOption('category_sub_process', 'offset', 'Offset');

        g_form.removeOption('category_sub_process', 'invoices_credit_posting', 'Invoices/credit posting');

        g_form.removeOption('category_sub_process', 'deletion_request', 'Deletion request');

        g_form.addOption('category_sub_process', 'urgent_posting','Urgent Posting');

        g_form.removeOption('category_sub_process', 'payment_changes','Payment changes');

        g_form.removeOption('category_sub_process', 'payment_issues','Payment issues');

        g_form.removeOption('category_sub_process', 'other_inquiries','Other Inquiries');

        g_form.removeOption('category_sub_process', 'other_request','Other request');

    } 
content_copyCOPY

This will work when you add or remove options based on the selection of other field. AP and billing

https://epsilondev.service-now.com/catalog_script_client.do?sys_id