org.mozilla.javascript.NativeArray issue
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā04-30-2021 04:41 AM
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:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā04-30-2021 05:06 AM
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()];