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.

background script to change field value

CV1
Tera Contributor
3 REPLIES 3

var tableName = '<table name>';
var oldURL = 'https://11111-app.test.com/app/abc/transaction/order.nl?id';
var newURL = "https://123111-app.testing.com/appications/xyz/transaction/order.nl?id";

var gr = new GlideRecord(tableName);
gr.addEncodedQuery('callLIKE' + oldURL);
gr.query();

if(gr.next()){//update if to while in order to loop through all results

var doc = gr.getDisplayValue('call');
gr.setValue('call', doc.replace(oldURL, newURL));
gr.setWorkflow(false);
gr.update();

}

nataliya_b
Kilo Sage

var gr= new GlideRecord(yourtable);

gr.addEncodedQuery("yourfieldCONTAINS11111");

gr.query();

 

if (gr.next())

{

var updatedValue = gr.getValue(yourfield).replace("11111","123111"),replace("test","testing").replace("app","applications").replace("abc","xyz");

gr.setValue(yourfield,updatedValue);

gr.setWorkflow(false);

gr.update();

}

If you happy with results, change if(gr.next()) to while (gr.next())