IndexOF is giving error in Flow Designer

Community Alums
Not applicable

Hi All,

 

Below code is written in Flow Designer

var single=fd_data.trigger.current.u_responsibility.toString();//Single Sys_id
var arrValues = fd_data._3__for_each.item.u_authority_role; //Multiple Sys_ids comma Separated
if(arrValues.indexOf(single)==-1){

 

 arrValues=arrValues + ','+ single;
}

 

 return arrValues.toString();
 
 
The above code should add the sys_id to the list of sys_ids but its giving error as below:
Cannot find function indexOf in object .
3 REPLIES 3

Dnyaneshwaree
Mega Sage

check the scope of the flow and check that the "index of" is supported for that scope of flow or not. If not then use sub-flow of the required scope for that particular logic and call it from main flow.

If my solution helps you any way then mark it as accepted and helpful.

Thank You!!

Please accept my solution if it works for you and thumps up to mark it as helpful.
Thank you!!

Dnyaneshwaree Satpute
Tera Guru

Community Alums
Not applicable

@Maik Skoddow Can you help again?

Community Alums
Not applicable

I have replaced my above script to the below:

var single=fd_data.trigger.current.u_responsibility;//Single Sys_id
var arrValues = fd_data._3__for_each.item.u_authority_role; //Multiple Sys_ids comma Separated
var arrayUtil = new global.ArrayUtil();
if(arrayUtil.indexOf(arrValues,single)==-1){
arrValues=arrValues + ','+ single;

}

  return arrValues.toString();
 
Above code is giving Error as
Error: Function size is not allowed in scope global
 
Actually I am not able to use indexOf function and getting error.Kindly assist in resolving the same