875 JSONata Example
(
$shippingAddresses := $lookupLoopInstances(message.transactionSets[0].N1_loop, message.transactionSets[0].N1_loop.partyIdentification[0].entityIdentifierCode, ["ST", "BS", "SD", "BY"])[0];
$billingAddresses := $lookupLoopInstances(message.transactionSets[0].N1_loop, message.transactionSets[0].N1_loop.partyIdentification[0].entityIdentifierCode, ["BT", "BY"])[0];
{
"metaData": {
"orderfulId": id,
"linkInOrderful": href,
"version": version,
"type": type.name,
"production": stream = "PRODUCTION",
"referenceNumber": businessNumber,
"validationStatus": validationStatus,
"deliveryStatus": deliveryStatus,
"acknowledgementStatus": acknowledgmentStatus,
"createdAt": createdAt,
"lastUpdatedAt": lastUpdatedAt,
"tradingPartnerId": sender.isaId,
"tradingPartnerName": sender.name,
"companyTradingPartnerId": receiver.isaId,
"autoAcknowledgeIfInventoryOnHand": true,
"customerConfig": {
"customer_internal": $customer.id,
"custentity_orderful_isa_id": $customer.prodIsaId,
"custentity_orderful_isa_id_test": $customer.testIsaId,
"custentity_orderful_use_850_date": $customer.use850Date ? "T" : "F",
"custrecord_edi_enab_trans_customer": $customer.id,
"custentity_orderful_auto_acknowledge": "F",
"useEDIPricing": false
}
},
"transaction": {
"purposeCode": message.transactionSets[0].purchaseOrderIdentification[0].orderStatusCode,
"date": message.transactionSets[0].purchaseOrderIdentification[0].date,
"requestedShipDate": message.transactionSets[0].dateTime[0] ~> $lookupQualifiedValues("10") ~> $first(),
"mustShipBy": message.transactionSets[0].dateTime[0] ~> $lookupQualifiedValues("38") ~> $first(),
"earliestDelivery": null,
"latestDelivery": message.transactionSets[0].dateTime[0] ~> $lookupQualifiedValues("02") ~> $ifNullThen(message.transactionSets[0].dateTime[0] ~> $lookupQualifiedValues("68")) ~> $first(),
"messageBlock": message.transactionSets[0].noteSpecialInstruction.(noteReferenceCode & ": " & description) ~> $join("\n"),
"backorderAllowed": true,
"currencyCode": null,
"purchaseOrderNumber": message.transactionSets[0].extendedReferenceInformation[0] ~> $lookupQualifiedValues("PO") ~> $join(" ") ~> $ifNullThen(message.transactionSets[0].purchaseOrderIdentification[0].purchaseOrderNumber),
"additionalPurchaseOrderNumbers": message.transactionSets[0].extendedReferenceInformation[0] ~> $lookupQualifiedValues("AN") ~> $join(" "),
"orderNumber": message.transactionSets[0].extendedReferenceInformation[0] ~> $lookupQualifiedValues("OQ") ~> $join(" "),
"customerOrderNumber": message.transactionSets[0].extendedReferenceInformation[0] ~> $lookupQualifiedValues("CO") ~> $join(" "),
"orderTypeCode": message.transactionSets[0].purchaseOrderIdentification[0].purchaseOrderTypeCode,
"storeNumber": message.transactionSets[0].extendedReferenceInformation[0] ~> $lookupQualifiedValues("ST") ~> $join(" "),
"division": message.transactionSets[0].extendedReferenceInformation[0] ~> $lookupQualifiedValues("19") ~> $join(" "),
"vendorNumber": message.transactionSets[0].extendedReferenceInformation[0] ~> $lookupQualifiedValues("IA") ~> $join(" "),
"departmentNumber": message.transactionSets[0].extendedReferenceInformation[0] ~> $lookupQualifiedValues("DP") ~> $join(" "),
"department": message.transactionSets[0].extendedReferenceInformation[0] ~> $lookupQualifiedValues("DP") ~> $first() ~> $lookupRecords("department") ~> $lookup("id"),
"mutuallyDefined": message.transactionSets[0].extendedReferenceInformation[0] ~> $lookupQualifiedValues("ZZ") ~> $join(" "),
"promoDealNumber": message.transactionSets[0].extendedReferenceInformation[0] ~> $lookupQualifiedValues("PD") ~> $join(" "),
"ediRouting": message.transactionSets[0].transportationInstructions[0].routing,
"shippingAddress": {
"attention": null,
"addressee": $shippingAddresses.partyIdentification[0].name,
"country": $shippingAddresses.geographicLocation[0].countryCode ~> $substring(0, 2),
"addr1": $shippingAddresses.partyLocation[0].addressInformation,
"addr2": $shippingAddresses.partyLocation[0].addressInformation1,
"city": $shippingAddresses.geographicLocation[0].cityName,
"state": $shippingAddresses.geographicLocation[0].stateOrProvinceCode,
"zip": $shippingAddresses.geographicLocation[0].postalCode,
"ediId": $shippingAddresses.partyIdentification[0].identificationCode
},
"billingAddress": {
"attention": null,
"addressee": $billingAddresses.partyIdentification[0].name,
"country": $billingAddresses.geographicLocation[0].countryCode ~> $substring(0, 2),
"addr1": $billingAddresses.partyLocation[0].addressInformation,
"addr2": $billingAddresses.partyLocation[0].addressInformation1,
"city": $billingAddresses.geographicLocation[0].cityName,
"state": $billingAddresses.geographicLocation[0].stateOrProvinceCode,
"zip": $billingAddresses.geographicLocation[0].postalCode,
"ediId": $billingAddresses.partyIdentification[0].identificationCode
},
"shipToId": $shippingAddresses.partyIdentification[0].identificationCode,
"sendFromTradingPartnerId": sender.isaId,
"sentToTradingPartnerId": receiver.isaId,
"contacts": {
"informational": message.transactionSets[0].contact ~> $lookupContact("IC"),
"mutuallyDefined": message.transactionSets[0].contact ~> $lookupContact("ZZ"),
"general": message.transactionSets[0].contact ~> $lookupContact("CN"),
"ediCoordinator": message.transactionSets[0].contact ~> $lookupContact("EA"),
"orderContact": message.transactionSets[0].contact ~> $lookupContact("OC"),
"receivingContact": message.transactionSets[0].contact ~> $lookupContact("RE"),
"buyerName": message.transactionSets[0].contact ~> $lookupContact("BD"),
"scheduleContact": message.transactionSets[0].contact ~> $lookupContact("SC")
},
"discounts": message.transactionSets[0].G72_loop.(
$code := allowanceOrCharge[0].allowanceOrChargeCode;
{
"code": $code,
"processMethod": allowanceOrCharge[0].allowanceOrChargeMethodOfHandlingCode,
"amount": allowanceOrCharge[0].allowanceOrChargeTotalAmount,
"percentDecimal": ($number(allowanceOrCharge[0].percentDecimalFormat) / 100) ~> $round(2),
"id": [$authorizedDiscounts[allowanceChargeCode = $code]][0].id,
"nsItemId": [$authorizedDiscounts[allowanceChargeCode = $code]][0].itemInternalId
}
) ~> $ifNullThen([]),
"entityNetSuiteId": $customer.id,
"locationLookup": {
"autoAssignValid": false,
"singleLocation": 1,
"uniqueLocationsByItem": []
},
"subsidiary": $customer.subsidiaryId,
"dcNumber": null,
"shippingAccountNumber": null,
"totalAmount": message.transactionSets[0].totalPurchaseOrder[0].amount ~> $ifNullThen(0)
},
"transactionLines": message.transactionSets[0].G68_loop.(
$upc := lineItemDetail[0].UPCCaseCode ~> $ifNullThen($lookupQualifiedValues(lineItemDetail[0], "UP")[0]);
$nsItem := $lookupItems($upc, "upccode")[0];
{
"orderedQuantity": lineItemDetail[0].quantity,
"unitLabelEDI": lineItemDetail[0].unitOrBasisForMeasurementCode,
"orderedUnitPrice": lineItemDetail[0].itemListCost,
"item": $.{
"universal": $.{
"upc": $upc,
"ean": $lookupQualifiedValues(lineItemDetail[0], "EN")[0],
"gtin": $lookupQualifiedValues(lineItemDetail[0], "UK")[0],
"upcCaseCode": $lookupQualifiedValues(lineItemDetail[0], "UA")[0],
"eanUCC8": $lookupQualifiedValues(lineItemDetail[0], "EO")[0]
},
"buyer": $.{
"buyerPartNumber": $lookupQualifiedValues(lineItemDetail[0], "BP")[0],
"buyerItemNumber": $lookupQualifiedValues(lineItemDetail[0], "IN")[0],
"buyerCatalogNumber": $lookupQualifiedValues(lineItemDetail[0], "CB")[0],
"sku": $lookupQualifiedValues(lineItemDetail[0], "SK")[0],
"buyerStyleNumber": $lookupQualifiedValues(lineItemDetail[0], "IT")[0]
},
"seller": $.{
"vendorPartNumber": $lookupQualifiedValues(lineItemDetail[0], "VP")[0],
"vendorNumber": $lookupQualifiedValues(lineItemDetail[0], "VN")[0],
"vendorStyleNumber": $lookupQualifiedValues(lineItemDetail[0], "VA")[0],
"vendorCatalogNumber": $lookupQualifiedValues(lineItemDetail[0], "VC")[0]
},
"netsuiteItemId": $nsItem.id
},
"priceBracketID": lineItemDetail[0].priceBracketIdentifier,
"priceListNumber": lineItemDetail[0].priceListNumber,
"originalItemData": lineItemDetail[0],
"class": $nsItem.class ~> $number(),
"nsUnitId": $nsItem.saleunit,
"storeQuantities": [],
"discount": $.(
$code := G72_loop[0].allowanceOrCharge[0].allowanceOrChargeCode;
$code ? {
"code": $code,
"processMethod": G72_loop[0].allowanceOrCharge[0].allowanceOrChargeMethodOfHandlingCode,
"amount": G72_loop[0].allowanceOrCharge[0].allowanceOrChargeTotalAmount,
"id": ([$authorizedDiscounts[allowanceChargeCode = $code]][0]).internalId,
"nsItemId": ([$authorizedDiscounts[allowanceChargeCode = $code]][0]).itemInternalId
} : undefined
)
}
)
}
)
Updated 7 days ago