create display method on form datasource

Hello friends,

It would be nice if you could provide an example on how to create a display method on form datasource in form extension.

Best regards,

Roberts

It is supported from PU29.

It’s a pity that you forgot to mention what problem you have.Let me guess…

If you don’t know how to write a display method, it should look like this:

display MyType myMethod(MyTable _myTable)
{
	return ...;
}

If you aren’t familiar with extension classes, search for ExtensionOf attribute. In case of form data sources, it’s used in this way:

[ExtensionOf(formDataSource(MyForm, MyDataSource))]
final class MyClass_Extension
{
    ...
}

If you have another problem, it’s time to tell us what it is.

Hi Martin,

Usually I create display methods in table class extensions. However, at the moment I need to create it in form datasource. Can you explain what is the difference between two methods with some code example?

Best regards,

Roberts

Please look at the code example before. If you compare it with the method defined on table (that you usually use), you’ll notice the extra parameter.

Hi, Martin

Looks simple. I have added the toy method in my datasource and outside it. However when I try to find it in my form field properties datasource method list nothing apears.

    [DataSource]
    class AccountingSourceExplorerTmp
    {
        /// <summary>
        ///
        /// </summary>
        public  display str  displayPartyNumber(AccountingSourceExplorerTmp _AccountingSourceExplorerTmp)
        {
            //PriceDiscTableExt_DS.observe();
            //PurchLine _purchline ;
            //select firstonly  PurchId  from _purchline where _purchline.SubPriceDiscTableRefRecId ==_PriceDiscTableExt.RecId ;
            return "222";
        }
    }

    public  display str  displayPartyNumber(AccountingSourceExplorerTmp _AccountingSourceExplorerTmp)
    {
        //PriceDiscTableExt_DS.observe();
        //PurchLine _purchline ;
        //select firstonly  PurchId  from _purchline where _purchline.SubPriceDiscTableRefRecId ==_PriceDiscTableExt.RecId ;
        return "222";
    }

data method.png

Best regards,

Roberts

Please show us your extension class.

[ExtensionOf(formStr(AccountingSourceExplorer))]
final class AccountingSourceExplorer_EBLSC_Extension
{



    [DataSource]
    class AccountingSourceExplorerTmp
    {
        /// <summary>
        ///
        /// </summary>
        public  display str  displayPartyNumber(AccountingSourceExplorerTmp _AccountingSourceExplorerTmp)
        {
            //PriceDiscTableExt_DS.observe();
            //PurchLine _purchline ;
            //select firstonly  PurchId  from _purchline where _purchline.SubPriceDiscTableRefRecId ==_PriceDiscTableExt.RecId ;
            return "222";
        }
    }

    public  display str  displayPartyNumber(AccountingSourceExplorerTmp _AccountingSourceExplorerTmp)
    {
        //PriceDiscTableExt_DS.observe();
        //PurchLine _purchline ;
        //select firstonly  PurchId  from _purchline where _purchline.SubPriceDiscTableRefRecId ==_PriceDiscTableExt.RecId ;
        return "222";
    }

}

Best regards,

Roberts

Your class is indeed wrong. Does it compile at all?

As I already said in my first reply, this is how you can create a data source extension:

[ExtensionOf(formDataSourceStr(MyForm, MyDataSource))]
final class MyClass_Extension
{
    ...
}