I was writing this method, but I get a [Ljava.lang.Object;@ec79b1 error.
Am I doing something wrong?
The method is:
var anagmailing = “”
currentcontroller.recordIndex = 1
var anagmailing = anagid;
currentcontroller.recordIndex = currentcontroller.recordIndex + 1;
for (x = 0; x < currentcontroller.getMaxRecordIndex()-1; x++)
{
var anagmailing = anagmailing + ", " + anagid;
currentcontroller.recordIndex = currentcontroller.recordIndex + 1;
}
var query = ‘SELECT email FROM uc_email WHERE anagid IN (’ + anagmailing + ‘)’;
var dataset = databaseManager.getDataSetByQuery(controller.getServerName(), query, null, 10000);
var indirizziemail = dataset.getColumnAsArray(1)
globals.indirizziemail = indirizziemail
The indirizziemail variable gives me the described error.
Well you request for the entire column(with all rows) from the dataset, so the result is an Array!
So you could do:
var first = indirizziemail[0];
var second = indirizziemail[1];
etc.
Jan Blok:
Well you request for the entire column(with all rows) from the dataset, so the result is an Array!
So you could do:
var first = indirizziemail[0];
var second = indirizziemail[1];
etc.
Hmm: can’t I have all the values together? I have to use them all to send a newsletter.
My idea was:
I select the customer I want to contact
with a loop, I put all their ID into the query that returns me their email addresses
when I get all the addresses, I send the mail putting them in the bcc
Not possible?
yes possible but the bcc argument requires a comma separated list and not an array
So you should do this:
var indirizziemail = dataset.getColumnAsArray(1)
var bcc = "";
for (var i = 0 ; i < indirizziemail.lenght ; i++)
{
bcc = bcc + indirizziemail[i];
if (i < indirizziemail.lenght -1)
{
bcc = bcc +",";
}
}
Jan Blok:
yes possible but the bcc argument requires a comma separated list and not an array
Right. In fact, I was writing a loop that extracts every item from the array and adds a comma, but your code is MUCH better (and shorter).
Thanks a lot ![Wink :wink:]()