DateFormula and C/FRONT

Does anyone know how to assign a DateFormula field a value from C/FRONT? eg. table:Payment Terms table field:Due Date Calculation I am calling C/FRONT from within Attain itself. The function exposed from the OCX is AssignField(TableNo, RecordNo, FieldNo, NewValue); My globals are integers (x3) and a variant. This works for the rest of the standard types. The C/FRONT documentation says that the function appearing to a C program is as follows: DBL_AssignField(DBL_HTABLE hTable,DBL_HREC hRec,DBL_S32 FieldNo, DBL_U16 Type, void *Data, DBL_S32 DataSize); Craig Bradney

DBL_FieldSize returns that it is 32 bit field. Data type code looks like TIME or DATE, but it can’t be DATE, because DATE can’t be negative. So, it can be Navision specific undocumented data format. Take a good debuger, maybe there is only extended DATE format.

Im waiting for a reply from Navision - it maybe an Attain issue. Craig Bradney

I have tried assign DateFormula and it’s works. There is code:

void main(int argc, char* argv[])
  DBL_HTABLE hlent;
  DBL_HREC hrec;
  DBL_S32 LentNr;
  DBL_S32 val=562; //= 2D
  DBL_U8* npath="c:\\progra~1\\navisi~1.00\\client\\";
  DWORD *data;

  if (DBL_Init() == 0)
    printf("Opening company\n");
    DBL_OpenCompany("CRONUS Lithuania u.a.b.");
    LentNr = 75000; // lent
    // opening tables 
    DBL_OpenTable(&hlent, LentNr);
    // allocating mamory for rec
    hrec = DBL_AllocRec(hlent);
    if (DBL_FindRec(hlent, hrec,(DBL_U8*) "-"))
     } while (DBL_NextRec(hlent,hrec,1)!=0);

		printf("CFront unloaded.\n");
		printf("Failed to load CFront library.\n");

What DateFormula data format, it is another question.

Hi David Thanks, yes - that is the code doing it from within C, but I am doing it from within C/AL and I dont have the type or size fields available within the AssignField call. Heres a sample piece of code. I know it doesnt have a lot of error checking and isnt all that tidy etc but it doesnt reach that code and its just a quick example to show it not working. btw - this is 3.01A. 2.6 used code fields for Dateformula. This is in a codeunit in an unmodified Cronus. ----- CLEAR(CFRONT); servername:=‘’; nettype:=‘nettype’; databasename:=‘databasename’; company:=‘companyname’; u:=‘user’; p:=‘password’; dbtype:=‘NDBCS’; CFRONT.ConnectServerAndOpenDatabase(dbtype,servername,nettype,databasename,2000,FALSE,FALSE,u,p); CFRONT.OpenCompany(COMPANYNAME); tableno:=3; IF CFRONT.OpenTable(Table,tableno) THEN BEGIN NewRecord:=CFRONT.AllocRec(Table); CFRONT.BWT; CFRONT.InitRec(Table,NewRecord); FieldValue:=‘TT’; CFRONT.AssignField(Table, NewRecord, 1, FieldValue); FieldValue:=‘CM’; EVALUATE(datef,‘CM’); //not assigning the due date calculation field means the record can be inserted. //try this, but this doesnt work because of field length and type, try any! CFRONT.AssignField(Table, NewRecord, 2, FieldValue); //or this, but this doesnt work because of type conflict //CFRONT.AssignField(Table, NewRecord, 2,datef); CFRONT.InsertRec(Table,NewRecord); CFRONT.EWT; CFRONT.FreeRec(NewRecord); CFRONT.CloseTable(Table); END; CFRONT.CloseCompany(); CFRONT.DisconnectServer(); ---------- where Name DataType Subtype Length CFRONT OCX CFRONT Control hrec Integer tableno Integer Table Variant NewRecordVariant FieldNo Integer FieldValue Text 2 datef DateFormula servername Text 30 nettype Text 30 company Text 30 u Text 30 p Text 30 databasename Text 30 dbtype Text 30 Craig Bradney

Try this:

  IntVal: Integer;

IntVal:=563; //3D
CFRONT.AssignField(Table, NewRecord, 2, InVal);

Is it works ? Do you using SQL version ?

No, this doesnt work, and I get the same result using native or SQL server. Thanks for the idea though! Craig Bradney

Hmmm, it’s looks like there are data types conversion probems. Maybe navision havn’t implemented this data type suport yet. I have found bug on cfront too. So, we should wait for service pack’s. Have you tried cfront dataformula assigments on vb or C++ ? Maybe there they works. You can write own ocx and use cfront.dll from it.

I havent tried that yet, and its a workaround I can explore. I’ll follow it up with the NTR tomorrow and see if they have had any response from Denmark. Calling another OCX to do the field update might be ok… will explore if I have to. Craig Bradney