org.mozilla.javascript.NativeArray issue

harishdasari
Tera Guru

Hi,

I'm writing a business rule and I wanted to compare the values in 2 arrays and then Find the elements present in all arrays. Below is the code I'm using. When I have put the logs gs.addInfomessage(countries.toString()) it is showing the values correctly, But when using the intersect it is not working.

This  is custom application

var arrayUtil = new global.ArrayUtil();
var a1 = new Array(countries.toString());
var a2 = new Array(arr.toString());

gs.addInfoMessage(arrayUtil.intersect(a1, a2));
	

 

ERROR:

find_real_file.png

 

1 REPLY 1

-O-
Kilo Patron
Kilo Patron
arrayUtil.intersect

returns an array.

While in functions that accept a (JavaScript) string parameter it will automatically converted to string and it will work, it is possible that addInfoMessage expect a Java String object, so this will not happen. So convert it to a string yourself.

arrayUtil.intersect(a1, a2).join(', ');

Also don't use new Array(), use literal array:

var a1 = [countries.toString()];