-
December 1st, 2016, 01:46 PM
#1
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!!!!
-
December 1st, 2016, 01:59 PM
#2
Re: How to iterate the Json object for a web service call?
Has this question been posted on another forum?
All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!
C++23 Compiler: Microsoft VS2022 (17.6.5)
-
December 2nd, 2016, 11:40 AM
#3
Re: How to iterate the Json object for a web service call?
-
December 2nd, 2016, 12:39 PM
#4
Re: How to iterate the Json object for a web service call?
Norm
-
December 2nd, 2016, 12:51 PM
#5
Re: How to iterate the Json object for a web service call?
"I've posted in Java forum
Couldn't find JavaScript Forum"
-
December 2nd, 2016, 01:40 PM
#6
Re: How to iterate the Json object for a web service call?
Originally Posted by shruz
"I've posted in Java forum
Couldn't find JavaScript Forum"
Scripting - Client side.
[Thread moved]
All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!
C++23 Compiler: Microsoft VS2022 (17.6.5)
-
December 2nd, 2016, 02:10 PM
#7
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!!
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|