Help Needed with Condition Script in 'Look Up Records' Action
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-31-2025 06:38 AM
Hi,
I’m trying to write a condition in the Condition Script snippet of the ‘Look Up Records’ action in Flow Designer, but I’m unsure how to write it correctly and return the expected results.
Requirement:
The condition script should return records where:
u_employee_type is 'Consultant'
AND u_user_principal_name does not start with 'p000'
Please refer the following screenshots.
Used the Look Up Records action.
However, it is returning all 20 records from the target table, even though only 2 records meet the above criteria in the backend.
Only the 2 matching records should be returned by the lookup action.
Kindly help me with how to write the correct condition script to achieve this?
Thanks,
Ankit B
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-31-2025 07:23 AM
Hi Everyone,
I wanted to share that I've found a workaround for the issue I mentioned earlier.
I tested the solution by using the following code in the Condition Script snippet of flow designer, and it worked as expected:
The following script checking the
u_employee_type is 'Consultant'
AND u_user_principal_name does not start with 'p000'
And it is returning the correct record from the table.
var listQury = 'u_employee_type=consultant^u_user_principal_nameIN';
var listVals = '';
var list = new GlideRecord("table_name");
list.addQuery('u_employee_type','Consultant');
list.addQuery('u_user_principal_name', 'NOT LIKE', 'y%');
list.query();
while (list.next()) {
listVals = listVals + list.u_user_principal_name + ',';
}
return listQury+listVals;
Output:
Thanks,
Ankit B