Page 1 of 1

Add CommentLine to a PO

PostPosted: Mon Feb 26, 2018 3:16 pm
by OliverYan
Hi,

I have created a plugs to insert a commentline to PO, the key parameter NewKey is now a Object, not a string value. how/what value can I assign value to this object?

Here is my code,

Dim oNewKey=New Object()

If CommentLineText<>"" Then
purchaseorder.Lines.AddCommentLine(CommentLineText,oNewkey,0)
End If

no error raised when I compile this code. but when I run it in PO creation, it crash Jiwa.
Would you please help?

Thanks,
Oliver

Re: Add CommentLine to a PO  Topic is solved

PostPosted: Wed Feb 28, 2018 10:36 pm
by Mike.Sheen
Hi Oliver,

To add a comment to a purchase order, the following code works for me:

Code: Select all
Dim newKey As Object
po.Lines.AddCommentLine("This is a comment", newKey)


I think your problem may be declaring your oNewkey variable as an array of objects.

Code: Select all
Dim oNewKey=New Object()


I've attached a sample plugin which I have tested in 07.00.175.00 which adds a comment when a new purchase order is created.

Plugin Add PO Comment.xml
Sample Plugin
(30.31 KiB) Downloaded 487 times


Mike

Re: Add CommentLine to a PO

PostPosted: Thu Mar 01, 2018 12:02 am
by OliverYan
Thanks Mike,

I did as you suggested, doesn't work.
I changed the code as below.
Code: Select all
purchaseorder.Lines.AddCommentLine(CommentLineText,"",purchaseorder.Lines.Count+1)


it works. weird!

Re: Add CommentLine to a PO

PostPosted: Thu Mar 01, 2018 5:07 pm
by Mike.Sheen
OliverYan wrote:I did as you suggested, doesn't work.


I did actually test the code by importing the plugin I supplied and created a new Purchase Order and sure enough, a new note appeared on the notes tab - so it did work for me.

When you say "doesn't work" - do you have any error message or anything? Does it still crash Jiwa as you said initially, or is the behaviour any different?