HII'm working with the following table structures and need to display approval tasks to users based on the current milestone of each request. A task should be shown if the user is either directly assigned or belongs to the assigned group. Each row in Request table has multiple rows in approval table.
Is there a way to achieve this using records (not a database view) given the structure below?
CREATE TABLE `table_request` ( `col_id` INT NOT NULL AUTO_INCREMENT, `col_loan_key` VARCHAR(32) DEFAULT NULL, `col_loan_1` VARCHAR(32) DEFAULT NULL, `col_loan_2` VARCHAR(255) NOT NULL, `col_manager` VARCHAR(100) DEFAULT NULL, `col_sponsor` VARCHAR(255) DEFAULT NULL, `col_milestone` INT DEFAULT NULL, `col_status` INT DEFAULT NULL, `col_submit_date` DATETIME DEFAULT NULL, `col_created_date` DATETIME NOT NULL, `col_created_by` VARCHAR(255) NOT NULL, `col_updated_date` DATETIME NOT NULL, `col_updated_by` VARCHAR(255) NOT NULL, `col_is_active` TINYINT(1) NOT NULL, PRIMARY KEY (`col_id`), KEY `idx_milestone` (`col_milestone`), CONSTRAINT `fk_status` FOREIGN KEY (`col_status`) REFERENCES `table_lookup` (`col_lookup_id`) ON UPDATE CASCADE, CONSTRAINT `fk_milestone` FOREIGN KEY (`col_milestone`) REFERENCES `table_lookup` (`col_lookup_id`) ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci; CREATE TABLE `table_approval` ( `col_id` INT NOT NULL AUTO_INCREMENT, `col_request_ref` INT NOT NULL, `col_created_date` DATETIME NOT NULL, `col_updated_date` DATETIME NOT NULL, `col_created_by` VARCHAR(255) NOT NULL, `col_updated_by` VARCHAR(255) NOT NULL, `col_is_active` TINYINT(1) NOT NULL, `col_milestone` INT NOT NULL, `col_assignment_type` INT DEFAULT NULL, `col_approval_key` VARCHAR(100) DEFAULT NULL, `col_required_count` TINYINT(2) DEFAULT NULL, `col_assigned_date` DATETIME DEFAULT NULL, `col_due_date` DATE DEFAULT NULL, `col_approver_name` VARCHAR(255) DEFAULT NULL, `col_status` INT NOT NULL, `col_approval_date` DATETIME DEFAULT NULL, PRIMARY KEY (`col_id`), KEY `idx_status` (`col_status`), KEY `idx_milestone` (`col_milestone`), KEY `idx_assignment_type` (`col_assignment_type`), CONSTRAINT `fk_status` FOREIGN KEY (`col_status`) REFERENCES `table_lookup` (`col_lookup_id`), CONSTRAINT `fk_milestone` FOREIGN KEY (`col_milestone`) REFERENCES `table_lookup` (`col_lookup_id`), CONSTRAINT `fk_assignment_type` FOREIGN KEY (`col_assignment_type`) REFERENCES `table_lookup` (`col_lookup_id`) ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci;
I'm able to achieve the functionality by creating a view in below structure but I want to see if this is achievable using Appian records. Any suggestions would be greatly appreciated.
SELECT a.*, -- All fields from approval table b.col_id AS col_request_id, b.col_loan_1 AS col_loan_number, b.col_loan_2 AS col_loan_type, b.col_milestone AS col_request_milestone, c.col_value AS col_milestone_label FROM table_approval a JOIN table_request b ON b.col_id = a.col_request_ref JOIN table_lookup c ON a.col_milestone = c.col_lookup_id WHERE b.col_milestone = a.col_milestone AND b.col_is_active = 1 AND a.col_is_active = 1;
Below is some dummy data
If I login as User_analyst 1 only requests that are assigned to user_analyst1 needs to be displayed to me, But If'm also part of Manager group and director group, I should also see the tasks that are directly assigned to those groups.
Thanks.
Discussion posts and replies are publicly visible
This seems to me like a pretty commonly supported scenario for synced records. You can model each of the tables as a record type, create relationships between them, and apply record-level security to the approval table (to ensure users can only see requests assigned to themselves, except for managers that can see tasks in their groups as well).
I'd certainly recommend giving it a shot and letting us know if you run into any issues!
Thanks Peter. How would you handle if same user is part of multiple Groups? And these tasks should be displayed to the next approver only after the prior approval is done.
Just create security rules for each of the scenarios you would like. You can set up rules with multiple groups and define conditions based on your data (i.e. only give visibility if the approval is done)
HI Peter, looks like the issue we are still unable to solve the issue as we need to match the logged in User with the value in the field. But I don't see a way to configure that.
Can you use the users found in fields option?
We are currently storing user and Group in the same field with a separate column in DB to identify whether the approval is assigned to User or Group. In this case, appian is not enabling the field as Appian detects the field as text and we cannot update the type to User or Group.
Can you create a custom field that splits out the user or group into separate columns and use each of those columns to determine the security?
I managed to segregate the data, but I'm unable to define the toUser function during real-time evaluation or sync-time evaluation. Additionally, the value is being defined as text and not as a user , and the custom field is not appearing on the security summary.
Ahhhh I see what you mean. One approach could be to try and create two separate record types (one for user approvals and one for group approvals with a source filter on each) and then use those relationships. You're right - I forgot that you can't set a custom record field as a user or group type (although it is something that is in consideration!) so probably the separate record types is your best bet.