Create records by using split function

Developer2764
Tera Contributor

Hi Everyone,
there is a catalog item that is auto populating the values on incident table. There is a split function that is not working well, will create multiple records on the table with auto population of field values. For example, if I write a,b,c it will create three new records on incident table. I've apply following after BR with insert and update.

(function executeRule(current, previous /*null when async*/) {

    (function() {
  var nm = current.variables.num.split(','); //num is the variable name 

  for (var i = 0; i < nm.length; i++) {
    var gr = new GlideRecord('incident');
   gr.initialize(); 
    gr.setValue('description', names[i].trim());
    gr.insert(); 
  }
})();
})(current, previous);
1 REPLY 1

Community Alums
Not applicable

Hi @Developer2764 ,

 

Try replacing line 2 with this: var nm = current.variables.num.toString().split(',');

 

Mark it helpful, if this helps you in any way!

 

regards,

Prasad