Adding filter of custom table's filed to target table

Tamil4
Tera Contributor

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.

Tamil4_0-1681811793933.png

 

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

19 REPLIES 19

Hi Anil,

 

Added the above line after while but it is still same.

Tamil4_0-1681817665506.png

Tamil4_1-1681817704031.png

 

Tamil

I don't see any issue with script.

Make sure to use correct name of field, it may not be u_condition.

Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande

Anil,

 

Tamil4_0-1681821185987.png

 Filed name is u_condition only. anything other than this I should check.

@Tamil4 

that line should be inside the while

gs.info('Condition' + Sc.getEncodedQuery());

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi Ankur,

 

Put that line inside while but it is not evening print the string in log.

Tamil4_1-1681821552938.png

And additionally I tried to print the value what I am getting from that field that is also blank only.

Tamil4_2-1681821835367.png

 

 

Tamil