Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Advance condition in Business rule on attachment table

Shubham67
Tera Contributor

Hi All,

 

I have a requirement to validate the attachment name for a certain type of ctask. I have written a BR on attachment table, script is working fine but this validation is working on all ctask that we don't want. I know that the dot walking with table name won't work. Please tell me if we can put this advance condition and how.

image.png

1 ACCEPTED SOLUTION

Hi @Shubham67 the query is wrong in line 51,

it must be

gr.addEncodedQuery('change_task_type=ci_load^sys_id='+current.table_sys_id); //used for encoded queries

not

gr.addActiveQuery(); .//this is used to filter active records

similar to

gr.addQuery('active',true);

Regards
Harish

View solution in original post

3 REPLIES 3

Harish KM
Kilo Patron
Kilo Patron

Hi @Shubham67 you can write advanced script on attachment table and validate with sysid of that record

example:

var gr = new GlideRecord("tablename");
gr.addQuery("sys_id", current.table_sys_id);// match table sysid with record sys id of that table

gr.addQuery('short_description', 'this is test');// retrieve record matches short desc =  this is test // addtional query
if (gr.next()) {
// validation here
}

Regards
Harish

Hi Harish,

I have this condition in the script.

image (1).png

But it is applying to all ctasks. Please suggest something that we can apply on condition of BR.

Hi @Shubham67 the query is wrong in line 51,

it must be

gr.addEncodedQuery('change_task_type=ci_load^sys_id='+current.table_sys_id); //used for encoded queries

not

gr.addActiveQuery(); .//this is used to filter active records

similar to

gr.addQuery('active',true);

Regards
Harish