Aug 25, 2012

Title fields in form by using X++ code

Today i would like to share how to get the title fields on the form with X++ code.

For that first i created a form with the name TestTitleFields.
And i selected SalesTable to do my coding from this table i am going to display the title fields on my newly created form.
select the SalesTable methods node and right click and click on new method. and write the following code in code editor window.


Display str getName()
{
    return ' Chowdary';
}

after that select the methods node and right click and click on override method and choose caption method.write the following code in the code editor.


public str caption()
{
    str ret;

    ret = super()+' Venkatesh'+this.getName();

    return ret;
}

After that you SalesTable table will be as shown below.




And go to your form and expand design and select design go to properties and set the propperty TitleDataSource to SalesTable.after that your form will be as shown below.


Now open your form you will see the title field as shown in the below screen.

It will not override the already existing values in the table level title fields. if you want to override those values simply remove the super from the caption method.




No comments: