Copy link to clipboard
Copied
The following script attempts to delete a nested property that repeats itself inside a nested Javascript object 'oVendors'. Unfortunately, the script doesn't perform as intended and produces a syntax error on line 6 (delete.oVendors[key]['sq3'];). Anyone know what in the script needs to be changed to make this work? Thank you ahead of time.
// sample script to delete a pair of key-value properties, sq3 and sa3, from object 'oVendors'
dsFld =getField("dataSrc");
oVendors = JSON.parse(dsFld.value);
for(var key in oVendors){
if (oVendors[key].hasOwnProperty('sq3'))//check if prop exists
delete.oVendors[key]['sq3'];
if (oVendors[key].hasOwnProperty('sa3'))//check if prop exists
delete.oVendors[key]['sa3'];
}
dsFld.value=JSON.stringify(oVendors);
Copy link to clipboard
Copied
Please disregard post. For whatever reason, a period (.) was inadvertently inserted between the words delete and oVendors in the script. I guess I need to have my eyes checked.
Copy link to clipboard
Copied
Please disregard post. For whatever reason, a period (.) was inadvertently inserted between the words delete and oVendors in the script. I guess I need to have my eyes checked.

