This topic contains 6 replies, has 0 voices, and was last updated by Vesku1980 7 years, 11 months ago.
-
AuthorPosts
-
December 8, 2016 at 12:07 pm #5679
jessieThe 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. -
December 8, 2016 at 12:44 pm #5680
david.smithOn a payment you should do this on an after submit function. Payments can be applied to more than one invoice.
-
December 8, 2016 at 12:51 pm #5681
Vesku1980Hi.
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
-
December 8, 2016 at 1:36 pm #5682
jessiedavid.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.
-
December 8, 2016 at 2:09 pm #5683
jessieVesku1980 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?
-
December 8, 2016 at 3:18 pm #5684
jessieVesku1980 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.
-
December 14, 2016 at 2:34 pm #5685
Vesku1980No. I use firebug or chrome developer tools with those.
-
AuthorPosts
You must be logged in to reply to this topic.