How to iterate the Json object for a web service call?
Below is my payload for a given WebService in JSON format:
{
"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:
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!!!!
Re: How to iterate the Json object for a web service call?
Quote:
0
down vote
accept
Has this question been posted on another forum?
Re: How to iterate the Json object for a web service call?
Re: How to iterate the Json object for a web service call?
Re: How to iterate the Json object for a web service call?
"I've posted in Java forum
Couldn't find JavaScript Forum"
Re: How to iterate the Json object for a web service call?
Quote:
Originally Posted by
shruz
"I've posted in Java forum
Couldn't find JavaScript Forum"
Scripting - Client side.
[Thread moved]
Re: How to iterate the Json object for a web service call?
I'm able to loop and able to display the data but was facing some issue that unable to display all the values in the list even though they have the respective invoice details in the pay load:
dataType:'json',
type:'GET',
contentType : 'application/json',
url:url,
}).
then(function(poInvoiceData) {
alert(JSON.stringify(poInvoiceData));
poInvoiceList = poInvoiceData.SupplierPOList.SupplierPOListDetails.SupplierPOHeader;
$.each(poInvoiceList[0].SupplierInvoiceList.SupplierInvoiceHeader, function( invoiceIndex, invoiceDetails ){
Suggestions are appreciated!!