Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

Bypass query Business Rule

Adheshwar2
Kilo Guru

Hi everyone,

        I have a scenario where I need to bypass a query Business Rule on a table. But all other business rule should work normally on update. Is it possible to bypass query Business Rule? I have used something like this

 

Operation done from another table

var gr = new GlideRecord('table');

gr.addQuery(<query>);

gr.setWorkflow(false);

gr.query();

 

if(gr.next())

{

    gr.setWorkflow(true);

    gr.setValue('state','3');

    gr.update();

}

 

 

Will the above code work just to bypass Query Business Rule but all other business rule to work on update?

1 ACCEPTED SOLUTION

Adheshwar2
Kilo Guru

Have achieved using Script action by event fired from Business rule. Thanks!!

View solution in original post

4 REPLIES 4

Harish Vaibhare
Kilo Guru

Hi Adheshwar

solved the problem by setting the reference qualifier on the variable to "activeANYTHING". Inside the "User Query" business rule I do something similar to:

var query = current.getEncodedQuery()

if( gs.getSession().isInteractive() && !query.includes('activeANYTHING') )

current.addActiveQuery()

 also refer the following thread it might help you.

https://community.servicenow.com/community?id=community_article&sys_id=c90c741bdb9108d8414eeeb5ca961...

 

Kindly Mark helpful and correct if it works.

Thanks.

hvrdhn88
Giga Patron

whats the use case ? only possible solution i can see by using gs.isInteractive() method which you need to use in query business rule.

https://developer.servicenow.com/dev.do#!/reference/api/orlando/server_legacy/c_GlideSystemAPI#r_GS-...

 

eg:

 

You have query br like below.

if(gs.isInteractive()){
var u = gs.getUserID();
current.addQuery("caller_id", u);
}

 

now if you will run updated operation using below code then it will work and update it. 

 

var gr = new GlideRecord('incident');
gr.get('7d95a0ab2f5e5c50f68d5ff62799b6a2');
gr.short_description = 'hey harshvardhan';
gr.update();

Adheshwar2
Kilo Guru

Have achieved using Script action by event fired from Business rule. Thanks!!

can you elaborate on what you did