Reposting in the correct channel: When executing a...
# suitescript
r
Reposting in the correct channel: When executing a suitescript that makes use of record.attach function to attach a file to a Vendor Bill record, what permissions are required for the script to execute the record.attach function? Script is able to create the file in the file cabinet using the file.create command, but the subsequent record.attach fails with INSUFFICIENT_PERMISSION - You do not have permission to perform this operation error.
In sandbox, the script works fine with the admin role, but for prod we want as tight a security role as possible
p
i'm guessing that the user needs at least "Edit" or "Full" permissions on the record type being attached.
Make sure that the user executing the script has the necessary permissions to edit the Vendor Bill records.
r
Yep, I'm pretty sure that was granted, but I'll confirm to be sure. We needed to add Documents to the role to allow the creation of the file
t
how about the folder permission? Does the user have necessary permission to upload
r
We can create the file in the file cabinet without issue, if that is what you mean
👍 1
It's the record.attach action after the file creation that is throwing the error
t
maybe you can play around on the entry points.. For example use the record.attach beforeLoad/AfterSubmit/beforeSubmit 🤔
r
The script works fine with admin role, so I'm confident the script is fine and is indeed a permissions issue.
Not helped that I don't have access to prod and rely on customer "admin" to confirm settings and make changes. And they're not very experienced with the platform
🫣 1
I suspect that if the role already has Files and Documents and Bills permissions, it's a List item that we're missing, but which?
The lazy option is for them to give the admin role to the script execution, but I'm reluctant to have script running under that role in prod
💯 1
t
On the script deployment. Is the Audience > Roles > (select all is checked)?
r
Almost certain it is (as that is what we advised) but again, I'm working blind
😎 1
t
I think they need to set the User Role to have a FULL or EDIT permission in production
if via UI they can't perform the attach then it is their role permission setup https://suiteanswers.custhelp.com/app/answers/detail/a_id/19964/loc/en_US
r
TY, very helpful. I've asked for some evidence from admin on the current settings and will ask them to add Vendors to List if not present and try again
goodluck 1
r
generally speaking, giving scripts admin is usually a safe bet. if it's a very large company with a lot of controls being enforced you could run into an issue but generally, if you're being paid to implement logic, you want it to work without forcing the company to align their roles to make the process work. my humble opinion
obviously you can't do this with client scripts, which is one reason why they are such a pain
r
So update, added the Vendor Full option to the Permissions tab > Lists subtab on the role the script is run under and attachments are now working. Thank you @Tyn Guardian for the tip
👍 1
thumbs up 1