Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Dynamics 365 Community / Forums / Finance forum / Access unbound form co...
Finance forum

Access unbound form control from display method of form extension

(0) ShareShare
ReportReport
Posted on by 20

Hi All.

I have requirement to display new field Settlement id from LedgerTransSettlement on LedgerTransAccount form Overview tab depends on ShowOpen checkbox of this form. If checkBox is selected, the value in settle id should be empty, otherwise, LedgerTransSettlement.SettleId.

I have added class extenstension:

[ExtensionOf(formStr(LedgerTransAccount))]
final class LedgerTransAccount_FRM_Extension
{
    [SysClientCacheDataMethodAttribute(true)]
    public static display Num settleId(GeneralJournalAccountEntry _generalJournalAccountEntry)
    {
        return LedgerTransSettlement::findTransRecId(_generalJournalAccountEntry.RecId).SettleId;
    }
}

Also i have created form extension and added new string control Settle id with next properties:
Data Source: GeneralJournalAccountEntry

Data Method: LedgerTransAccount_FRM_Extension::settleId

It works ok, but the next step is how to get value of form CheckBox control in display method? I could not find solution for this approach.

Also i have tried another approach:

[ExtensionOf(formStr(LedgerTransAccount))]
final class LedgerTransAccount_FRM_Extension
{
[DataSource]
    class GeneralJournalAccountEntry
    {
         public display Num SettleId(GeneralJournalAccountEntry _generalJournalAccountEntry)
        {
            LedgerTransSettlement ledgerTransSettlement = LedgerTransSettlement::findTransRecId(_generalJournalAccountEntry.RecId);
            
            if (showOpen.value())
            {
                return '';
            }
        
            return ledgerTransSettlement.SettleId;
        }
    }
}

But in this case what should be specified on form control property value for Data Method?  If i just specify Data Method: settleId, i got the next error:

The data method 'settleId' was not found on the data source 'GeneralJournalAccountEntry' or its base table/view.

It makes me crazy, please help me to find right solution or approach.

  • Oleg Resh Profile Picture
    45 on at
    RE: Access unbound form control from display method of form extension

    - Is there a special reason why you want so? Why you cannot create a method in the extension class of the table?

    If you tell me how it is possible to display data in the table's diaplay method that is selected by 2 criteria from 2 different tables, I will be very grateful to you.

    By default, we send the write method to the displays and, based on the data in this record, we make a selection. Here you need to actually send the values from 2 tables.

    - Have you  tried to debug  the display method? what if you return the hard coded value such as Return True;

    the method will simply return the true

  • Sohaib Cheema Profile Picture
    46,614 User Group Leader on at
    RE: Access unbound form control from display method of form extension

    Hi Oleg Resh,

    Well, of course, I know that need to use the edit method.

    If you want to use EditDisply method, Please create a EditDisplay method rather than a display method.

    The display was shown for an example, and it also does not work.

    Have you  tried to debug  the display method? what if you return the hard coded value such as Return True; 

    Those links that you gave are all methods on the table, but I need methods on DS in the extended form class

    Is there a special reason why you want so? Why you cannot create a method in the extension class of the table?

    Reply

  • Oleg Resh Profile Picture
    45 on at
    RE: Access unbound form control from display method of form extension

    Well, of course, I know that need to use the edit method.

    The display was shown for an example, and it also does not work.

    Those links that you gave are all methods on the table, but I need methods on DS in the extended form class

  • Sohaib Cheema Profile Picture
    46,614 User Group Leader on at
    RE: Access unbound form control from display method of form extension

    Your method is not a EditDisplay method. It seems more like a display method.

    Please have a look at next post to see how you can code a display method in two different ways.

    And if you want to use EditDisply method, you would use either two or three parameters, not 1.

  • Oleg Resh Profile Picture
    45 on at
    RE: Access unbound form control from display method of form extension

    In PU15, it became possible to assign display / edit methods to an extension.

    To experiment in the extended form class added the following method:  

         public display boolean haveGroupRows(PdsBatchAttribByAttribGroup _groupLine = PdsBatchAttribByAttribGroup)

         {

             PdsBatchAttribGroupSalesLineM attSalesLines;

             ;

             info('1');

             select firstOnly attSalesLines

                 where attSalesLines.SalesLineRecId              == salesLine.RecId

                 &&    attSalesLines.PdsBatchAttribGroupId  == _groupLine.PdsBatchAttribGroupId

                 &&    attSalesLines.PdsBatchAttribId            == _groupLine.PdsBatchAttribAttribId;

             If (attSalesLines)

                 return true;

             else

                 return false;

    Created a control and write a new method in the properties.
    Does not work

         }0434._21043A04400438043D04_.jpg

  • Oleg Resh Profile Picture
    45 on at
    RE: Access unbound form control from display method of form extension

    In principle, you understood correctly, but there is one nuance, the general data structure is displayed by attribute groups and attributes, it will be the same for all order lines, i.e. the user does not create new lines, but simply selects by putting a flag on the necessary attributes. It is this functionality of putting a flag and I wanted to do it through the edit method.

    _21043A04400438043D04_.jpg

    Corrected the form and added checkBox, in which the selection should occur

  • Sohaib Cheema Profile Picture
    46,614 User Group Leader on at
    RE: Access unbound form control from display method of form extension

    I failed myself again to understand the problem.

    I can understand the process that you have described in your recent reply with the help of a screenshot, which shows that for each sales lines you have a selected attribute-group and further based selected attribute-group there are multiple attributes (within a single attribute). Cool, so far.

    However it does not mentions what the problem is?

    If I look again at your original post, you have shown us a display method from AX2012. It is difficult for me to understand about the problem that comes while to try to replicate same method in AX7.

    Please help us, if you want us to help you. Also you may want to create a new thread please.

  • Oleg Resh Profile Picture
    45 on at
    RE: Access unbound form control from display method of form extension

    I do not agree that the problem is in the relationship between the tables.

    Maybe I have not quite clearly described. I will try again:

    We have a table of groups of Batch (pdsBatchAttribGroup), each group has attributes (PdsBatchAttribByAttribGroup).

    It is necessary for the sales line to determine which attributes are key for this order, and accordingly parties will be selected based on this choice.

    To simplify the selection, I created on the form the sales lines (SalesTable) tree batch group list  and the attributes list, where the user chooses which attributes he needs.

    Accordingly, on the same form, you must see which attributes are already selected.

    Sampling and displaying and I could make it through the edit method 

    tempsnip.jpg

  • Sohaib Cheema Profile Picture
    46,614 User Group Leader on at
    RE: Access unbound form control from display method of form extension

    Hi Oleg Resh,

    Your problem sounds more like a relationships between the tables and not about display methods.

    Can you please open a new thread and providing details of your problem in the new thread.

  • Oleg Resh Profile Picture
    45 on at
    RE: Access unbound form control from display method of form extension

    Hi, All!

    And yet, how could this problem be solved?
    For example, I need on the form SalesTable to display the data from GroupSalesLines. At the same time, a sample of data from group rows goes by a composite key: RecId of the sales line and GroupId from GroupTable.

    Accordingly, in the displace method, you need to give 2 tables SaleLine and GroupTable

    Lets imagine in ax 2012 it can looks like this:

          display boolean haveGroupRows(GroupLine _groupLine)

           {

    GroupSalesLines groupSalesLines;

    ;

    select firstOnly groupSalesLines

    where groupSalesLines.SalesRecId == salesLine.RecId

    &&     groupSalesLines.GroupId     == _groupLine.GroupId

    &&     groupSalesLines.AttribId      == _groupLine.AttribId;

    If (groupSalesLines)

    return true;

    else

    return false;

           }

    that is, it is necessary on the form of order lines to display a list of groups and their attributes, and opposite each attribute to display a mark that this attribute is included for a given line or not.

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

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

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 293,278 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 232,011 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans