pass values to an array based on condition
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-27-2023 04:41 AM
how can I push some hard coded values to an array based on some condition.
if user is having role itil
then add user having itil role is added to list in short description field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-27-2023 05:48 AM
with regards to above code how can I add else if inside array
here if gr.user_name == C then
arr.push (gr.getvalue(name came from A, B)+ " user is from different group) // this is how i want it to be
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-27-2023 05:55 AM
var gr = new GlideRecord(tablename);
gr.addQuery(your query);
gr.query()
while(gr.next())
{
if(gr.user_name =="A")
{
arr.push(dynamic value);
}
else if(gr.user_name == "B")
{
arr.push(dynamic value 2);
}
else if(gr.user_name =="C")
{
arr.push("user does not exist");
}
gr.short_description= arr.toString();
gr.update();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-27-2023 06:56 AM
if I have list of sys id inside an array and if I have to check whether it contains one of them then how can I get it
for eg. array = [1,2,3,4,5,6]
if array contains 2 then go inside loop or else skip
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-27-2023 07:09 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-27-2023 07:41 AM
hi Shashank,
above code is working just want to add few condition