Page 2 of 2 FirstFirst 12
Results 11 to 13 of 13

Thread: How to iterate the Json object for a web service call?

  1. #11
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    It's difficult to see just where the delimiters are and where the literal quotes belong. But I think it would be like so:

    Code:
    <td><a href="javascript:displayPaymentInfo(\'' + POId + '###${invoiceDetails.InvoiceId}\');" style="color:black">${invoiceDetails.InvoiceId}</a></td>
    I would caution against using javascript href though. You very rarely need to get yourself into a situation where this kind of thing is required. It's often easier to keep things straight by generating markup and functions separately.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  2. #12
    Join Date
    Dec 2016
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanks for your response John... Glad to receive your support..Unfortunately your syntax didn't work saying : Uncaught ReferenceError: POId is not defined(…)
    I've tried using in many ways infact, I'm calling my Javascript function there which is a seperate function

    Functionality was onclick of each Invoice, I should display my Payment details:

    My code::::

    /* Service Call for displaying Invoice list for a Purchase Order*/

    function displayInvoiceInfo(POId){
    url = "/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="+POId;

    $.ajax({
    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 ){
    var invoicelistdetails = `<tr width=100%>
    <td><a href="javascript:displayPaymentInfo(\'' + POId + '###${invoiceDetails.InvoiceId}\');" style="color:black">${invoiceDetails.InvoiceId}</a></td>
    <td><a href="" style="color:black">${invoiceDetails.InvoiceDate}</a></td>
    </tr>`;
    $("#poInvoiceListOutput").html(invoicelistdetails);

    });
    });
    }

    /* Service Call for displaying Payment list for an Invoice */

    function displayPaymentInfo(InvoiceId){
    alert(InvoiceId); //alert(POId);
    url = "/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=&InvoiceId="+InvoiceId;

    $.ajax({
    dataType:'json',
    type:'GET',
    contentType : 'application/json',
    url:url,
    }).
    then(function(paymentData) {
    //alert(JSON.stringify(paymentData));
    purchaseOrderList = paymentData.SupplierPOList.SupplierPOListDetails.SupplierPOHeader;
    purchaseInvoiceList = purchaseOrderList[0].SupplierInvoiceList.SupplierInvoiceHeader;
    $.each(purchaseInvoiceList[0].SupplierPaymentList.SupplierPaymentHeader, function( paymentIndex, paymentDetails ){
    alert(paymentDetails.PaymentId);
    var paymentListDetails = `<tr width=100%>
    <td><a href="" style="color:black">${paymentDetails.PaymentId}</a></td>
    </tr>`;
    $("#invoicePaymentListOutput").html(paymentListDetails);
    });
    });
    }

    Your help is appreciated!! Thanks

  3. #13
    Join Date
    Dec 2016
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    working now

    Thank you !

Similar Threads

  1. Replies: 1
    Last Post: 03-26-2016, 02:37 PM
  2. Replies: 1
    Last Post: 08-01-2011, 06:54 AM
  3. Replies: 15
    Last Post: 05-10-2011, 03:55 AM
  4. Replies: 2
    Last Post: 07-13-2009, 10:42 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •