cancel
Showing results for 
Search instead for 
Did you mean: 

Simply trying to add a Document line in Goods Receipt (oInventoryGenEntry)

Former Member
0 Kudos

Probably the way I'm doing it isn't right. I'm a little new in this.

I tried many way from the HELP way to MY way and I always get the same error.

-5002 Item no. is missing [IGN1.ItemCode]

Here's the latest attempt at doing it.

oGoodsReceipt.Lines.ItemCode = oDelivery.Lines.ItemCode;

oGoodsReceipt.Lines.ItemDescription = oDelivery.Lines.ItemDescription;

oGoodsReceipt.Lines.Quantity = oDelivery.Lines.Quantity;

oGoodsReceipt.Lines.Add();

int ErrCode;

string ErrMsg;

int retVal = oGoodsReceipt.Add();

if(retVal != 0)

{

oCompany.GetLastError(out ErrCode, out ErrMsg);

MessageBox.Show(ErrCode.ToString() + " " + ErrMsg);

}

Since the oDelivery got the right data (I tested it) I even tried to put data manually it should work.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

I tried "Invoice Document - Add Method Sample"

No luck yet

Former Member
0 Kudos

Hi JP,

You shouldn't call the lines.Add() method in such way...

The document_lines object always has a default first line, so you call lines.add() only if you need to put an extra (2nd) line ( in this case you have to call SetCurrentLine(1) ). This makes sense of the error message you get (you add a second line to doc lines without setting the item code...

this is the correct sequence when adding lines to documents

SetCurrentLine(0) --- can be omitted, 1st line selected by default

doclines.ItemCode = ...

etc.

doclines.Add() --- here you add an empty line

doclines.ItemCode = ...

doc.add() --- here you add the doc

Hope this helps...

Former Member
0 Kudos

Hi Enrico.

Here my last attempt :

if(oGoodsReceipt.Lines.Count > 0)

{

oGoodsReceipt.Lines.Add();

oGoodsReceipt.Lines.SetCurrentLine(oGoodsReceipt.Lines.Count-1);

}

oGoodsReceipt.Lines.ItemCode = oDelivery.Lines.ItemCode;

oGoodsReceipt.Lines.ItemDescription = oDelivery.Lines.ItemDescription;

oGoodsReceipt.Lines.Quantity = oDelivery.Lines.Quantity;

oGoodsReceipt.Lines.UnitPrice = oDelivery.Lines.UnitPrice;

int ErrCode;

string ErrMsg;

int retVal = oGoodsReceipt.Add();

if(retVal != 0)

{

oCompany.GetLastError(out ErrCode, out ErrMsg);

rtfResults.Text += ErrCode.ToString() + " " + ErrMsg + "\n";

}

else

{

rtfResults.Text += oDelivery.Lines.ItemCode + " Succeeded...";

}

Still got the error. I tried other way too based on what you said and it doesn't work.

Former Member
0 Kudos

Thank you Enrico. It works.

What I was missing is the famous SetCurrentLine...

Former Member
0 Kudos

I'm happy to hear it...

anyway I apologize for the missing SetCurrentLine(1) after the lines.Add() in my example...

Cheers

Answers (0)