Block specific users from processing a connected form

I have a RAMS (Risk Assessment) process that i need to be processed by a Lead Engineer (account) who has been assigned to a works order connected field.

The RAMS form creates a Make process and puts a document in the Lead Engineers email inbox by simply processing a form.

The RAMS record is linked to the Works Order table.

What i want to know is it possible to stop the form for the RAMS being run by anyone else other than the Lead Engineer who has been associated to that page.

I may just need to create a new table for accounts that are assigned as lead engineers on a new page but i’d like to keep it all on one main works order page.

Hi @AndrewClar42169, you could keep all this on one page using Page Rules, where you can hide the particular view if the logged-in user’s role does not contain ‘Lead Engineer’.

Unfortunately that won’t work. I use page views already which is great for when using global account roles.

This field is variable, the lead engineer is set when the job is created, the engineers group can have any individual as a lead engineer, so for a specific job we only want the assigned lead engineer to have the ability to use that form.

Ah I see. Unfortunately there’s no native way to control that, so it would require a simple slice of JavaScript which will get the current logged in user from a details view, and compare it to the ‘assigned to’ field in the job/project record to hide the form view.

  1. Create a details view (e.g. view_4) with the assigned to field (e.g. field_12) visible, and the form below (e.g. view_5) that you’d like to show/hide.

  2. Add the following bit of code, making sure to replace view_4 with your details view, field_12 with your ‘assigned to’ field, and view_5 with your show/hide form view.

$(document).on('knack-view-render.view_4', function(event, view, record) {
  var assignedUser = record.field_12_raw[0].id
  var loggedInUser = Knack.getUserAttributes().id;
  if (assignedUser != loggedInUser) { // Hide work order form when user is not assignee