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?

Solved Solved
0 5 239
1 ACCEPTED SOLUTION

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โ€)

View solution in original post

5 REPLIES 5

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.

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.

Top Labels in this Space