var itms = root.getChild('SaleRecord', NS).getChildren() //Logger.log(itms); var values = itms.map(e => { var item = e.getChild('SaleRecordID', NS); Logger.log(item); var sku = e.getChild('CustomLabel', NS); Logger.log(sku); var title = e.getChild('ItemTitle', NS); Logger.log(title); var qty = e.getChild('QuantitySold', NS) Logger.log(qty); var id = e.getChild('OrderLineItemID', NS) Logger.log(id); return [item ? item.getText() : "", sku ? sku.getText() : "", title ? title.getText() : "", qty ? qty.getText() : "", id ? id.getText() : ""]; }); Logger.log('Value Lengh:'+ values[0].length) sheet.getRange(sheet.getLastRow() + 1, 1, values.length, values[0].length).setValues(values);
<?xml version="1.0" encoding="utf-8"?>
<GetSellingManagerSoldListingsResponse xmlns="urn:ebay:apis:eBLBaseComponents">
<!-- Call-specific Output Fields -->
<PaginationResult> PaginationResultType
<TotalNumberOfEntries> int </TotalNumberOfEntries>
<TotalNumberOfPages> int </TotalNumberOfPages>
</PaginationResult>
<SaleRecord> SellingManagerSoldOrderType
<BuyerEmail> string </BuyerEmail>
<BuyerID> string </BuyerID>
<CashOnDeliveryCost currencyID="CurrencyCodeType"> AmountType (double) </CashOnDeliveryCost>
<CreationTime> dateTime </CreationTime>
<DaysSinceSale> int </DaysSinceSale>
<ItemCost currencyID="CurrencyCodeType"> AmountType (double) </ItemCost>
<OrderStatus> SellingManagerOrderStatusType
<CheckoutStatus> CheckoutStatusCodeType </CheckoutStatus>
<FeedbackReceived> CommentTypeCodeType </FeedbackReceived>
<FeedbackSent> boolean </FeedbackSent>
<IntegratedMerchantCreditCardEnabled> boolean </IntegratedMerchantCreditCardEnabled>
<PaidStatus> SellingManagerPaidStatusCodeType </PaidStatus>
<PaidTime> dateTime </PaidTime>
<PaymentHoldStatus> PaymentHoldStatusCodeType </PaymentHoldStatus>
<PaymentMethodUsed> BuyerPaymentMethodCodeType </PaymentMethodUsed>
<ShippedStatus> SellingManagerShippedStatusCodeType </ShippedStatus>
<ShippedTime> dateTime </ShippedTime>
<TotalEmailsSent> int </TotalEmailsSent>
</OrderStatus>
<SalePrice currencyID="CurrencyCodeType"> AmountType (double) </SalePrice>
<SaleRecordID> long </SaleRecordID>
<SellingManagerSoldTransaction> SellingManagerSoldTransactionType
<CharityListing> boolean </CharityListing>
<CustomLabel> string </CustomLabel>
<ItemID> ItemIDType (string) </ItemID>
<ItemTitle> string </ItemTitle>
<ListedOn> TransactionPlatformCodeType </ListedOn>
<!-- ... more ListedOn values allowed here ... -->
<ListingType> ListingTypeCodeType </ListingType>
<OrderLineItemID> string </OrderLineItemID>
<QuantitySold> int </QuantitySold>
<Relisted> boolean </Relisted>
<ReservePrice currencyID="CurrencyCodeType"> AmountType (double) </ReservePrice>
<SaleRecordID> long </SaleRecordID>
<SecondChanceOfferSent> boolean </SecondChanceOfferSent>
<SoldOn> TransactionPlatformCodeType </SoldOn>
<StartPrice currencyID="CurrencyCodeType"> AmountType (double) </StartPrice>
<TransactionID> long </TransactionID>
<Variation> VariationType </Variation>
<WatchCount> int </WatchCount>
</SellingManagerSoldTransaction>
<!-- ... more SellingManagerSoldTransaction nodes allowed here ... -->
<ShippingAddress> AddressType
<Name> string </Name>
<PostalCode> string </PostalCode>
</ShippingAddress>
<ShippingDetails> ShippingDetailsType
<ShippingType> ShippingTypeCodeType </ShippingType>
</ShippingDetails>
<TotalAmount currencyID="CurrencyCodeType"> AmountType (double) </TotalAmount>
<TotalQuantity> int </TotalQuantity>
<UnpaidItemStatus> UnpaidItemStatusTypeCodeType </UnpaidItemStatus>
</SaleRecord>
<!-- ... more SaleRecord nodes allowed here ... -->
<!-- Standard Output Fields -->
<Ack> AckCodeType </Ack>
<Build> string </Build>
<CorrelationID> string </CorrelationID>
<Errors> ErrorType
<ErrorClassification> ErrorClassificationCodeType </ErrorClassification>
<ErrorCode> token </ErrorCode>
<ErrorParameters ParamID="string"> ErrorParameterType
<Value> string </Value>
</ErrorParameters>
<!-- ... more ErrorParameters nodes allowed here ... -->
<LongMessage> string </LongMessage>
<SeverityCode> SeverityCodeType </SeverityCode>
<ShortMessage> string </ShortMessage>
</Errors>
<!-- ... more Errors nodes allowed here ... -->
<HardExpirationWarning> string </HardExpirationWarning>
<Timestamp> dateTime </Timestamp>
<Version> string </Version>
</GetSellingManagerSoldListingsResponse>
[20-09-24 19:15:45:313 BST] Success
[20-09-24 19:15:45:315 BST] 2020-09-24T18:15:45.157Z
[20-09-24 19:15:45:323 BST] 40
[20-09-24 19:15:45:378 BST] [Element: <SaleRecordID [Namespace: urn:ebay:apis:eBLBaseComponents]/>]
[20-09-24 19:15:45:383 BST] [Element: <CustomLabel [Namespace: urn:ebay:apis:eBLBaseComponents]/>]
[20-09-24 19:15:45:386 BST] [Element: <ItemTitle [Namespace: urn:ebay:apis:eBLBaseComponents]/>]
[20-09-24 19:15:45:389 BST] [Element: <QuantitySold [Namespace: urn:ebay:apis:eBLBaseComponents]/>]
[20-09-24 19:15:45:393 BST] [Element: <OrderLineItemID [Namespace: urn:ebay:apis:eBLBaseComponents]/>]
[20-09-24 19:15:45:399 BST] null
[20-09-24 19:15:45:401 BST] null
[20-09-24 19:15:45:404 BST] null
[20-09-24 19:15:45:407 BST] null
[20-09-24 19:15:45:409 BST] null
[20-09-24 19:15:45:413 BST] null
[20-09-24 19:15:45:415 BST] null
[20-09-24 19:15:45:417 BST] null
[20-09-24 19:15:45:419 BST] null
[20-09-24 19:15:45:422 BST] null
[20-09-24 19:15:45:424 BST] null
[20-09-24 19:15:45:428 BST] null
[20-09-24 19:15:45:431 BST] null
[20-09-24 19:15:45:433 BST] null
[20-09-24 19:15:45:436 BST] null
[20-09-24 19:15:45:438 BST] null
[20-09-24 19:15:45:441 BST] null
[20-09-24 19:15:45:446 BST] null
[20-09-24 19:15:45:449 BST] null
[20-09-24 19:15:45:451 BST] null
[20-09-24 19:15:45:454 BST] null
[20-09-24 19:15:45:456 BST] null
[20-09-24 19:15:45:459 BST] null
[20-09-24 19:15:45:461 BST] null
[20-09-24 19:15:45:462 BST] null
[20-09-24 19:15:45:464 BST] null
[20-09-24 19:15:45:466 BST] null
[20-09-24 19:15:45:468 BST] null
[20-09-24 19:15:45:470 BST] null
[20-09-24 19:15:45:473 BST] null
[20-09-24 19:15:45:475 BST] null
[20-09-24 19:15:45:478 BST] null
[20-09-24 19:15:45:480 BST] null
[20-09-24 19:15:45:482 BST] null
[20-09-24 19:15:45:484 BST] null
[20-09-24 19:15:45:486 BST] null
[20-09-24 19:15:45:488 BST] null
[20-09-24 19:15:45:491 BST] null
[20-09-24 19:15:45:493 BST] null
[20-09-24 19:15:45:495 BST] null
[20-09-24 19:15:45:497 BST] null
[20-09-24 19:15:45:499 BST] null
[20-09-24 19:15:45:502 BST] null
[20-09-24 19:15:45:504 BST] null
[20-09-24 19:15:45:506 BST] null
[20-09-24 19:15:45:508 BST] null
[20-09-24 19:15:45:511 BST] null
[20-09-24 19:15:45:513 BST] null
[20-09-24 19:15:45:516 BST] null
[20-09-24 19:15:45:519 BST] null
[20-09-24 19:15:45:521 BST] null
[20-09-24 19:15:45:523 BST] null
[20-09-24 19:15:45:526 BST] null
[20-09-24 19:15:45:528 BST] null
[20-09-24 19:15:45:530 BST] null
[20-09-24 19:15:45:532 BST] null
[20-09-24 19:15:45:534 BST] null
[20-09-24 19:15:45:537 BST] null
[20-09-24 19:15:45:540 BST] null
[20-09-24 19:15:45:542 BST] null
It produces an array then sends it to the sheet. The part which sends it to the sheets is here:
sheet.getRange(sheet.getLastRow() + 1, 1, values.length, values[0].length).setValues(values);
Hi @ cy66oTa
It oroduces and array then sends it to the sheet. The part which sends it to the sheets is
var itms = root.getChild('SaleRecord', NS).getChild('SellingManagerSoldTransaction', NS).getChildren();
Logger.log(root.getChild('SaleRecord', NS).getChild('SellingManagerSoldTransaction', NS).getChild('OrderLineItemID', NS).getText());
Logger.log(root.getChild('SaleRecord', NS).getChildren().length)
var values = itms.map(e => {
var item = e.getChild('SaleRecordID', NS);
Logger.log('Item ' + item);
var sku = e.getChild('CustomLabel', NS);
Logger.log('sku ' + sku);
var title = e.getChild('ItemTitle', NS);
Logger.log('title '+title);
var qty = e.getChild('QuantitySold', NS);
Logger.log('qty '+qty);
var id = e.getChild('OrderLineItemID', NS);
Logger.log('id '+id);
return [item ? item.getText() : "",
sku ? sku.getText() : "",
title ? title.getText() : "",
qty ? qty.getText() : "",
id ? id.getText() : ""];
});
//Logger.log('Value Lengh:'+ values[0].length)
sheet.getRange(sheet.getLastRow() + 1, 1, values.length, values[0].length).setValues(values);
[20-09-27 09:48:06:916 PDT] Success[20-09-27 09:48:06:919 PDT] 2020-09-27T16:48:06.818Z[20-09-27 09:48:06:924 PDT] Page# 1[20-09-27 09:48:07:058 PDT] Number of Orders 78[20-09-27 09:48:07:069 PDT] 160989605461-2048236393006[20-09-27 09:48:07:081 PDT] 13.0[20-09-27 09:48:07:084 PDT] Item null[20-09-27 09:48:07:086 PDT] sku null[20-09-27 09:48:07:089 PDT] title null[20-09-27 09:48:07:091 PDT] qty null[20-09-27 09:48:07:094 PDT] id null[20-09-27 09:48:07:096 PDT] Item null[20-09-27 09:48:07:099 PDT] sku null[20-09-27 09:48:07:101 PDT] title null[20-09-27 09:48:07:103 PDT] qty null[20-09-27 09:48:07:105 PDT] id null[20-09-27 09:48:07:107 PDT] Item null[20-09-27 09:48:07:109 PDT] sku null[20-09-27 09:48:07:111 PDT] title null[20-09-27 09:48:07:114 PDT] qty null[20-09-27 09:48:07:116 PDT] id null[20-09-27 09:48:07:118 PDT] Item null[20-09-27 09:48:07:120 PDT] sku null[20-09-27 09:48:07:122 PDT] title null[20-09-27 09:48:07:124 PDT] qty null[20-09-27 09:48:07:126 PDT] id null[20-09-27 09:48:07:128 PDT] Item null[20-09-27 09:48:07:130 PDT] sku null[20-09-27 09:48:07:132 PDT] title null[20-09-27 09:48:07:134 PDT] qty null[20-09-27 09:48:07:136 PDT] id null[20-09-27 09:48:07:139 PDT] Item null[20-09-27 09:48:07:141 PDT] sku null[20-09-27 09:48:07:143 PDT] title null[20-09-27 09:48:07:145 PDT] qty null[20-09-27 09:48:07:147 PDT] id null[20-09-27 09:48:07:149 PDT] Item null[20-09-27 09:48:07:151 PDT] sku null[20-09-27 09:48:07:153 PDT] title null[20-09-27 09:48:07:155 PDT] qty null[20-09-27 09:48:07:157 PDT] id null[20-09-27 09:48:07:158 PDT] Item null[20-09-27 09:48:07:160 PDT] sku null[20-09-27 09:48:07:162 PDT] title null[20-09-27 09:48:07:164 PDT] qty null[20-09-27 09:48:07:166 PDT] id null[20-09-27 09:48:07:167 PDT] Item null[20-09-27 09:48:07:169 PDT] sku null[20-09-27 09:48:07:171 PDT] title null[20-09-27 09:48:07:172 PDT] qty null[20-09-27 09:48:07:173 PDT] id null[20-09-27 09:48:07:175 PDT] Item null[20-09-27 09:48:07:176 PDT] sku null[20-09-27 09:48:07:178 PDT] title null[20-09-27 09:48:07:179 PDT] qty null[20-09-27 09:48:07:181 PDT] id null[20-09-27 09:48:07:182 PDT] Item null[20-09-27 09:48:07:184 PDT] sku null[20-09-27 09:48:07:186 PDT] title null[20-09-27 09:48:07:187 PDT] qty null[20-09-27 09:48:07:189 PDT] id null[20-09-27 09:48:07:191 PDT] Item null[20-09-27 09:48:07:193 PDT] sku null[20-09-27 09:48:07:195 PDT] title null[20-09-27 09:48:07:197 PDT] qty null[20-09-27 09:48:07:199 PDT] id null[20-09-27 09:48:07:201 PDT] Item null[20-09-27 09:48:07:203 PDT] sku null[20-09-27 09:48:07:205 PDT] title null[20-09-27 09:48:07:207 PDT] qty null[20-09-27 09:48:07:209 PDT] id null
Hi,How is structured each element of the array?In my humble opinion you should replace the map function by a for loop because it would be easier to debug the state of the array prior to send it to the sheet.Pedro