using WebService; class Program { static void Main(string[] args) { string custNo = "10000"; string custName = "Name - 10000"; string itemNo = "1000"; // Create instance of service SalesInv_Service salesInvoice; SalesInv_Service_Service service; salesInvoice = new SalesInv_Service(); service = new SalesInv_Service_Service(); service.UseDefaultCredentials = true; salesInvoice.Sell_to_Customer_No = custNo; salesInvoice.Sell_to_Customer_Name = custName; Sales_Invoice_Line[] salesInvLine = new Sales_Invoice_Line[1]; salesInvLine[0] = new Sales_Invoice_Line(); salesInvLine[0].Type = WebService.Type.Item; salesInvLine[0].No = itemNo; // <------ itemNo "1000" exist in Item Master salesInvLine[0].Description = "xx"; salesInvoice.SalesLines = salesInvLine; service.Create(ref salesInvoice); Console.ReadLine(); } }
Comments
salesInvLine[0].Type = 2;
www.pardaan.com
I got the compile error because wrong data type. It's not a Integer.
Options
Blank (0) -> this means standard text
G/L Account (1)
Item (2)
Resource (3)
Fixed Asset (4)
Charge (Item) (5)
The error message implicates that the field 'Type' is blank. So when validating the field 'No' with value 1000, NAV is looking for a standard text with code 1000 instead of an item 1000....
In C/AL you can change the field type with the following code:
"sales invoice line".type := "sales invoice line".type::Item
or
"sales invoice line".type := 2;
www.pardaan.com
Error is from C# not from C/AL.
I have no problem insert option string in C/AL but this is outside the C/SIDE and I don't know how to insert field which is an option.
I already tried
salesInvLine[0].Type = WebService.Type.Item;
This has no error but when I look in database it inserted blank.
and tried
salesInvLine[0].Type = 2;
It error when compile because wrong data type as I said.
But I'm 100% sure the error you receive is a NAV error caused by validating the field 'No' with value 1000 while the field 'Type' is blank!
www.pardaan.com
Although error still can't resolve, I'm very appreciated your help
Maybe I went to the wrong step. Now I can insert optionString by follow this instruction.
http://blogs.msdn.com/b/freddyk/archive ... d-rtm.aspx