Skip to main content

Notifications

Microsoft Dynamics AX forum
Answered

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

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

  • Verified answer
    dontran Profile Picture
    dontran 130 on at
    RE: How to get data from an another DataSource of Forms Extension in edit method

    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

  • Verified answer
    Martin Dráb Profile Picture
    Martin Dráb 227,996 Super User 2024 Season 2 on at
    RE: How to get data from an another DataSource of Forms Extension in edit method

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

  • Verified answer
    dontran Profile Picture
    dontran 130 on at
    RE: How to get data from an another DataSource of Forms Extension in edit method

    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
    Martin Dráb 227,996 Super User 2024 Season 2 on at
    RE: How to get data from an another DataSource of Forms Extension in edit method

    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().

  • dontran Profile Picture
    dontran 130 on at
    RE: How to get data from an another DataSource of Forms Extension in edit method

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

  • Martin Dráb Profile Picture
    Martin Dráb 227,996 Super User 2024 Season 2 on at
    RE: D3FO: How to get data from an another DataSource of Forms Extension in edit method

    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.

Helpful resources

Quick Links

Dynamics 365 Community Update – Sep 9th

Welcome to the next edition of the Community Platform Update. This is a weekly…

Dynamics 365 Community Newsletter - August 2024

Catch up on the latest D365 Community news

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,186 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 227,996 Super User 2024 Season 2

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans