Interested in a ServiceNow event built for developers? Registration for now[dev]26 is officially open!

How to temporarily make changes to script and avoid creating versions?

Suggy
Giga Sage

I need to temporarily make changes to a script (say a Business rule) and avoid creating versions.

Post my testing, I will revert it to original state. I dont want any versions/traces. 

Is it possible?

 

1 ACCEPTED SOLUTION

Chaitanya ILCR
Giga Patron

Hi @Suggy ,

whatever changes you are doing to them via Background script or fixscript with setworkflow false

or you can use update jobs with run business rules false

var current = new GlideRecord("sys_script");
if (current.get("67014acbc39d6610051cb132b4013192")){
    gs.info(current.getDisplayValue());
}
current.name ='test';
current.setWorkflow(false)
current.update()

example I have updated name of a BR with setWorkflow(false) it did not create a version 

 

Please mark my answer as helpful/correct if it resolves your query.

Regards,
Chaitanya

View solution in original post

6 REPLIES 6

@Suggy 

check the script which @Chaitanya ILCR shared but remember setting the script field is tedious as it's a script type field

see if that works for you

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

That should be fine @Ankur Bawiskar  @Suggy 

use Template literals take the edited script and wrap them using the backtick(`)

var current = new GlideRecord("sys_script");
if (current.get("67014acbc39d6610051cb132b4013192")) {
    gs.info(current.getDisplayValue());
}

current.script = `(function executeRule(current, previous /*null when async*/) {

	// Add your code here
	gs.warn('usr query '+gs.action.getGlideURI().toString())
	if(gs.action.getGlideURI().toString().contains('api/now/form/mention/record/')){
		gs.warn('usr query inside gs.action')
		current.addNullQuery('sys_id')
	}
//hello test
})(current, previous); `
current.setWorkflow(false)
current.update()

 

Please mark my answer as helpful/correct if it resolves your query.

Regards,
Chaitanya