Adding filter of custom table's filed to target table
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2023 03:04 AM
Hi Everyone!
Am having a custom table, in that I have a field called condition which is Conditions type field.
I have to get the value of this condition filed and use that as a filter in my target table through script.
For Example: The custom table's condition field having company=ACME Africa, then I should use the same in incident table filter.
Below is the script I wrote. Not sure how far it is correct.
1. var Script = new GlideRecord('u_integration_configuration'); -> this is the custom table name
2. Script.addQuery('u_table_name', current.sys_class_name);
3. Script.addQuery('u_active', true);
4. Script.query();
5. while (Script.next()) {
6. //var fliterString = Script.getValue('u_condition');
7. var Rec = new GlideRecord(Script.u_table_name);
8. Rec.addEncodedQuery(Script.u_condition);
9. Rec.query();
10. if (Rec.next()) {
In the 8th line I have to use the condition field's value of custom table.
Please help me to achieve this.
Thanks in advance.
Thanks,
Tamil
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2023 03:48 AM - edited 04-18-2023 03:49 AM
How about this
var sc = new GlideRecord('u_integration_configuration'); -> this is the custom table name
sc.addQuery('u_table_name', current.sys_class_name);
sc.addQuery('u_active', true);
sc.query();
while (sc.next()) {
var rec = new GlideRecord(''+current.sys_class_name);
rec.addEncodedQuery(''+sc.u_condition);
rec.query();
if (rec.next()) {
//do whatever
}
}
Also, add logs to see if the code is going in any of the gliderecords?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2023 03:57 AM
Below is what am getting in log after adding logs to both gliderecords.
First gliderecord is giving the correct encoded query but the second one it is coming as blank only.
Tamil
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2023 04:03 AM
add second info message inside if.
Also you have not added string conversion as suggested by Anil and myself
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2023 04:09 AM
Added you suggestion. Please correct me if I made it wrong .
But still log is empty for second gliderecord.
Tamil

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2023 04:32 AM
Hi,
Try adding log for u_condition in while loop.
while(Sc.next()){
gs.info('Test123Condition--'+Sc.u_condition.toString());
I hope you are using correct field name u_condition.
Thanks
Anil Lande