How to show only incidents created by currently logged in user?

Community Alums
Not applicable

Hi,

I am in a scenario to show only logged-in user-created incidents. I tried it, but it is not working. Kindly help.

 

1.png

 

2.png

 

if(current.sys_created_by == gs.getUserID()){
	answer = true;
}
else{
	false;
}

 

Regards

Suman P.

10 REPLIES 10

Community Alums
Not applicable

Hi @Mark Manders,

Thank you for correcting my mistake. I checked that sys_created_by is a string field. I can simply use the condition, but I am not interested in using a condition. I want to use the script only. 

 

1.png

 

2.png

 

if(current.opened_by == gs.getUserID()){
	answer = true;
}
else{
	false;
}

 

3.png

 

Regards

Suman P.

Why would you script? It does exactly the same in the conditions and is even more efficient. Next to that: in the future anyone can easily see what is done, instead of having to open the script. 

So you are not interested in using the best way to use the platform? 


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark

Community Alums
Not applicable

Hi @Mark Manders,

 

It is not that i don't want to use. I am practicing ACL script on my PDI.

 

Regards

Suman P.

In your ACL - your are using incident . * (star)
* is ALL fields - not the table itself.

So change the "field" from * to "none" - then it evaluates for the table instead of all the fields.

Also - You dont want to use "current.opened_by" because thats a GlideElement

Use:

 

if(current.getValue('opened_by') == gs.getUserID()){
	answer = true;
}
else{
	answer = false;
}

 

By the way - be careful if you test with your admin account as the ACL have "Admin override" meaning that it ALWAYS returns true 🙂 - effectively render the ACL true on all incidents

Else you need to remove the admin override checkbox