A quick question, is there system flag that w...

A quick question, is there system flag that will let me know if the record is in edit mode? I want to show/disable certain fields if the record is in edit mode. Thanks in advance.

0 4 710
4 REPLIES 4

If youโ€™re asking to know if some other user is editing the record, then no. If youโ€™re just taking about in the app, then I would say you know itโ€™s in edit mode of the user has a form view open. So turn off show if universally in the UX settings, and then you can use the show if in the column settings

As @Grant_Stead indicated, if the user is adding or editing the row, the Form view is used; a non-Form view is used for anything else.

Thereโ€™s no system-provided way to determine how the user is viewing a row. The way I work around it is to maintain a modification counter for each row ([mcount]) that is incremented by the columnโ€™s App formula (=([_this] + 1)) every time the row is loaded into a Form view. Knowing that the columnโ€™s value is incremented in the (temporary, as-yet-unsaved) Form view, and thus different from the saved, โ€œon-diskโ€ copy, I can compare the formโ€™s copy with the saved copy to determine what the user is doing:

switch((lookup([_thisrow].[KEY], MyTable, KEY, mcount) + 0), 0, โ€œaddโ€, [mcount], โ€œviewโ€, โ€œeditโ€)

Replace KEY, MyTable, and mcount as appropriate for your schema.

This formula compares the modification counter (mcount) of the visible row ([_thisrow].[KEY]) against the columnโ€™s value as stored (lookup(โ€ฆ)). If the row is new, there is no stored copy, so lookup() returns NULL, which I convert to a number (lookup(โ€ฆ) + 0)) (NULL + 0 = 0). If the result is 0, the row is being added (โ€œaddโ€). If the result matches the visible value ([mcount]), the increment from the App formula has not been applied, so I know a Form view is not in use, thus no add or edit is occurring (โ€œviewโ€). Otherwise, knowing that the visible and saved values of [mcount] exist and differ, I assume the App formula has been applied within a Form view to a pre-existing column, indicating an edit operation (โ€œeditโ€).

Note that [_thisrow] is required within a lookup() to refer to the visible row, rather than to the row targeted by the lookup().

So, using the expression in my last comment, you could try to show and hide columns selectively using Show_If. In my experience, that becomes really cumbersome really quick.

My current preference for hiding columns in forms is to layer a Slice atop each and every Table. All of my expressions then reference the slice rather than the table (with a few exceptions). The slice allows me to control what occurs in forms and where, and views allow such control elsewhere.

To hide columns in forms while keeping them available for other views, I add a Show column of the Page_Header category immediately after the last form-visible column, and set Show_If for this Show column to =false. Every column in the slice on this page will be hidden on forms but still available for all other uses.

Top Labels in this Space