Splice method not working in Flow Designer

Community Alums
Not applicable
Below code is written in Updating Responsibilities field of type List in Flow Designer:
var delvalue=fd_data.trigger.current.u_responsibility;// Single sys_id
gs.info('Value to be deleted:'+delvalue);
var existvalue=fd_data._6__for_each.item.u_authority_role;//Comma Seprated sys_ids
gs.info('Existin Values:'+existvalue);

 

//var arr=[];
var arr=existvalue.indexOf(delvalue);
gs.info('removed Index:'+arr);
existvalue.splice(arr,1);
gs.info('Left Values:'+existvalue);
return existvalue.toString();
 
the above is giving error in flow designer as below:
Error: Cannot find function splice in object false.,Detail: Cannot find function splice in object false.
1 ACCEPTED SOLUTION

Maik Skoddow
Tera Patron
Tera Patron

You really should write better variable names. It's hard to understand your code due to those irritating names.

 

My proposal:

 

var arrValues = fd_data._6__for_each.item.u_authority_role.split(','); 
var numPosition = arrValues.indexOf(String(fd_data.trigger.current.u_responsibility || ''));

if (numPosition != -1) {
  arrValues.splice(numPosition , 1);
}

return arrValues.join(',');

 

 

Tip: For removing elements from an array please refer to https://www.geeksforgeeks.org/remove-elements-from-a-javascript-array/#method-3-remove-element-from-... 

View solution in original post

2 REPLIES 2

Maik Skoddow
Tera Patron
Tera Patron

You really should write better variable names. It's hard to understand your code due to those irritating names.

 

My proposal:

 

var arrValues = fd_data._6__for_each.item.u_authority_role.split(','); 
var numPosition = arrValues.indexOf(String(fd_data.trigger.current.u_responsibility || ''));

if (numPosition != -1) {
  arrValues.splice(numPosition , 1);
}

return arrValues.join(',');

 

 

Tip: For removing elements from an array please refer to https://www.geeksforgeeks.org/remove-elements-from-a-javascript-array/#method-3-remove-element-from-... 

Community Alums
Not applicable

@Maik Skoddow Sure will consider that will follow proper names