HI , here i am trying to execute a statement like this. glaccount.INIT; str3:=desttbl1 +’."’+ tempname +’"’; //MESSAGE(FORMAT(recordset2.Fields.Item(1).Value)); str3:=str3+ ‘:=’ +FORMAT(recordset2.Fields.Item(1).Value); dynamically i am getting str3 as “glaccount.“No.”:= 001” now i would like to execute str3 . how could i execute this statement. thanks in advance…
Hello suryanarayana.knv, I would say that you are completely off. Your string constant ‘:=’ can not under any circumstances be interpreted as the assignment operator := by the compiler. I doubt that this could be accomplished in any programming language. //Pelle
here i am trying to execute a statement like this. Quote: glaccount.INIT; str3:=desttbl1 +’."’+ tempname +’"’; //MESSAGE(FORMAT(recordset2.Fields.Item(1).Value)); str3:=str3+ ‘:=’ +FORMAT(recordset2.Fields.Item(1).Value); dynamically i am getting str3 as glaccount.“No.”:= 001 that means str3 is having value of glaccount.“No.”:= 001 now i am trying to execute the line → str3 . how could i execute this statement. (str3) i hope that u can get this now… OK
I doubt that this could be accomplished in any programming language.
Originally posted by pelle - 2005 Jul 08 : 10:33:14
OT: I remember to “chage” my basic-coding “from within” the code on a ZX81
Hello, I think Pelle’s comments still apply. It can not be accomplished in Navision. Maybe you could explain what the result should be.
I assume you are trying to update a value in a field where you don’t know which field you want to update until run-time. You should be able to achieve this with FieldRef. Look up RecoredRef and FieldRef in the online help.
yes…u r right mr Gary Frostick. u got my point. but how can we ?
Well short of writing the whole thing for you [;)] RecRef is defined as a data type RecordRef TableNo Integer
TableNo := 15; //GL Account Table Object ID RecRef.OPEN(TableNo); RecRef.INIT; RecRef.FIELD(1) := '001'; //Update G/L Account Field RecRef.INSERT; RecRef.CLOSE; This should give you an idea. You can cross reference names and object IDs using the Object and field tables.
A bit off topic… Gary, I have no experience with RecordRef and tried to find a topic about it, but the topic I found (http://www.mbsonline.org/forum/topic.asp?TOPIC_ID=12142) showed an error. [:(] Why should danda_kumar use RecordRef instead of Record as datatype?
I think you should be working in assembler.
Ya ! Gary Frostick is correct We attempted to migrate the data from access to Navision using CODBC. We are successful in using ‘RecodRef’ and ‘FieldRef’. We could able to open the tables dynamically from access using CODBC and assigning the field values to Navision table columns. I am sure this is one of the best ways to migrate the data to Navision and vis versa using CODBC The sample code which may help u to think
..... ......... ............ WHILE NOT recordset2.EOF DO BEGIN rec.OPEN(Tableno); rec.INIT; // LOOP TO START j:=1; FOR j:=1 TO i-1 DO BEGIN EVALUATE(k,tempname[j]); reckey:=rec.FIELD(k); reckey.VALUE:=FORMAT(recordset2.Fields.Item(posfname[j]).Value); IF j=1 THEN rec.INSERT(TRUE) ELSE rec.MODIFY(TRUE); END; // LOOP END recordset2.MoveNext; END; END;
Tino, For virtually all things you will ever need to do with Navision the record datatype will do everythinbg you ever need. The advantage of the RecordRef datatype is you do not set the table you want to access at design time but can assign the ID of the table you want to work with at run-time. I have only ever needed to do this ‘in anger’ once. I had to write a modification that calulated targets based on certain fields that the user could select themselves. By storing the record and field ID in a table I could then use them to read the record and field the user had selected. The on-line help for these datatypes isn’t really that useful. I had to work them out myself the hard way, however RecordRef and FieldRef are pretty easy to use. Just define them and have a look at the properties in the Symbol menu.
Hi Gary, Thanks for the explanation! It’s clear to me now. Maybe I’m gonna use it to make a flexible report. So the user can select the columns he wants on the tabular-type report. Thanks!
Helpful Download:[:p] Learn the basics of Record References in Navision. A little codeunit with some code and explanation on how to use RecordRef’s in Navision http://www.mibuso.com/dlinfo.asp?FileID=276
Thanks! Somethimes I forget there’s also mibuso.com… [:I]
Maybe I’m gonna use it to make a flexible report. So the user can select the columns he wants on the tabular-type report. -------------------------------------------------------------------------------- greetings, Tino Ruijs
Very nice datatypes are RecordRef and FieldRef! I used them to make a report in which users can select there own columns. Again it seems to me that mbsonline.org can be very educational! At least for me! [:D]
What do you want to do when you get a duplicate record? You could put an if-statement in the line “rec.INSERT(TRUE)”. If NOT rec.INSERT(TRUE) then begin; // Things you want to do when you get a duplicate record. // Maybe modify. // Or nothing. end;
Maybe I’m gonna use it to make a flexible report. So the user can select the columns he wants on the tabular-type report. -------------------------------------------------------------------------------- greetings, Tino Ruijs |
| - |
Hi Tino Ruijs could you explain a bit more on the flexible reporty thingy. thanks
Hi, I’v made a report with DataItem Job. On the tab Options are 10 ‘flexible’-fields. One can choose fields out of the job-table in these ‘flexible’-fields. In the properties of the textbox (flexible-field) there’s a TableRelation “Field.No. WHERE (TableNo=FILTER(167))” and LookupFormID is “FieldsFieldRef” (new form based on table Field). In the OnAfterGetRecord the job-table is opened as record reference.
rrfProjectTable.OPEN(167); rrfProjectTable.FIND('-'); Also in the OnAfterGetRecord the (flexible) fieldnumbers from the Options tab are used in the field reference.
codProjectnumber := Job."No."; "frfProjectFieldNo." := rrfProjectTable.FIELD(1); "frfProjectFieldNo.".SETFILTER(FORMAT(codProjectnumber)); FOR intCount := 1 TO 10 DO BEGIN; IF intFieldNumber[intCount] <> 0 THEN BEGIN; frfProjectField[intCount] := rrfProjectTable.FIELD(intFieldNumber[intCount]); IF FORMAT(frfProjectField[intCount].CLASS) = 'FlowField' THEN BEGIN; frfProjectField[intCount].CALCFIELD; END; txtColumn[intCount] := FORMAT(frfProjectField[intCount].VALUE); END ELSE BEGIN; txtColumn[intCount] := ''; END; END; That’s about it.