Sure, here's how you can format y
I have created a use case with two tables: `requestor` and `approval`. The `requestor` table has a `status` column which is an enum with the values: `new`, `pending`, `approved`, and `rejected`
problem Statement:
I need to update the `status` of the `requestor` table based on a button click in the `approval` table. Specifically, when the button is clicked and saved, the `status` in the `requestor` table should change to `pending` if approved, or `rejected` if denied.
I have created the `approval` table and a view that shows the `requestor` details. I also created a button using the behavior tab to approve the request.
Specific Details:
Here is a simplified version of my schema:
requestor table:
- id (primary key)
- status (enum: 'new', 'pending', 'approved', 'rejected')
approval table:
- id (primary key)
- requestor_id (foreign key referencing requestor.id)
- other_columns...
The button logic needs to handle the following transitions:
- If the request is approved, change `status` to `pending`.
- If the request is rejected, change `status` to `rejected`.
5. Request for Help:
Could someone guide me on how to implement the button logic to update the `status` column in the `requestor` table based on the approval or rejection action?
Hi,
Welcome to the community!!
Surely I can help you.
If possible, share the app with me so that I can make necessary settings in the app if you could not do it.
BTW, your explanation was good.
Steps to be followed:
1. Almost all necessary tables have been created, and some actions have been set up.
2. Create a new action (Type): "Set values to some of this columns of this row" for REQUESTOR TABLE. Action: "MARK PENDING or REJECTED"
[STATUS] =
```
if(
LOOKUP([THISROW].[REQUESTOR ID], "APPROVER TABLE", "RELATED REQUESTOR ID", "STATUS") = "APPROVED",
"PENDING",
"REJECTED"
)
```
--- Make the action hidden.
// I am not taking the rejected condition seriously since you have only 2 possibilities either pending or rejected. if the approver table has rejected naturally IF() statement will return the values as rejected.
3. Create a new action type: "Execute an action on set of rows" in Approver table.
Name it as: "Set values in Requestor table"
For a record of this table: Approver table
Do this: Execute an action on set of rows
Referenced Table: Requestor table
Referenced row: [RELATED REQUESTOR ID]
Referenced action: "MARK PENDING or REJECTED"
Make the action hidden and save the action.
4. Create a grouped action: executed sequence of action.
- First, add the action you have created to set values "new", "pending", "approved", and "rejected" in approver table in the group action.
- Second, add the "Set values in Requestor table" action to grouped action.
Make it prominent or primary as you like.
5. Hide the action which was created by you for setting values "new", "pending", "approved", and "rejected".
--------------------------------------
Whenever you hit the group action 1st, it sets the values in the approver table and sets the values in the requestor table.
Similarly, I have made a simple app like this for user approval. If you have doubts, please feel free to approach.
---
Thank you for responding to my message. I will work on the idea as soon as possible and let you know how it goes. If I encounter any issues, I'll reach out for further assistance.
User | Count |
---|---|
16 | |
10 | |
9 | |
8 | |
3 |