function draft(id, subject) { this.emailId = id; this.emailSubject = subject;}
function seeDraftMessages() { var testArray = []; testArray.push(new draft(12412, 'test subject 1')); testArray.push(new draft(75162, 'test subject 2')); var testArrayDetails = []; testArray.forEach(function(msg) { Logger.log(msg); });};
[19-05-22 14:35:06:863 CDT] {emailId=12412.0, emailSubject=test subject 1}[19-05-22 14:35:06:864 CDT] {emailId=75162.0, emailSubject=test subject 2}
[19-05-22 14:35:06:863 CDT] {emailId: '12412', emailSubject: 'test subject 1'}[19-05-22 14:35:06:864 CDT] {emailId: '75162', emailSubject: 'test subject 2'}
In Google Apps Script, "{emailId=12412.0, emailSubject=test subject 1}" means that the value is an object. So, although I'm not sure whether this is the result you want, how about modifying from `Logger.log(msg)` to `Logger.log(JSON.stringify(msg))`?
--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
Visit this group at https://groups.google.com/group/google-apps-script-community.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/fbcc58ab-687a-49ae-a140-2ac5a52a70d2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Although I'm not sure about your whole situation, when you want to use the value of `{"emailId":"12412", "emailSubject":"test subject 1"}` as an object, how about using `JSON.parse()`?
--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
Visit this group at https://groups.google.com/group/google-apps-script-community.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/7edfa0e8-dc0c-437f-8077-af2a6ffa800e%40googlegroups.com.
Adam Morris | IT Systems & English Teacher | IGB International School
Jalan Sierramas Utama, Sierramas,
47000 Sungai Buloh, Selangor DE, Malaysia
t +60 3 6145 4688
f +60 3 6145 4600
w www.igbis.edu.my
e adam....@igbis.edu.my
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/CAGPa%2BS3MxEX8Lg_RHUms7P0CVRvgN8mo29ShezYOgYC%3DqkkjPw%40mail.gmail.com.
function ll(a,b) {
//Logger.log('ll ran: ' + a + " " + b)
if (ll.arguments.length === 2) {//two arguments were passed in
b = processValForLog(b);
var f = new Function('a','b','Logger.log(a + ":" + b)');
f(a,b);
} else {
var f = new Function('a','Logger.log(a)');
f(a);
}
}
window.processValForLog = function(val) {
try{
var typeOfThisVal;
typeOfThisVal = typeof val;
if (val) {
if (typeOfThisVal === 'object') {//The variable val can be an object and still be null
if (Array.isArray(val)) {//The very first test should be for an array because that is easy to check for
//Logger.log('it is an array')
if (val.toString().indexOf("[object Object]") !== -1) {
val = JSON.stringify(val);
} else {
val = val.toString();
}
//Logger.log('val: ' + val)
} else {//It is an object but not an array
//Logger.log('its NOT an array')
try{
val = JSON.stringify(val);//Test for whether it is a date
}catch(e) {//If this is an invalid date then JSON stringify will fail
//Logger.log('Error stringifying')
}
}
//Logger.log('typeof val: ' + typeof val)
if (typeof val !== 'string') {
try{
val = val.toString();
}catch(e) {
val = e.message;
}
}
if (val.indexOf("{") !== 0 && typeof val !== 'string') {
val = val.toString();
}
//continue;
}
}
if (typeOfThisVal === 'number') {
val = '"' + val.toString();
}
if (val === undefined) {//Avoid having all three cells undefined
val = 'UNDEFINEDDD';
} else if (val === null) {
val = 'NULLLL';
} else if (val === false) {
val = 'FALZZE';
} else if (val === true) {
val = 'TREWWW';
}
return val;
}catch(e) {
var f = new Function('e','Logger.log(e.message + ":\n\n" + e.stack)');
f(e);
}
}
Adam Morris | IT Systems & English Teacher | IGB International School
Jalan Sierramas Utama, Sierramas,
47000 Sungai Buloh, Selangor DE, Malaysia
t +60 3 6145 4688
f +60 3 6145 4600
w www.igbis.edu.my
e adam....@igbis.edu.my
--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
Visit this group at https://groups.google.com/group/google-apps-script-community.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/798683d9-6b4e-4e1b-b8d9-51c282348b20%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/CAFgZO_P9WR%3DV91%2B0vN-LGp7h8TZHjitXHgQihyCRjyhTojjkAw%40mail.gmail.com.