- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-03-2024 03:35 AM
Hello Community,
I want some use case where I can switch case for implementations.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-03-2024 03:38 AM
Hi @AnkitT ,
You can refer this link to know about how to use switch case in ServiceNow.
https://www.servicenow.com/community/developer-forum/using-a-switch-case-in-servicenow/td-p/2739803
Please accept my solution and mark this helpful if it works for you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-04-2024 05:27 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-03-2024 03:38 AM
Hi @AnkitT ,
You can refer this link to know about how to use switch case in ServiceNow.
https://www.servicenow.com/community/developer-forum/using-a-switch-case-in-servicenow/td-p/2739803
Please accept my solution and mark this helpful if it works for you.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-03-2024 03:44 AM
Hi @AnkitT ,
Please refer below code
var gr = new GlideRecord('incident');
gr.addQuery('sys_id', '46e2fee9a9fe19810049b49dee0daf58');
gr.query();
if(gr.next()){
gs.print("here = " + gr.incident_state)
switch(gr.incident_state.toString()){
case "1":
gs.print("Yes category is Hardware");
break;
case "2":
gs.print("Yes category is Software");
break;
case "3":
gs.print("Yes category is Network");
break;
}
}
Result
Please mark my answer correct and helpful if this works for you
Thanks and Regards
Sarthak
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-04-2024 05:27 AM