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.

Business rule is not working when image content type is inserting or updating in Attachment table

Samiksha2
Mega Sage

Hi All,
I have written a BR (before Insert/ Update ) on sys_attachment table to update image. But sometimes it is wprking sometimes not.

    var kb = new GlideRecord('kb_knowledge');
    kb.addQuery('sys_id', current.table_sys_id);
    kb.query();
    while (kb.next()) {
        if (current.content_type == "image/png") {
            current.table_name = "ZZ_YYkb_knowledge";
        }
    }

 

Thanks,
Sam

 

1 REPLY 1

Mark Manders
Mega Patron

I would adjust the BR trigger to only check on insert/update where the table_name = kb_knowledge and content_type = image/png. That will already limit the BR triggering on other tables/types, which it currently does.

Then you only need to update the current.table_name and not query to the table.


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark