Switch case for multiple choices

Afrin12
Tera Contributor

Hi
I want to write a switch case for OnBefore script in which  If model category is computer, model sub category is Desktop and state is installed then office number is mandatory. 
How can I write because i'm confusing a little bit.
I have tried but not getting. Anyone Help me
Thanks in advance

NAfreenAfreen_0-1668608410508.png

 

3 ACCEPTED SOLUTIONS

palanikumar
Mega Sage

Switch case is for simple check. For complex condition it is advised to use if else condition

Thank you,
Palani

View solution in original post

Pavankumar_1
Mega Patron

Hi @Afrin12 ,

you can use if condition to check those conditions.

refer below link.

https://www.servicenow.com/community/developer-blog/community-code-snippets-javascript-switch-statem...

If it helps please click Accept as Solution/hit the Thumb Icon.
ServiceNow Community MVP 2024.
Thanks,
Pavankumar

View solution in original post

FelipeReis
Giga Expert

Hi @Afrin12 ,


You can try this. But "If Else" could be more simple.
Captura de Tela 2022-11-16 às 12.09.12.png

Hope this helps.

Thanks, 
Felipe Reis

 

View solution in original post

4 REPLIES 4

palanikumar
Mega Sage

Switch case is for simple check. For complex condition it is advised to use if else condition

Thank you,
Palani

Thank you

 

Pavankumar_1
Mega Patron

Hi @Afrin12 ,

you can use if condition to check those conditions.

refer below link.

https://www.servicenow.com/community/developer-blog/community-code-snippets-javascript-switch-statem...

If it helps please click Accept as Solution/hit the Thumb Icon.
ServiceNow Community MVP 2024.
Thanks,
Pavankumar

FelipeReis
Giga Expert

Hi @Afrin12 ,


You can try this. But "If Else" could be more simple.
Captura de Tela 2022-11-16 às 12.09.12.png

Hope this helps.

Thanks, 
Felipe Reis