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.

multiple records update on setWorkflow(false)

Mohammed Lais1
Mega Guru

Hi

i am trying to update multiple ritm records through workflow.

i am using the below code.

var req = current.request;

  var gr = new GlideRecord('sc_req_item');

  gr.addQuery('request',req);

  gr.orderBy('number');

  gr.query();

  while(gr.next()){

  gr.variable_pool.test_access_created="true";

  gr.update();

  }

this is updating only one record.but the query is fetching multiple records.

if i add

gr.setWorkflow(false);

before gr.update();

all the records are getting updated perfectly.

can we update the multiple records without making the workflow as false?

12 REPLIES 12

jayfreise
Mega Contributor

Hi, not sure if you want to use setWorkflow - it is used to skip running business rules during a gliderecord update.



https://developer.servicenow.com/app.do#!/api_doc?v=helsinki&id=r_GlideRecord-setWorkFlow_Boolean


Enables or disables the running of business rules that might normally be triggered by subsequent actions. If the e parameter is set to false, an insert/update will not be audited. Auditing only happens when the parameter is set to true for a GlideRecord operation.


Mohammed Lais1
Mega Guru

thanks for reply, i do not want to use setWorkflow(false);


Hi Mohammed,


Ok, did that answer your question?


Mohammed Lais1
Mega Guru

no jay, without using setWorkflow(false) i am not able to update multiple records.