Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
5

Javascript Syntax Error

Engaged ,
Dec 31, 2023 Dec 31, 2023

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);

TOPICS
How to , JavaScript
537
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
1 ACCEPTED SOLUTION
Engaged ,
Dec 31, 2023 Dec 31, 2023
LATEST

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. 

View solution in original post

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Dec 31, 2023 Dec 31, 2023
LATEST

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. 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines