Newbie question - associate a function to a Table box coumn

ferrisferris Member Posts: 23
I want to associate a function to a Table box coumn. I have create a function test() with a return value Code and I have set the function as SourceExp of the column.
How can I recover the data of the table box in the function?
And how can I display the data of an array in the function into the table box.

In other words: haw can I recover or set a value of a table cell using a function? With the xy coordinates?

Comments

  • krikikriki Member, Moderator Posts: 9,118
    As parameters to the function, you best give the current record and a second parameter you give an integer (or option or text or whatever) so in the function you can identify the column who is calling it.
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • ferrisferris Member Posts: 23
    My problem is the first parameter: if I set the return value of the function to 'xxx' all rows of the table box are set to 'xxx'.
    How can I recover the value of the the selected row and the index of the row?
  • andreofandreof Member Posts: 133
    Use a variable instead of a function, and on the onaftergetrecord event put var := funtion. This should do it (without testing).
    Andre Fidalgo
    My world: Dynamics NAV,SQL and .NET

    CEO at Solving Dynamics
    http://www.solvingdynamics.com
  • andreofandreof Member Posts: 133
    if you want to get the value back, add a field to the table and fill the field with the function value again on the onaftergetrecord event
    Andre Fidalgo
    My world: Dynamics NAV,SQL and .NET

    CEO at Solving Dynamics
    http://www.solvingdynamics.com
  • ferrisferris Member Posts: 23
    I'm sorry I don't undestand :oops: ](*,):
    If I put a text in a column and a variable as sourceExp, each row of the table box share the same variabile.
    How can I set a different sourceExp for each row? Obviously the number of rows is dinamic.
  • andreofandreof Member Posts: 133
    Example:

    OnAfterGetRecord()
    BEGIN
    var := Funtion();
    END;

    This has several problems:
    you cannot get the value of a specific line, if you scrolldown and up the records you will get different values.

    The best way is to create a field in the table and just use that field to store the value you want.


    OnAfterGetRecord()
    BEGIN
    field := Funtion();
    END;
    Andre Fidalgo
    My world: Dynamics NAV,SQL and .NET

    CEO at Solving Dynamics
    http://www.solvingdynamics.com
  • krikikriki Member, Moderator Posts: 9,118
    Better is :
    make a function Test that accepts 2 parameters:
    Function Test(IrecMyTable : record "My Table" ; IintTheColumn : INTEGER) : Text 250
    // "IrecMyTable" contains the record for which the function has been triggered
    // "IintTheColumn" contains an integer for the field for which the function is triggered (you can use FIELDNO("The Field") in case it is a field of the table or you can use your own numbering)
    

    So in the "SourceExpression" can put
    Test(rec,FIELDNO("Some Field"))
    

    This is a more beautifull way of triggering the function instead of using "OnAfterGetRecord".
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • andreofandreof Member Posts: 133
    yeah, beautiful
    Andre Fidalgo
    My world: Dynamics NAV,SQL and .NET

    CEO at Solving Dynamics
    http://www.solvingdynamics.com
  • SaroSaro Member Posts: 58
    andreof wrote:
    Use a variable instead of a function, and on the onaftergetrecord event put var := funtion. This should do it (without testing).

    There is no on after get record for a table box if you do not link it to the main form, i.e. if you want to put a table box on a form with variable columns not belonging to the table of the main form you will not have a onaftergetrecord trigger.
    Saro
  • andreofandreof Member Posts: 133
    have you tried to use a tablebox without it being connected to a form?
    Andre Fidalgo
    My world: Dynamics NAV,SQL and .NET

    CEO at Solving Dynamics
    http://www.solvingdynamics.com
  • andreofandreof Member Posts: 133
    to a form record i mean
    Andre Fidalgo
    My world: Dynamics NAV,SQL and .NET

    CEO at Solving Dynamics
    http://www.solvingdynamics.com
  • SaroSaro Member Posts: 58
    yes that's what i'm talking about if you use a table box without connecting it to the form, the onaftergetrecord will only be executed once, and the first line of the table box will be filled, except for the whole thing is disabled so you cannot access the data in the table box
    Saro
Sign In or Register to comment.