Hide "Add" action - Pass and read "Context metadata"

Hi,

User story:
As an Admin I would like to prevent users from adding additional job_items to the given job after the job is closed.

View:
On the detail view of a job (lets call it “Job details”) , the inline view of the related job_items is displayed.
As we know this inline view enables the user for direct job_item creation to the given job.

Problem:
As I understand, the action to ”Add” a record to any table cannot be controlled by row-level “Only if this condition is true” expression (ex.: IF job is closed…) because it is a table-level action.

However,
Context() rules can be applied whether the action should be hidden or not.
or
I can create a custom “Add job_item” action that can handle row-level conditions for the job’s status. (But this action won’t be displayed at the inline view I guess)

I was thinking, what could be the most efficient way of handling this situations and my idea is:

  • in case we could pass and retrieve metadata to the given context based on the displayed row’s information,
  • we wouldn’t have to create new view to restrict the original “Add” action.

Questions:

  1. Is my description accurate about the problem? Does anyone knows a solution that doesn’t require new view or action creation?
  2. IF I was right,
  • what is your opinion about the context metadata idea?
  • Does this situation happens often enough to make such a feature worth to develop in your opinion? (Or are there other usecases where such a feature would make our life easier?)

You could create a slice on the job_items table that doesn’t allow adds, then add a new virtual column to the jobs table with an App formula of [Related job_items], type List, base type of Ref, and referenced table of the slice. Give this new column a Show? expression that evaluates to TRUE only when the job is closed. Give the original Related job_items column a Show? expression that evaluates to TRUE only when the job is not closed. In your views, ensure the Related job_items and this new slice column occur next to each other. This prevents the user from accessing the Add action from the inline view of a jobs row, but does not prevent additions if the user finds their way to the job_items table in another way.

Or you could add a virtual column to the job_items table that blocks the addition of a new row when the job is closed. Make it type Text with an App formula that produces a suitable error message (e.g., New items not allowed) only if the job is closed. Set the Valid if expression to ISBLANK([_THIS]). Ensure the column occurs in your form views. This prevents all addition regardless of how the user reaches the form, but it doesn’t prevent the user from getting to the form. This might be confusing to the user.

2 Likes

Hi,

I love both solutions!
Thanks a lot for the creative ideas!!!
(I haven’t seen them previously under similar topics)

2 Likes