Search code examples
axaptax++dynamics-365-operations

Block FormRun task from executing in DetailsTransaction pattern


I am building a simple journal form based on the form pattern DetailsTransaction. In this pattern it has the standard two view layout, the header/*journalTable grid and a lines/*journalTrans grid.

However, when I click the New button two create a new header/journal, it automatically invokes the taskSwitchToDetailsView task and switches to the lines. I wish to block this from happening, but I am unsure on how to do it. Is there a way to block this task from being invoked?


Solution

  • There is a lot of complexity around the OOTB journals, and if I needed a robust journal implementation I would have created classes that derived from JournalFormController and JournalFormTable/JournalFormTrans which provide number sequence generation, blocking/locking, validation, and much more very useful and powerful functionality to a journal form + table structure.

    However, I don't need any of that. So to solve my specific problem I added this to the create method of the *journalTable datasource's create method (which the super call changes the context of the form to the lines by calling task(#taskSwitchToDetailsView). To counter this, I simply call task(#taskSwitchToGridView) immediately after the super.

    [DataSource]
    class CustomJournalTable
    {
        public void create(boolean _append = false)
        {
            #Task
    
            super(_append);
    
            element.task(#taskSwitchToGridView); 
        }
    }