How to iterate the Json object for a web service call?
Below is my payload for a given WebService in JSON format:
Code:
{
"SupplierPOList": {
"RowCount": 1,
"SupplierPOListDetails": {
"SupplierPOHeader": [
{
"VendorSetid": "STATE",
"VendorId": "0000099475",
"POBusinessUnit": "DRC01",
"POId": "0000128530",
"PODate": "2014-01-13",
"ActivityDate": "2014-02-25",
"EnteredDate": "2014-01-13",
"DispatchDateTime": "2014-01-16T11:10:45.000000-05:00",
"DueDate": "2014-01-13",
"POAmount": 460.63,
"Buyer": "eSettlements Buyer User",
"PaymentTerms": "Net 30",
"CurrencyCd": "USD",
"OnHold": "No",
"POStatus": "Complete",
"POAckStatus": "Not Required",
"RecvStatus": "PO Not Received",
"SupplierPOLineList": {...},
"SupplierInvoiceList": {
"POBusinessUnit": "DRC01",
"POId": "0000128530",
"SupplierInvoiceHeader": [
{
"InvoiceDate": "2014-01-27",
"InvoiceId": "6942150",
"EnteredDate": "2014-02-03",
"InvoiceAmount": 460.63,
"APBusinessUnit": "DRC01",
"VoucherId": "00791073",
"DueDate": "2014-02-26",
"CurrencyCd": "USD",
"PaymentTerms": "Net 30",
"SupplierPaymentList": {
"APBusinessUnit": "DRC01",
"VoucherId": "00791073",
"SupplierPaymentHeader": [
{
"PaymentDate": "2014-02-26",
"PaymentId": "0007275500",
"PaymentIdRef": "0003501364",
"InvoiceId": "6942150",
"InvoiceDate": "2014-01-27",
"PaymentAmount": 460.63,
"CurrencyCd": "USD",
"PaymentMethod": "Electronic Funds Transfer",
"Name1": "HAZELDEN",
"Name2": null,
"Country": "USA",
"Address1": "PO BOX 176",
"Address2": null,
"Address3": null,
"Address4": null,
"City": "CENTER CITY",
"State": "MN",
"Postal": "55012-0176",
"BankAccount": "*****0207",
"PaymentStatus": "Paid"
}
],
}
}
],
}
}
],
}
}
}
How can I retrieve SupplierInvoiceHeader and the below operations in my service call? I'm able to produce data until SupplierInvoiceList with the below code:
Code:
0
down vote
accept
$.ajax({url:"/wps/proxy/http/10.249.114.31:8009/soa-infra/resources/SupplierPortal/GetSupplierPOListService!1.0/GetSupplierPOListService/Get?RecordName=OH_ESA_P_AL_LVW&VendorId=0000099475&VendorSetid=STATE&DateFrom=2014-01-01&DateTo=2015-01-01&ShowDetail=Y&POId=", dataType:'json'
}).
then(function(poInvoiceData) {
poInvoiceList = poInvoiceData.SupplierPOList.SupplierPOListDetails.SupplierPOHeader;
poInvoiceList1 = poInvoiceList.SupplierInvoiceList.SupplierInvoiceHeader;
// poInvoiceList2 = poInvoiceList1.SupplierInvoiceHeader;
console.log("poInvoiceData",poInvoiceData);
console.log("poInvoiceList",poInvoiceList);
poInvoiceTemplate = generatePOInvoice(poInvoiceList1);
$("#poInvoiceListOutput").html(poInvoiceTemplate);
});
function generatePOInvoice(poInvoiceList1) {
let poInvoiceTemplate = '';
for (poInvoice of poInvoiceList) {
console.log("poInvoice=",poInvoice);
poInvoiceTemplate+=`<tr width=100%>
<td><a href="" style="color:black">${poInvoice.PaymentTerms}</a></td>
</tr>`;
}
console.log("poInvoiceTemplate",poInvoiceTemplate);
return poInvoiceTemplate;
}
Your help is highly appreciable!!!!