How to pre-fill a column depending on the view

Good day everyone,

I hope you can help me. I have a table TRANSACTIONS and I want to identify easily the “INCOMES” and the “EXPENSES”, so I have a column [transactionType] which is an enum with those two values.

Then, I want to add 2 buttons “Add Income” and “Add Expense” which both use the same table.

I was wondering if there is a way to pre-fill the value of [transactionType] based on the the pressed button, so if someone presses “Add Income”, then [transactionType]=“INCOME”, and if someone presses “Add Expense” then [transactionType]=“EXPENSE”.

Is it there a way to achieve this?

It sounds from your post heading that you probably wish to prefill a button with a value depending on the view.

Could you please add more details to your requirement? Somehow, it sounds that the [transactionType] column values and

are probably one and the same.

1 Like

Thank you @Suvrutt_Gurjar

I’ll try to re-phrase my previos question.

I want to have 2 views which are almost identical since both views are for adding a “transaction” into the TRANSACTIONS table.

But, I have 2 types of transactions… “Incomes” and “Expenses” (and that is the main difference). I differ them by having a column [transactionType] which is an Enum that can be either “INCOME” or “EXPENSE”.

Then, I want to have 2 views… one to “Add Income” and another to “Add Expense”, and I want them to show on the bottom of the scree as 2 buttons.

What I wish, is that if the user hits on the “Add Income” button, the view will be displayed and the [transactionType] would be already selected as “INCOME”.

In similar way, when the user will hit the “Add Expense” button, then the view will be displayed and the [transactionType] would be already selected as “EXPENSE”.

Eventually, the idea is to even not show the [transactionType] in the view (as long as the proper values are pre-filled, depending on the button the user is hitting).

All of this is just to prevent the user would be wrongly adding an “income” but by mistake have the [transactionType] as “EXPENSE” (or viceversa).

I hope that this explains better my user case.

Thank you for all the details.

Presuming you mean primary views by the above and “Add Income” and “Add Expense” are two form type views, please explore having an expression like following in the initial value of [transactionType] . You could also keep this [transactionType] column hidden.

IFS(CONTEXT(“View”)=“Add Income” , “INCOME” , CONTEXT(“View”)=“Add Expense” , “EXPENSE”)


Thank you @Suvrutt_Gurjar as usual, your tips were very helpful! it worked like a charm!


You are welcome. Please refer below article for a quick reference just in case you have already not.

1 Like