Is there a way to prevent deleting records besides...
# suitescript
g
Is there a way to prevent deleting records besides throwing an error in beforeSubmit
c
Revoke their permissions.
💯 1
g
It needs to be only for certain roles when deleting invoices that have specific field values, so that won't work in this case.
c
@GMR Admin Can you redirect to the same record in View mode with a pageinit message?
g
Which entry point would you use for that?
I don't know of any that get triggered by the delete action
e
In some transaction I can see this options in a Workflow Workflow Action > Remove Button > Delete
👍 1
g
I was typing something similar actually
it can be removed but not sure if suitescript offers that same functionality
might need to be a workflow
You cannot use suitescript to disable actions.
Does the delete button trigger saveRecord in client scripts?
c
@GMR Admin I don't believe so, because you're not submitting the current form fields to save the record but instead issuing a record delete action. Could you try creating a second transaction form for this scenario that doesn't include the Delete action, then load that form for the logic branch that you're preventing delete for? Also throw the error in beforeSubmit just in case someone figures out how to trigger via URL or some other method...
g
It does not trigger it. I just tested.
I doubt they're going to be ok with a second form.
Looks like workflow is the way to go
👍 1
c
That might just leave you with DOM manipulation or other client-side script hacks that aren't robust or reliable
Cool, hope the workflow solves this for you!
g
yeah I really dislike DOM hacks in the native UI.
1000 1
Thanks!
n
Wonder if you do your various check on beforeSubmit and use redirect.toRecord. I'm thinking you could add a param in the options of that, pick it up in a beforeload and add a message to the form. Just not 100% sure if the UE would fire a second time if you redirect, I'm 50/50 on that.
c
@NElliott Unfortunately, redirecting from beforeSubmit doesn't work - the beforeSubmit function finishes and the delete action completes. I have used redirect in beforeLoad before, but that's a different case. I tested it in beforeSubmit yesterday, including all manner of combinations of errors, returns, breaks, etc.
😖 1