- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-30-2022 09:16 AM
We are getting odd java error on what by all appearances (and previous function since this worked last week prior to Tokyo) is correct syntax. After recent upgrade though, we are getting java errors that look like this-
We are logging out the data object before the split, and then after. You can see a valid data object and then a java error.
var clientarr = this.getParameter('sysparm_clientarr').toString();
gs.log('clientarr' + clientarr);
obj = {};
arr = [];
clientarr = clientarr.split("&");
gs.log('clientarr AFTER SPILT' + clientarr);
Above is the bit that is generating the error, just in case below is the whole function-
saveBreakdownPreference: function() {
var clientarr = this.getParameter('sysparm_clientarr').toString();
gs.log('clientarr' + clientarr);
obj = {};
arr = [];
clientarr = clientarr.split("&");
gs.log('clientarr AFTER SPILT' + clientarr);
for (var i = 0; i < clientarr.length; i++) {
gs.log('clientarr[i]' + clientarr[i]);
element1 = clientarr[i].toString();
gs.log('element1' + element1);
element= element1.split(":");
gs.log('element' + element);
client = element[0];
gs.log('client' + client);
breakdown = element[1].split(",");
gs.log('breakdown' + breakdown);
preference = element[2].split(",");
gs.log('preference' + preference);
var gr = new GlideRecord("u_login_management_client");
gr.addQuery("sys_id", client);
gr.query();
var clientnum;
var CorpCode;
if (gr.next()) {
clientnum = gr.u_client_number.toString();
corpCode = gr.u_corpcode.toString();
}
var temp_breakdown = [];
for (var j = 0; j < breakdown.length; j++) {
var gr1 = new GlideRecord("u_login_management_output");
gr1.addQuery('sys_id', breakdown[j]);
gr1.query();
if (gr1.next()) {
temp_breakdown.push(gr1.u_data.toString());
}
}
var temp_preference = [];
for (var k = 0; k < preference.length; k++) {
var gr2 = new GlideRecord("u_login_management_output");
gr2.addQuery('sys_id', preference[k]);
gr2.query();
if (gr2.next()) {
temp_preference.push(gr2.u_data.toString());
}
}
var client_obj = {};
client_obj["CorpCode"] = corpCode;
client_obj["Client"] = clientnum;
client_obj["BreakDown"] = temp_breakdown;
client_obj["Preference"] = temp_preference;
arr.push(client_obj);
}
obj.message = arr;
return JSON.stringify(obj);
},
Anyone have an idea on why this is not working now and better, what we need to do to fix?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-30-2022 10:43 AM
Came across this line in another post on the community-
[Ljava.lang.String;@c09a8a means that is an array of type string. So you do not need to split it any more...
Value at start:
clientarr530761ff1b2d05500a05feeccd4bcbc5:ff4f45181b23d950677e0dc8cc4bcb18:805fc1181b23d950677e0dc8cc4bcb28&530761ff1b2d05500a05feeccd4bcbc5:b34f45181b23d950677e0dc8cc4bcb19:805fc1181b23d950677e0dc8cc4bcb28&
I am confused as to what to change. Ideas?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-30-2022 10:43 AM
Came across this line in another post on the community-
[Ljava.lang.String;@c09a8a means that is an array of type string. So you do not need to split it any more...
Value at start:
clientarr530761ff1b2d05500a05feeccd4bcbc5:ff4f45181b23d950677e0dc8cc4bcb18:805fc1181b23d950677e0dc8cc4bcb28&530761ff1b2d05500a05feeccd4bcbc5:b34f45181b23d950677e0dc8cc4bcb19:805fc1181b23d950677e0dc8cc4bcb28&
I am confused as to what to change. Ideas?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-21-2023 04:52 AM
I had this exact issue today - it seems there are some data types that are difficult to convert to a string using .toString() and instead they may be converted to the 'Ljava.lang.String;@c09a8a' data type. .split() is specifically a string method so this then causes issues when converting to a list.
Instead of using variable.toString(), I used new String(variable) and then used .split() to successfully turn it into a list.
If you're still having this issue, maybe try the following in the first line:
var clientarr = new String(this.getParameter('sysparm_clientarr'));