This topic contains 6 replies, has 0 voices, and was last updated by Vesku1980 7 years, 8 months ago.

  • Author
    Posts
  • #5679 Score: 0

    jessie
    • Contributions: 0
    • Level 1

    The business goal is to retrieve the location from the invoice the payment is created from and set the payment.location to invoice.location. The code below fires in Post Sourcing Function

    I’ve used the following code but it is not working:

    Code:
    itemCount = nlapiGetLineItemCount(‘apply’);
    nlapiSelectLineItem(‘apply’, 1);
    var transactionId = nlapiGetCurrentLineItemValue(‘apply’, ‘internalid’);
    itemCount is returning value of 1 which I believe is correct.

    transactionId is returning NULL

    Any thoughts on what I am doing wrong or alternative methods to achieve the goal?
    This is a cached copy. Click here to see the original post.

  • #5680 Score: 0

    david.smith
    • Contributions: 0
    • Level 1

    On a payment you should do this on an after submit function. Payments can be applied to more than one invoice.

  • #5681 Score: 0

    Vesku1980
    • Contributions: 0
    • Level 1

    Hi.

    I have met some problems when using nlapiSelectLineItem api.

    Is there always just one row in apply sublist?

    If not then you need a for loop to go through all the lines.

    Try just nlapiGetLineItemValue api to get wanted value. It is also possible that field you are searching is id not internalid.

    If you are using chrome browser console is a great tool to execute these apis that are in use also in client scripts.

    Vesku

  • #5682 Score: 0

    jessie
    • Contributions: 0
    • Level 1

    david.smith The after submit function would be too late. The business goal is to “default” the value of payment.location based on the invoice the payment was created. If the user wants to change the location, then they are allowed to do so.

  • #5683 Score: 0

    jessie
    • Contributions: 0
    • Level 1

    Vesku1980 Thanks for the pointer on nlapiGetLineItemValue. Unfortunately, the same behavior occurs. The nlapiGetLineItemCount returns 1 but when I use nlapiGetLineItemValue, I get null returned. From looking at the raw xml, I’ve tested various fields and all return null. I am wondering if the “apply” list is not yet full populated.

    Any ideas on how to debug?

  • #5684 Score: 0

    jessie
    • Contributions: 0
    • Level 1

    Vesku1980 Ugh – always check the Schema browser not the XML… The field to use is “doc” not “internalId”.


    Vesku1980 replied on 12/08/2016, 10:42 PM: So, problem is solved?

    I usually use debugger domain if i have this kind on problems with scripting.

  • #5685 Score: 0

    Vesku1980
    • Contributions: 0
    • Level 1

    No. I use firebug or chrome developer tools with those.

You must be logged in to reply to this topic.