Write data to CSV


(function executeRule() {
  var grCI = new GlideRecord('cmdb_ci');
  grCI.addNotNullQuery('x_tori2_addm_key');
  grCI.query();

  var dataStr = 'name,x_tori2_addm_key,sys_id,sys_class_name\n';

  while (grCI.next()) {
    dataStr += grCI.getValue('name') + ','
    + grCI.getValue('x_tori2_addm_key') + ','
    + grCI.getUniqueValue() + ','
    + grCI.getValue('sys_class_name') + '\n';
  }

  var user = new GlideRecord('sys_user');
  user.get(gs.getUserID());

  var gsa = new GlideSysAttachment();
  gsa.write(user, 'uControl.csv', 'text/csv', dataStr);

})();


Comments

Popular posts from this blog

Running transform maps asynchronously

Post a command to the ECC queue for the mid server to initiate a powershell file copy

GlideRecord setValue