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

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @Community Alums 

 

Where you want to show these incidents?

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

Community Alums
Not applicable

Hi @Dr Atul G- LNG,

 

When I am in the list view, I should see only the incidents created by the logged in user.

 

Regards

Suman P.

Hi @Community Alums 

 

You can create filter and put created by dynamic Me.

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

Mark Manders
Mega Patron

If you use ACL's for this, you are always only seeing your own incidents and none other. Next to that: use the conditions. 'opened by is dynamic me' can be used as a condition instead of scripting it.

Also: your script is handling 'sys_created_by' as a reference field to check if it's the current logged in user. That will never work, because sys_created_by is a string field.

 

If you just want to show someone a list of their own incidents, create a menu item 'my incidents' and set the condition to 'is dynamic me'. Your ACL will cause big issues with people having to watch or report on the incident table.


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