How to filter list by adding javascript in the conditions for a string type field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2023 02:21 AM
Hello,
I have created a system property which stores the string values (for example: hardware, software etc.).
In the incident list I am trying to filter with short description field, by adding a condition as
short description is one of and using the javascript to call system property I created and get the values from it as below. However, I am seeing undefined as return value from the javascript code.
I have tried with script include but for some reason it isn't working or showing the same issue as below. The idea is to get this logic and use in the business rule when to run condition for a string field to check if the values are one of from the system property. Kindly help to resolve this issue.
- Labels:
-
Incident Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2023 02:53 AM
basically you are on the right path and using prefix "javascript:" along with any simple method invocation will but, as described at https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0746219
However, using "gs.getProperty()" doesn't seem to work for me either. Really strange. Instead you should you use a custom Script Include. Refer to the linked KB article for examples.
Maik
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2023 03:14 AM
I haven't tried the way you mentioned.
But you can try to use this approach if your didn't work
1) create client callable classless script include something like this and return that property value
2) then call that script include in filter condition
short description [IS ONE OF] javascript: getPropertyValue()
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-22-2024 02:08 AM
The instructions for creating a scripted filter are in this article: Create scripted filters
So, the query "active=true^short_description=<your_string>" should be placed in the function and then return the relevant [sys_id]s