Home > database >  How to do a for loop in a array with a index that contain object
How to do a for loop in a array with a index that contain object

Time:05-31

I'm trying to do a for loop in a array like this:

 a0C7X0000056xmxUAA: {
   attributes: {
     type: 'GRD__c',
     url: '/services/data/v53.0/sobjects/GRD__c/a0C7X0000056xmxUAA'
   },
   Id: 'a0C7X0000056xmxUAA',
   Name: 'Lote-6155066',
   Guia__c: [ a0Y7X000006RUHxUAO: [Object], a0Y7X000006RUI2UAO: [Object] ]
 },
 a0C7X0000056x9EUAQ: {
   attributes: {
     type: 'GRD__c',
     url: '/services/data/v53.0/sobjects/GRD__c/a0C7X0000056x9EUAQ'
   },
   Id: 'a0C7X0000056x9EUAQ',
   Name: 'Lote-6155065',
   Guia__c: []
 },
 a0C7X0000056x99UAA: {
   attributes: {
     type: 'GRD__c',
     url: '/services/data/v53.0/sobjects/GRD__c/a0C7X0000056x99UAA'
   },
   Id: 'a0C7X0000056x99UAA',
   Name: 'Lote-6155064',
   Guia__c: [
     a0Y7X000006RSSvUAO: [Object],
     a0Y7X000006RST0UAO: [Object],
     a0Y7X000006RST1UAO: [Object]
   ]
 },
 a0C7X0000056x8YUAQ: {
   attributes: {
     type: 'GRD__c',
     url: '/services/data/v53.0/sobjects/GRD__c/a0C7X0000056x8YUAQ'
   },
   Id: 'a0C7X0000056x8YUAQ',
   Name: 'Lote-6155063',
   Guia__c: [ a0Y7X000006RSR9UAO: [Object], a0Y7X000006RSREUA4: [Object] ]
 },
 a0C7X0000056wmxUAA: {
   attributes: {
     type: 'GRD__c',
     url: '/services/data/v53.0/sobjects/GRD__c/a0C7X0000056wmxUAA'
   },
   Id: 'a0C7X0000056wmxUAA',
   Name: 'Lote-6155062',
   Guia__c: [ a0Y7X000006RSR4UAO: [Object] ]
 },
 a0C7X0000056wmsUAA: {
   attributes: {
     type: 'GRD__c',
     url: '/services/data/v53.0/sobjects/GRD__c/a0C7X0000056wmsUAA'
   },
   Id: 'a0C7X0000056wmsUAA',
   Name: 'Lote-6155061',
   Guia__c: [ a0Y7X000006RSQzUAO: [Object] ]
 },
 a0C7X0000056wmnUAA: {
   attributes: {
     type: 'GRD__c',
     url: '/services/data/v53.0/sobjects/GRD__c/a0C7X0000056wmnUAA'
   },
   Id: 'a0C7X0000056wmnUAA',
   Name: 'Lote-6155060',
   Guia__c: [ a0Y7X000006RSQpUAO: [Object], a0Y7X000006RSQuUAO: [Object] ]
 },
 a0C7X0000056wmYUAQ: {
   attributes: {
     type: 'GRD__c',
     url: '/services/data/v53.0/sobjects/GRD__c/a0C7X0000056wmYUAQ'
   },
   Id: 'a0C7X0000056wmYUAQ',
   Name: 'Lote-6155059',
   Guia__c: [ a0Y7X000006RSQLUA4: [Object], a0Y7X000006RSQQUA4: [Object] ]
 },
 a0C7X0000056wmTUAQ: {
   attributes: {
     type: 'GRD__c',
     url: '/services/data/v53.0/sobjects/GRD__c/a0C7X0000056wmTUAQ'
   },
   Id: 'a0C7X0000056wmTUAQ',
   Name: 'Lote-6155058',
   Guia__c: [
     a0Y7X000006RSQGUA4: [Object],
     a0Y7X000006RSQVUA4: [Object],
     a0Y7X000006RSQaUAO: [Object],
     a0Y7X000006RSQfUAO: [Object],
     a0Y7X000006RSQkUAO: [Object]
   ]
 },
 a0C7X0000056wmOUAQ: {
   attributes: {
     type: 'GRD__c',
     url: '/services/data/v53.0/sobjects/GRD__c/a0C7X0000056wmOUAQ'
   },
   Id: 'a0C7X0000056wmOUAQ',
   Name: 'Lote-6155057',
   Guia__c: [ a0Y7X000006RSQBUA4: [Object] ]
 }
]

but when I try to do a loop nothing happens, i'm doing like this because during the execution i need to add new keys like Guia__c and inside of Guia__c i need to put i new one, this already happen but the problem is to do the loop, and when i try to convert the array to a string nothing returns

CodePudding user response:

Object.values(mapGRD__c)

is necessary to resolve this case

Like this:

for(let objectGRD__c of Object.values(mapGRD__c)) {
 ...Logic
} 
  • Related