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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

Calling modified field from a FormDataField extention

(0) ShareShare
ReportReport
Posted on by 5

Hi 


I am using CoC to extend a datafield in a form (SalesTable).
That works ok. 

Is there any way to call modified on another field, in another datasource, in the form, from the extension?
In this case call modified on a field in MCRSalesLineDropShipment.

ExtensionOf(formDataFieldStr(SalesTable, SalesLine, ItemId))]
final class SalesTable_FormFieldItemdIdDC_Extension
{
   public void modified()
   {
      SalesLine salesLine;
      FormDataSource fds;
      FormDataObject fdo = any2Object(this) as FormDataObject;

      next modified();

      fds = fdo.datasource();
      salesLine = fds.cursor();

      salesLine = DCLocationMatrix::SetSalesLineDirectDelivery(salesLine);

      boolean isDropShipment = SalesLine.mcrInventTable().DropShipment;
      if (isDropShipment)
      {
         element.defaultInventDimBasedOnDirectDeliveryWarehouse(isDropShipment);
      }

      salesLine.reread();
   }
}

I have the same question (0)
  • Evaldas Profile Picture
    1,800 on at

    There is.

    FormDataSource formDataSource = element.AnotherDataSource_DS;

    formDataSource.object(fieldId).modified();

  • Suggested answer
    JoRu Profile Picture
    5 on at

    Hi

    Thanks for the quick reply!

    Very close to what I enden up with. :-)
    My problem was the FormDataObject thing.


    I added this code under the rest:

       FormRun formRun = fds.formRun();
       FormDataSource formDataSource = formRun.dataSource(formDataSourceStr(SalesTable,  MCRSalesLineDropShipment));
       FormDataObject field = formDataSource.object(fieldNum(MCRSalesLineDropShipment, DropShipment));

       field.modified();

  • Evaldas Profile Picture
    1,800 on at

    Welcome!

    Just a tip:

    You don't have to use formRun.

    You can directly access many form variables, including form data source object by using element. Like this example:

    FormDataSource formDataSource = element.SalesTable_DS;

    Another tip:

    E.g. in your code you are first casting your extension class to FormDataObject and when calling dataSource() to get FormDataSource.

    You can get FormDataSource simply by calling

    fds = this.dataSource().

    It's not shown in the suggestion list but it works. And it makes your code more readable ;)

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

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

#1
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 617

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 461 Super User 2026 Season 1

#3
Syed Haris Shah Profile Picture

Syed Haris Shah 298 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans