Category Values should be Remove

Priya madyapgol
Tera Contributor

Hi There,

 

I have one requirement on Client Script,

 

I have one 'u_tower' (choice type) field, and which is having 4 choices,

1.Controlling

2.Financing

3.Account payable

4.General Accounting

 

 

and my requirement is, when the country is Portugal and the Tower is GA at that time the below case_category values shouldn't visible to the user to select 

1. urgent payments

2. General Ledger Accounting.

 

I have written the below code but which is not working for me

Priyamadyapgol_0-1746640577291.png

 

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
   if (isLoading || newValue === '') {
      return;
   }

   if ('u_tower' =='General Accounting'&& 'language'=='Portuguese'){

    g_form.removeOption('u_case_category','General Ledger Accounting');
    g_form.removeOption('u_case_category','urgent payments');

   }
   
}
 
ca anybody please help me on this to get the solution.
 
Thanks,
 

 

1 ACCEPTED SOLUTION

Sohail Khilji
Kilo Patron
Kilo Patron

Hi @Priya madyapgol ,

 

Try this :

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || newValue === '') {
        return;
    }

    var towerValue = g_form.getValue('u_tower');
    var countryValue = g_form.getValue('u_country'); // Assuming that country field is named 'u_country' on ur isntance
    if (towerValue == 'General Accounting' && countryValue == 'Portugal') {
        g_form.removeOption('u_case_category', 'urgent payments');
        g_form.removeOption('u_case_category', 'General Ledger Accounting');
    }
}

☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....

LinkedIn - Lets Connect

View solution in original post

4 REPLIES 4

Sohail Khilji
Kilo Patron
Kilo Patron

Hi @Priya madyapgol ,

 

Try this :

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || newValue === '') {
        return;
    }

    var towerValue = g_form.getValue('u_tower');
    var countryValue = g_form.getValue('u_country'); // Assuming that country field is named 'u_country' on ur isntance
    if (towerValue == 'General Accounting' && countryValue == 'Portugal') {
        g_form.removeOption('u_case_category', 'urgent payments');
        g_form.removeOption('u_case_category', 'General Ledger Accounting');
    }
}

☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....

LinkedIn - Lets Connect

Hi @Sohail Khilji ,

I tried the above code which you have mentioned, but still it is not working for me, the values are still visible

Please recheck the values which are passed in parameters it must work.


☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....

LinkedIn - Lets Connect

Ankur Bawiskar
Tera Patron
Tera Patron

@Priya madyapgol 

Share few things first

1) share the choice list screenshot for u_tower

2) share from where are you picking language? is it coming from some field or you are saying logged in user's language

3) are you removing the correct choice value from that field u_case_category?

If my response helped please mark it correct and close the thread so that it benefits future readers.

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