Simple Solutions: Disable Role From Deleting an Attachment
Jan 18, 2022Not long ago, a client of mine asked me how to disable specific user roles from deleting attached files.
The challenging part... these users would still need permission to add attachments.
This meant they had to have 'modify' access to the attachment field.
While I was quite confident there weren't any role settings that would address this, I made sure to double check that Quickbase hadn't slipped in something new.
I was able to verify that the role permissions include an option to disable deleting the entire record, but not an attachment.
And while there are rules that can be set for viewing or modifying the record, these cannot be used for specific attachment fields.
That's when the thinking cap came on! 🤠
Noodling on Custom Data Rules, I determined that it wouldn't be possible to 'detect' the delete action when the user saves the record.
Then it came to me... in the form of good old Form Rules!
To access Form Rules:
- When viewing the applicable form: Click on "Customize this Form" in the upper right, then click on the "Dynamic Form Rules" tab.
- From the table settings menu: Click on "Forms", then select the from this rule will apply to. Repeat for other forms as necessary.
Add the following rule, adjusting for your needs.
What this form rule does is check that the attachment field is not empty AND that the user is in the "Team Member" role.
If both are true, the file attachment field is made read-only.
This allows the "Team Member" users to add files, view files, but not delete files.
TIP: Many browsers allow you to drag and drop files into the "Choose File" button.
How it would look if the delete option was available.
Additional Notes
Some Quickbase builders steer away from using form rules because they only apply while the form is being used (i.e. the rules aren't enforced in Grid Edit, Import, or other non-form methods of editing and entering data).
However, in the case of attachments, this is a non-issue.
Attachments cannot be deleted using grid edit or import!
Other Rule Options
Depending on your needs you may opt for one of these alternative rules.
Only Administrator Can Delete
Multiple Roles Can't Delete
CAUTION: Notice the use of "any" prior to listing the roles the user is in.
More Resources
Simple Solutions: How to Require A File Type for Attachments Read the Post
What's With File Attachments | Opening vs Downloading Read the Post
The 7 Must Know Form Properties Watch the Video
Why You Should Hide Fields on Your Forms Watch the Video
Don't miss new Simple Solutions >> Subscribe Now!