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, ...
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

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
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 420 Most Valuable Professional

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 241 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans