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

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Enable and Disable lines button on header form

(0) ShareShare
ReportReport
Posted on by 2,059

Hi,

I'm working in test environments and trying to learn forms.

I'm trying to mimic the 'General Journal' form Lines button enable/disable behavior on 2 simple custom forms that I created, "HeaderForm" and "LineForm".

I have created a "Lines" button (which has a menu-item with "LineForm") on "HeaderForm".

To disable the "lines" button on header form when opening the line form I have written button.enable(false); in clicked() method of the 'Lines' button. The button gets disabled correctly.

But how do I enable the button on the header form only when the line form is closed?

I can't figure out how to access the Header form button in lines form Close() method.

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    nmaenpaa Profile Picture
    101,160 Moderator on at
    RE: Enable and Disable lines button on header form

    I think on the journal forms, the system updates a "Blocked" checkbox in the header table when the Lines form is opened. And when the Lines form is closed, that checkbox is cleared. Only this way it can be disabled for all users, if one user is working on the lines.

    The enable/disable logic should be written in the active method of the data source on the header form.

    When the Lines form is opened or closed, you need to update the Blocked field, and call the header form data source refresh so that the button gets updated for the current user.

    You can refresh the header form's data source from the close method of the lines form by:

    element.args().record().dataSource().refresh();
    
    element.args().record().dataSource().research(true):
  • MYGz Profile Picture
    2,059 on at
    RE: Enable and Disable lines button on header form

    Thanks Nikolaos. Working on this. Will provide detailed feedback once I finish implementing it.

  • MYGz Profile Picture
    2,059 on at
    RE: Enable and Disable lines button on header form

    Hi Nikolaos,

    On exploring the LedgerJournalTable form, I'm getting the impression that when lines button is clicked, "In Use" checkbox is checked and "Used by User" gets the userid.

    There's an edit method  inUseBlock in LedgerJournalTable DataSource in LedgerJournalTable Form as below:

    //BP Deviation Documented
    
    edit JournalMarkInUseBlock inUseBlock(boolean _set, JournalTableMap _journalTable, JournalMarkInUseBlock _value)
    
    {
    
       ;
    
       return journalFormTable.datasourceMethodInUseBlock(_set, _journalTable, _value);
    
    }

    public JournalMarkInUseBlock datasourceMethodInUseBlock(
        boolean                 _set,
        JournalTableMap         _journalTable,
        JournalMarkInUseBlock   _value)
    {
        if (_set)
        {
            if (!_value && _journalTable.SessionId)
            {
                if (formRunLines)
                {
                    formRunLines.close();
                }
                else
                {
                    journalTableData.updateBlock(JournalBlockLevel::None,JournalBlockLevel::None);
                    this.updateFormCacheCurrent(journalTableData.journalTable());
                    journalTable_ds.active();
                }
            }
    
        }
        return _journalTable.SessionId ? true : false;
    }
    
    

    I tried debugging but I'm unable to figure out how the "In Use" is checked, unchecked and how the lines button is enabled, disabled based on the "In Use".

  • nmaenpaa Profile Picture
    101,160 Moderator on at
    RE: Enable and Disable lines button on header form

    Did you debug these methods? Are they called when the user opens the Lines form?

    You can also use the cross references to see who (which code) read/write the InUse field.

  • MYGz Profile Picture
    2,059 on at
    RE: Enable and Disable lines button on header form

    Hi Nikolaos,

    I found the code where it's enabling and disabling the line button, but I still can't figure out the execution flow.

    Here's the code:

    class JournalFormTable extends JournalForm
    {
    	...
    	...
    	public void enableButtonsActive(boolean _enableInfolog = true)
    	{
    		boolean enabled = journalTableData.blockLevel() == JournalBlockLevel::None  
    							&& !formRunLines 
    							&& journalTable.JournalNameId;
    
    		if (ctrlLines)
    		{
    			ctrlLines.enabled(enabled);
    		}
    		
    	...
    	...
    }

    class FormRun extends ObjectRun
    {
    ...
        void init()
        {
           ...
           journalFormTable.parmCtrlLines(journalLines);
           ...
    ...
    }

    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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Pallavi Phade – Community Spotlight

We are honored to recognize Pallavi Phade as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Tocauer Profile Picture

Martin Tocauer 4

#2
Alexey Lekanov Profile Picture

Alexey Lekanov 2

#2
NNaumenko Profile Picture

NNaumenko 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans