
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-21-2018 09:20 PM
We are writing a server script for a service portal widget and we need to check if state is in one of multiple values.
Our current only checks a single value, what we need is for this to check if state is either -4, -3, -2 and -1. Can we use IN or LIKE here?
if(data.table == 'change_request' && gr.active == true && gr.state == '-4' && gr.requested_by == gs.getUserID()){
//code
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-21-2018 09:48 PM
Hi JC,
we can use (gr.state =='-4'||gr.state =='-3'||gr.state =='-2'||gr.state =='-1')
this should work
if(data.table == 'change_request' && gr.active == true && (gr.state =='-4'||gr.state =='-3'||gr.state =='-2'||gr.state =='-1') && gr.requested_by == gs.getUserID()){ //code }
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-21-2018 09:48 PM
Hi JC,
we can use (gr.state =='-4'||gr.state =='-3'||gr.state =='-2'||gr.state =='-1')
this should work
if(data.table == 'change_request' && gr.active == true && (gr.state =='-4'||gr.state =='-3'||gr.state =='-2'||gr.state =='-1') && gr.requested_by == gs.getUserID()){ //code }
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-21-2018 09:55 PM
Hello JC,
for checking multiple values you can use or(||) operator.
like --state==1||state==2||state==3.
if(data.table == 'change_request' && gr.active == true &&//then you just use sate in or operator.
(gr.state =='1'||gr.state =='2'||gr.state =='3') && gr.requested_by == gs.getUserID()){
//code
}
HOPE THIS HELPFUL!!!!! MARK CORRECT OR HELPFUL.
Thanks,
Mohammed Iqbal