AX – D365FO – How to call a method of a calling Form objects

Suppose you ha ve Form A that calls Form B.

In Form B you want to call a method of Form A.

How to do this?

Follow these instructions.

First in Form B declare 2 variables

[Form]
public class Al0VendorActivityVendorSearch extends FormRun
{
FormRun                 callerObject;
Object                  object;

......

Then in the init method set callerobject

   public void init()
    {
        super();

        callerObject = element.args().caller();

......

Then in your method you can call the callerobject method. In this example the name of the callerobject method is “setStatesSelected”

    public void setStatesSelected()
    {
        str selectedStatesString = selectedStatesGrid.text();
        if(sysFormRun::hasMethod(callerObject, identifierStr("setStatesSelected")))
        {
            object = callerObject;
            object.setStatesSelected(selectedStatesString);
        }
    }

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s