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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

How to get data from an another DataSource of Forms Extension in edit method

(0) ShareShare
ReportReport
Posted on by 130

Hi All,

I have create Project DICD3FO_VASPackage inheritance Application Suite model

- Add Forms extension LedgerJournalTransDaily.Extension to my Project

- Form LedgerJournalTransDaily.Extension had ready DataSource LedgerJournalTrans 

- Add DataSource "DICVASFields" to DataSource of Form Extension

- New tab in the Design pattern

- Add some fields of DICVASFields datasource to this TAB

- Input Data Method (DICVASFields_Extension::editAddress) and DataSource (DICVASFields) in to Field (Address) attribute

- Create class Name: DICVASFields_Extension

public static class DICVASFields_Extension
{
           [SysClientCacheDataMethodAttribute(true)]
           public static edit DICAddress editAddress(boolean _set,DICVASFields _this,DICAddress _address)
           {
               // I want to get current datasource of LedgerJournalTrans  in form LedgerJournalTransDaily.Extension to assgin to 3th param in the method setAddress
              return _this.setAddress(_set,_address, ledgerJournalTrans);
         }

 }

Please help me find out the solutions

Thanks,

DonTran

*This post is locked for comments

I have the same question (0)
  • Martin Dráb Profile Picture
    240,075 Most Valuable Professional on at

    Hi DonTran, please tags for categories of your question; a sentence like "D3FO: How to get data from an another DataSource of Forms Extension in edit method: doesn't fulfil the purpose of tags.

  • dontran Profile Picture
    130 on at

    Thanks Martin Dráb, Do you have any solution for my question?

  • Verified answer
    Martin Dráb Profile Picture
    240,075 Most Valuable Professional on at

    Models can't inherit from other modules. Do you mean that you've created a new model in a separate package and added a reference to Application Suite, or that you added another module to Application Suite package?

    Regarding your method, you can call _this.datasource() to get the FormDataSource object nad then formRun() to get the form. When you have a reference to the form, you can call any of its methods, such as datasource() and you can get the active record from a datasource by cursor().

  • Verified answer
    dontran Profile Picture
    130 on at

    Thanks Martin, You gave me good idea and I finished task with code:

    FormDataSource  fdsVASFields = _this.datasource();        

    FormDataSource  fdsLedgerJournalTrans  = fdsVASFields.formRun().dataSource("LedgerJournalTrans");

    LedgerJournalTrans ledgerJournalTrans = fdsLedgerJournalTrans.cursor();

    return _this.setAddress(_set,_address,ledgerJournalTrans);

    By the way for me add one the question:

    I got current datasource from ledgerJournalTrans and  have value of some fields of table ledgerJournalTrans (Like voucher,...) , but special value of field RecID = 0.

    I don't know reason why the value of RecID = 0.,

    and help me how to get RecID of ledgerJournalTrans ;

    Please help.

  • Verified answer
    Martin Dráb Profile Picture
    240,075 Most Valuable Professional on at

    Maybe the record hasn't been saved yet. Record ID is assigned on insert.

  • Verified answer
    dontran Profile Picture
    130 on at

    The record already exists in the table LedgerJournalTrans have JourNumber = "00619 "

    and Voucher = "ARPM004091", RecID = 5637161597

    I add form Extension "LedgerJournalTransDaily.Extension" to add some fields from table DICVASFields to calculator but must get some data from datasource LedgerJournalTrans in that RecID Field.

    Thanks

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans