I have seen there are several posts on a similar topic with answers but I can't seem to use any of that information to assist my issue; unless I am not understanding something correctly.
I have an object that I am converting to a JSON string. I can see the multidimensional object in the browser console, but when I stringify the object and print out the new variable it simply states {}
.
Here is my JavaScript snippet:
//consider up until this point the object has been created in the variable returnObject
console.log("returnObject", returnObject);
var returnString = JSON.stringify(returnObject);
console.log("returnString", returnString);
and here is a screenshot of the console terminal for these two console logs:
Can anyone assist in why it is not converting into a proper string value?
EDIT: Here is the entire function that is being executed including the initialization of the object.Note that this is interacting with a Salesforce API:
var getTabIds = function getTabIds(result) {
if (result.success) {
//var returnObject = new Array();
var returnObject = new Object();
for (i = 0; i < result.ids.length; i++) {
sforce.console.getSubtabIds(result.ids[i], function (subTabResult) {
if (subTabResult.success) {
for (i = 0; i < subTabResult.ids.length; i++) {
var subTabId = subTabResult.ids[i];
sforce.console.getPageInfo(subTabId, function (page) {
var subTabInfo = jQuery.parseJSON(page.pageInfo);
var id = subTabInfo.objectId.toString();
returnObject[id] = subTabInfo;
Object.defineProperty(returnObject, id, {
enumerable: true
});
//returnObject.push(page.pageInfo);
});
}
console.log("returnObject", returnObject);
var returnString = JSON.stringify(returnObject);
console.log("returnString", returnString);
console.log("keys", Object.keys(returnObject));
console.log(Object.getOwnPropertyNames(returnObject), returnObject["001N0000016Shzx"])
$Lightning.use("c:LO_InteractionLogApp", function() {
$Lightning.createComponent("c:LO_InteractionLogComponent",
null,
"lightning",
function(cmp) {
var myExternalEvent;
myExternalEvent = $A.get("e.c:InteractionLogRelatedRecordsResponse");
myExternalEvent.setParams({
"response": returnString
});
myExternalEvent.fire();
});
});
}
});
}
}
};
In short in Salesforce console there are parent tabs and child tabs (its a workspace that allows you to open multiple records in one UI) and I am trying to get the record IDs of all records that are currently open via the integration toolkit. This is not so important but figured the context might help.