Nav Sales header table Document type field

Hi everybody!

I need som help for dynamics nav 5.0 sp1. i want to import invoice into Nav.

If i write into sales header table, whit this code:

try
{
NavisionFieldType type = CFrontDotNet.Instance.FieldType(table.Handle, i); // lekérjük, hogy az a mezõ amibe írni akarunk az milyen típusú

// try
// {

if (type == NavisionFieldType.Text)
{
CFrontDotNet.Instance.SetFieldData(table.Handle, recordHandle, i, type, NavisionText.Parse(elem).GetBytes());
}
else if (type == NavisionFieldType.Code)
{
CFrontDotNet.Instance.SetFieldData(table.Handle, recordHandle, i, type, NavisionCode.Parse(elem).GetBytes());
}
else if (type == NavisionFieldType.Option)
{
CFrontDotNet.Instance.SetFieldData(table.Handle, recordHandle, i, type, NavisionOption.Parse(elem, table.Handle, i).GetBytes());
}
else if (type == NavisionFieldType.Date)
{
CFrontDotNet.Instance.SetFieldData(table.Handle, recordHandle, i, type, NavisionDate.Parse(elem).GetBytes());
}
else if (type == NavisionFieldType.Decimal)
{
CFrontDotNet.Instance.SetFieldData(table.Handle, recordHandle, i, type, NavisionDecimal.Parse(elem).GetBytes());
}
else if (type == NavisionFieldType.Boolean)
{
CFrontDotNet.Instance.SetFieldData(table.Handle, recordHandle, i, type, NavisionBoolean.Parse(elem).GetBytes());
}
else if (type == NavisionFieldType.Integer)
{
CFrontDotNet.Instance.SetFieldData(table.Handle, recordHandle, i, type, NavisionInteger.Parse(elem).GetBytes());
}
// }
// catch { }
}
catch { }

the first field named “Document type” have a navisiontype: option. So i want to insert a row, all other fields inserted correctly, but this first insert a 0 value, but i send value 2.

if i run my app without “try… catch” i become a message:

The option string is not valid or exceeds the maximum number of characters allowed 250.

but i send just a string: “2”

sorry for my english and thx for the help!

Csaba

sorry i have forget im connection with c/front to a native nav server, and i work in c#.

so what is your query now?

welcome on aboard Csaba[:D]

hi thx![:D]

the query is:

how can i inserting a record into sales headers document type field with value: 2??

the type of this field is Navision Option, and my variable elem value is 2, and have a type string.

else if (type == NavisionFieldType.Option)
{
CFrontDotNet.Instance.SetFieldData(table.Handle, recordHandle, i, type, NavisionOption.Parse(elem, table.Handle, i).GetBytes());
}

after this rows i become one error message. but i dont understand why?

first of all, as far as i know we can code in NAV like this.

And secondly, in what do yo want to add? table 36 ?

As is it the table sales header has option string set has

Quote,Order,Invoice,Credit Memo,Blanket Order,Return Order

now are you saying you want to add in this?

Hi Csaba,

Option variables are stored as integers so if you assign this to 2 it will be picked up as type Invoice. Be careful that all the data is validated afterwards.

sorry. yes into table 36

Hi Dave!

on the table 36 im going with for,

i read the actually fields type with this:

NavisionFieldType type = CFrontDotNet.Instance.FieldType(table.Handle, i);

and later when i call the SetFieldData, i will give this for type.

just one thing.

i have printed for me the state of database befor/after invoice inserting in Navision.

I have see, a “Document dimension” table is changed, so i have inserted into this the actually values before i inserting into table 36.