is it possible to script out the Edit button on a ...
# suitescript
is it possible to script out the Edit button on a record if the current User isn't the Owner of the record? Using SS2 if possible.
You could use a workflow and lock the record
Yes it's possible, there's a remove function somewhere and you can check ID of logged in user.
@Daniel Lloyd After further reading, I don't think you can specifically remove the Edit button among the list of buttons you could remove, though fetching the ID of the current user isn't that hard. Netsuite probably leaves it accessible on purpose. @ehcanadian I'd like it so that the record would unlock if the user was the owner though, would it be possible to "unlock" a locked record that's being locked by a workflow?
Pretty sure I did form.removeButton({id:”edit”})
Might need “submitedit” too
@Daniel Lloyd I gave it a try, and surprisingly it worked. I initially wrote it off since checking the SS2 API pdf, the Button id's never indicated anything for the Edit button, though I guess that's something they wouldn't want people removing unknowingly. Thanks for this.
Yep, there's plenty of undocumented functionality. It's just vulnerable to being pulled out/unsupported and needs that assessment before being implemented in a business.
This method doesn't prevent the user from adding
to the URL and editing the record anyway. As ehcanadian mentioned above, using a workflow with the lock record action would work and no scripting required.
@Mike Robbins I see. Am I correct to assume I can conditionally "lock" and "unlock" it based on the current User through workflows? From what I've been reading on it, locking records through workflows seem to be a one-way thing, though this might be another case of undocumented features not being written down.
@7px Yes. You can apply conditions to the "Lock Record" action so that it only applies if the current user is the owner of the record. Locking a record only applies while the record is in a workflow state that contains the Lock Record action. As soon as the record transitions to another state without that action, the record is unlocked. It's not a permanent status by any means.
You can stop them doing &e=T on a user event before load, you make the relevant checks on EDIT and redirect back to the opened record with it set to view. It's trivial to do.
Also as for button IDs in help...
Copy code
if (context.type === context.UserEventType.EDIT) {
        type: record.Type.VENDOR_BILL,
You will want to preface this with any logic you need to determine that you do not want it editing. (you could also use context.newRecord.type for "type" above)