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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

How can I access a form extension variable from a data source extension?

(0) ShareShare
ReportReport
Posted on by 5

Hi all,

I'm adding a multi select drop down field to the VendTable form. I've created a extension class to create the drop down;

[ExtensionOf(formStr(VendTable))]
final class TestVendTable_Extension
{
    public SysLookupMultiSelectCtrl logisticsTradeTypeCtrl;

    void init()
    {
        next init();

        logisticsTradeTypeCtrl = SysLookupMultiSelectCtrl::construct(this, 
            LogisticsTradeType, 
            queryStr(TestLogisticsTradeTypeQry), 
            true, 
            [tableNum(TestLogisticsTradeType),
            fieldNum(TestLogisticsTradeType, TestLogisticsTradeTypeId)]);


    }

}

I need to access the property from a DataSource extension in order to populate the control;

[ExtensionOf(formDataSourcestr(VendTable, VendTable))]
final class TestVendTableDataSource_Extension
{
    public int active()
    {
        VendTable vt = this.cursor();
		
        if (vt.LogisticsTradeTypeCon)
        {
            // I can't access this variable
			logisticsTradeTypeCtrl.set(vt.LogisticsTradeTypeCon);
        }
        else
        {
           logisticsTradeTypeCtrl.set(conNull());
        }

        int ret = next active();

        return ret;
    }

}

However, I can't access "logisticsTradeTypeCtrl" from within the active datasource method.

Have I gone about this in the correct way, feels like I haven't :)

Any help appreciated!

Regards, Jason

I have the same question (0)
  • Verified answer
    nmaenpaa Profile Picture
    101,160 Moderator on at

    First of all, remember to use your prefix when adding new variables to standard forms. Otherwise you will have issues if MS adds a variable with the same name.

    docs.microsoft.com/.../naming-guidelines-extensions

    You should be able to access public variables by element.logisticsTradeTypeCtrl.

    Or, you can add method "getMyLogisticsTradeTypeCtrl" that returns the variable, and you can call that method from the form data source.

  • Blue Wang Profile Picture
    on at

    Hi

    Use element.logisticsTradeTypeCtrl.

    Similar thread for you:

    community.dynamics.com/.../access-variable-across-different-cocs-of-the-form

  • Jason Hyland Profile Picture
    5 on at

    Thanks Nikolaos for the prompt answer! Yes, the element.logisticsTradeTypeCtrl did the job. I take your point about naming clashes, I'd removed them for posting here ;)

    Thanks again.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 664 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 522 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 303 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans