Prevent record insert from "Insert a New Row" based on parent state

Janel2
Mega Expert

Is there any sort of method to disable the "Insert a new row..." function on a related list based on the parent record's state?

We have a form setup for network route requests.   The user fills out some information on a parent record and then adds the actual route entries exist on a different table as its own record.   For ease of adding entries, we are allowing users to insert new records from the related list while the parent is in a Draft state (List Control > List edit insert row == true).   Once the request is submitted, an ACL prevents the submitter from being able to write, which stops the inserting of new records.   This works fine for the submitter.

After it is submitted, a group of people approve each record (not using system approvals) by changing an Approval drop down to Approved, Rejected, etc. and make any edits to the entry as needed.   So we obviously need them to be able to write to the entries while the parent is in the "Pending Approval" state.

The problem is that we do not want them to *create* new records from the "Insert a new row..." option, but we want them to edit records from the related list.   The approvers are still able to *add* entries via the "Insert a new row..." option when they shouldn't be able to.  

I cannot add a create ACL that looks at the parent state to prevent adding, as we run into a cart before the horse situation.   When adding from a related list row, the parent field doesn't exist yet, so if I add a create ACL, it prevents inserting from a row for everyone, at all time.   I've been through the List Control options without any luck as there isn't a way to omit list insertion like there is the New or Edit buttons.

I've tried ACL after ACL, between list_edit, writes, and creates, but no dice.   Either the submitter can edit or create after submission or no one can edit or create at any time.

My next guess is that I need to look at some sort of business rule that stops inserting, but where would that BR live?   And would I still run into the same issue as the create ACL where people will never be able to add because the parent field doesn't exist yet?

1 ACCEPTED SOLUTION

Janel2
Mega Expert

Guess I should have tried the BR idea first!



Looks like the parent field not being populated isn't an issue here.   On the route entries table, I made a Before BR that runs on insert.   Added filter conditions where if the parent is not in Draft or Review, run the rule.   In the advanced script I simply plopped in current.setAbortAction(true); with an info message indicating the record wasn't added.



Seems to be working like a champ so far.   Submitters get the normal ACL "security prevents writing" notice and the approvers get the gs.addInfoMessage notice.


View solution in original post

1 REPLY 1

Janel2
Mega Expert

Guess I should have tried the BR idea first!



Looks like the parent field not being populated isn't an issue here.   On the route entries table, I made a Before BR that runs on insert.   Added filter conditions where if the parent is not in Draft or Review, run the rule.   In the advanced script I simply plopped in current.setAbortAction(true); with an info message indicating the record wasn't added.



Seems to be working like a champ so far.   Submitters get the normal ACL "security prevents writing" notice and the approvers get the gs.addInfoMessage notice.