We're reclaiming inactive PDIs to keep them available for active builders. Learn what's changing, who's affected, and how to protect your work. Read More

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())