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

I have the same question (0)
  • nmaenpaa Profile Picture
    101,162 Moderator on at

    First of all, if this display field is always supposed to be empty when "showOpen" is not selected, why not hide the entire field? Otherwise you are causing unnecessary performance overhead. Especially because your code always performs the find operation, even when it needs to return empty.

    Second, I think your syntax for CoC on form data source is not correct. You need to create a new class (and it's possible only from PU18 or PU20 onwards, not sure which one):

    [ExtensionOf(formDataSourceStr(LedgerTransAccount, GeneralJournalAccountEntry))]

    But it might be that you still can't add new methods in form data sources this way - you can only use Chain of Command on existing form data source methods.

    So the easiest solution for your case is to hide the display field when "showOpen" is not checked.











  • diana.v Profile Picture
    20 on at

    Hi

    Nikolaos,

    Thank you for your reply. But i have simplify the requirement for question.  

    Lets imagine in ax 2012 it can looks like this:

           display Num SettleId(GeneralJournalAccountEntry _generalJournalAccountEntry)

           {

               LedgerTransSettlement ledgerTransSettlement = LedgerTransSettlement::findTransRecId(_generalJournalAccountEntry.RecId);

               if (showOpen.value() && ledgerTransSettlement.MyNewDateField > MyNewFormDateControl.dateValue())

               {

                   return '';

               }

               return ledgerTransSettlement.SettleId;

           }

    So its impossible to hide display field on showOpen value, because the value of this field depends on more conditions.

    But i can't find out how to realize this functionality in ax7..

  • Sohaib Cheema Profile Picture
    49,438 User Group Leader on at

    How if you think it otherwise.

    For example. Hide or show your Display Field, as soon as the showOpen(control) is modified.

    With this approach, you would also handle the situation for init of the form, which means when form is loaded first time, what is default value of showOpen(control). On init of the form, same you should do with your display field.

  • diana.v Profile Picture
    20 on at

    Hi Sohaib,

    Will try, thank you for the idea :)

  • Oleg Resh Profile Picture
    45 on at

    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.

  • Sohaib Cheema Profile Picture
    49,438 User Group Leader on at

    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

    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
    49,438 User Group Leader on at

    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

    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

  • Oleg Resh Profile Picture
    45 on at

    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

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 > Finance

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans