Robbie
Kilo Patron

Hi @Nisha30,

 

Can you expand on where you are calling and running this script? Is it a one off Fix Script for example, or a scheduled job for example?

 

I've tested the syntax via my PDI and it works as expected. Thoughts that come to mind is that you may have some logic implemented on update of the name unique to your org or instance.

You are able to execute the script without invoking other scripts that maybe blocking the update by add a line before the sr.update();

Add the following above the update: sr.setWorkflow(false);

This essentially stops other rules and logic from being invoked - however - please consider this, there maybe a valid reason why this is being blocked. I would suggest you run this on NON prod first and confirm the results and behaviour before running on prod. I'd also specifically target one or two records first before running on all servers meeting the criteria.

 

Updated script:

 

var sr = new GlideRecord('cmdb_ci_server');
sr.addQuery('po_number', 'decom');
sr.addQuery('sys_class_name', 'cmdb_ci_server'); //only  cmdb_ci_server CI
sr.query();
while (sr.next()) {
    gs.print('Server name before update: ' + sr.name);
    var dName = 'zzz' + sr.name;
    sr.name = dName;
    gs.print('Server name after update: ' + sr.name);
    sr.setWorkflow(false);
    sr.update();
}

 

 

To help others (and for me to gain recognition for my efforts), please mark this response correct by clicking on Accept as Solution and/or Kudos.




Thanks, Robbie