web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Dynamics 365 Community / Blogs / ELandAX blog / How to extend a form's ...

How to extend a form's data source field added in a form extension?

Evaldas Profile Picture Evaldas 1,800
Hello AX World,

Let's say you have a form extension where you added a new data source.

You need to extend a field of the new data source.

The first thought that comes to my mind is to create a class extension of this field.

[ExtensionOf(formDataFieldStr(Form, NewDataSource, DataField))]
final class FormDataField_Extension
{
 ...
}

After compiling, I get the following error:

Abnormal termination with unhandled exception. Exception key: ... System.NullReferenceException: Object reference not set to an instance of an object.

Without further explanation, I will tell you that this is not possible. At least in PU24.
You can extend any data source field but not the one added in a form extension.

So what are the options?

  1. Hookup to framework events if you need to extend modified or validate.
  2. Extend a form's control instead.
  3. Register method override with registerOverrideMethod. This one is useful in case you need to override lookupReference or resolveReference methods.
Important note: When overriding lookupReference and resolveReference overriden method signature should be the following. 
Note that there is no FormReferenceObject or FormDataObject parameter. Example bellow shows you how to get a table record.

public Common lookupReference(FormReferenceGroupControl_control)
{
    FormObjectSet formObjectSet = _control.formRun().dataSource(tableStr(Table));
       
    Table table = formObjectSet.cursor();
       
    return Table::lookupReference(table.FilterField, _control);
}

Be aware and take care!

This was originally posted here.

Comments

*This post is locked for comments