Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Simple list filter.

austiin
Giga Contributor

Hey Guys, I am having an issue with the simple list filter field. I am trying to make a widget for the service portal that only shows "My closed incidents" I am able to show closed incidents, However I am not sure how to make it only show closed incidents of the current user signed into service portal. I have a similar widget named "My Requests" whose operation is very similar, but only showing open incidents. Its filter looks like this "caller_idDYNAMIC90d1921e5f510100a9ad2572f2b477fe^active=true^EQ". I have tried multiple methods of trying to get this right and i kinda feel like a fish out of water. Can you guys help point me in the right direction?

TLDR Question: How do I use the simple list widget "Filter" field to only show Closed Incidents of the current user signed into service portal?

4 REPLIES 4

dvp
Mega Sage

DO you mean widget instance?



Here is the screenshot of widget instance that shows all the closed incidents of a caller



find_real_file.png


drjohnchun
Tera Guru

If you want a truly dynamic filter, without the hardcoded sys_id, you can use this:



caller_id=javascript:gs.getUserID()^active=false



The key is using javascript:gs.getUserID() to get the current user's sys_id.



Hope this helps.



Please feel free to connect, follow, mark helpful / answer, like, endorse.


John Chun, PhD PMP see John's LinkedIn profile

visit snowaid


ServiceNow Advocate

Winner of November 2016 Members' Choice Award


austiin
Giga Contributor

Thanks guys, @dvp i didn't even think about doing it that way will remember that for next time. @John Chun i wrote some code similar to that and it didn't work However, I may or may not have made a small error of putting the ^ in the wrong place...How embarrassing Thanks for the quick response guys!


Yes, encoded queries tend to be picky about small things like the placement of "^". I tested the query before posting and works as expected. If you want to use the Condition Builder UI, it has to be



[caller_id.sys_id] [is] [javascript:gs.getUserID()] AND


[active] [is] [false]



To get caller_id.sys_id, you'd have to first pick "Show Related Fields" at the bottom of the dropdown, and then pick Caller => User fields, and then Sys ID (a bit convoluted).