- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2022 04:25 AM
Hi,
I have this query and instead of using LIKE and sysid i need to use LIKE and the var product.
What is the right way to replacing the sys ID with the variable product?
u_allowed_duplication is of a type list and its a reference to a table, so i need to filter using contains which is LIKE.
bs.addEncodedQuery('name=' + user + ^u_allowed_duplication_swLIKEda1d2ffc1b3db05073542f02604bcbcb')
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2022 05:10 AM
Hi Aon,
To replace the hard-coded sys_id with a variable depends on where you are running this script, but generally the syntax is current.variables.variable_name, so you can do this with an encoded query:
bs.addEncodedQuery('name=' + user + '^u_allowed_duplication_swLIKE' + current.variables.product);
or 2 addQuery lines:
bs.addQuery('name', user);
bs.addQuery('u_allowed_duplication', 'CONTAINS', current.variables.product);
both of these examples assume 'user' is defined elsewhere in the script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2022 10:25 PM
Hi
It is strange to me without checking the responses you or someone are marking the question as correct/helpful.
Please make sure validate the responses and mark only which you tried or which are helpful otherwise how this thread will help others and you as well.
There is no use if anyone marks the helpful as comments and try to hit helpful or accept the solution.
Regards
Pavankumar
ServiceNow Community MVP 2024.
Thanks,
Pavankumar