0

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?

rjv
  • 1,058
  • 11
  • 29

2 Answers2

1

Have you experimented with the viewEditModeHelper() and other form event handlers?

I don't have an environment in front of me now, but here's a little snip that might give you an idea where to look. I know it's not exactly what you're looking for but the same style is what I would think.

[FormEventHandler(formStr(LogisticsPostalAddress), FormEventType::Initialized)]
public static void MyForm_OnInitialized(xFormRun sender, FormEventArgs e)
{
    // Subscribe event handlers
    FormRun formRun = sender as FormRun;

    formRun.viewEditModeHelper().EditModeSwitched += eventhandler(MyEventHandler.ViewEditModeSwitched);

}
Alex Kwitny
  • 11,211
  • 2
  • 49
  • 71
  • I think that this event is for switching between read and write mode on the form, as opposed to the header/lines context switch for merged header and lines forms – rjv Oct 07 '19 at 13:26
0

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); 
    }
}
rjv
  • 1,058
  • 11
  • 29