I want to add a colume in the tabular form, but this new colume will display the value of a global variable instead of referring to a real field from the Table. Does anyone have idea?
I know that I can 'create' a new colume in the tabular form by adding a new field in the Table, but I just want to know whether there is another method that achieve the same goal and without changing the table structure.
you should create the columnn with an existing table field and then you have to change the 'SourceExpression' of this column to your variable.
The calculation of this variable can be do in the 'OnAfterGetRecord'-Trigger.
Yes, you can add a textfield to a tabular form without changing the table structure. Better, you choose Add Label from the toolbox and then add the textfield to the tabular form.
Its Table Relation property will be 'undefined'.
Change its SourceExpr property to the Global variable you have declared earlier.
You can even write code to manipulate the textfield behaviour at runtime. Write code within the form's OnNewRecord trigger.
If you have a global variable with the same name as a field of the source table, just add "Rec." in front of the textbox source expression.
E. g.: Instead of "Description" write "Rec.Description".
Another possibility:
Add a new column in the browser like Kowa and andreof have suggested.
Create a function in the form (or in another object like this table or a codeunit) that accepts as a parameter a record of your table and has as return-value the type of your global variable. Put this function in the property "SourceExpr" of the new column. [eg. MyFunction(rec) ]
Put the calculation of your return-value in that function and do an EXIT(MyReturnValue) in the function.
In this way you don't need to put code in the "OnAfterGetRecord"-trigger and if needed, you can use this function in other places
eg. of the function:
PROCEDURE MyFunction(IrecCurrentRecord : Record NNN) : Decimal;
BEGIN
// put here you calculation
EXIT(MyCalculation);
END;
Regards,Alain Krikilion No PM,please use the forum. || May the <SOLVED>-attribute be in your title!
Comments
If necessary, calculate the variable values in the OnAfterGetRecord Trigger of the form.
I know that I can 'create' a new colume in the tabular form by adding a new field in the Table, but I just want to know whether there is another method that achieve the same goal and without changing the table structure.
My world: Dynamics NAV,SQL and .NET
CEO at Solving Dynamics
http://www.solvingdynamics.com
you should create the columnn with an existing table field and then you have to change the 'SourceExpression' of this column to your variable.
The calculation of this variable can be do in the 'OnAfterGetRecord'-Trigger.
HTH,Otschko
Its Table Relation property will be 'undefined'.
Change its SourceExpr property to the Global variable you have declared earlier.
You can even write code to manipulate the textfield behaviour at runtime. Write code within the form's OnNewRecord trigger.
E. g.: Instead of "Description" write "Rec.Description".
Microsoft Dynamics NAV Developer since 1997
MSDynamics.de - German Microsoft Dynamics Community - member of [clip]
Add a new column in the browser like Kowa and andreof have suggested.
Create a function in the form (or in another object like this table or a codeunit) that accepts as a parameter a record of your table and has as return-value the type of your global variable. Put this function in the property "SourceExpr" of the new column. [eg. MyFunction(rec) ]
Put the calculation of your return-value in that function and do an EXIT(MyReturnValue) in the function.
In this way you don't need to put code in the "OnAfterGetRecord"-trigger and if needed, you can use this function in other places
eg. of the function:
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!