Is it possible to call a suitelet from another sui...
# suitescript
c
Is it possible to call a suitelet from another suitelet? I have a suitlet where I need to perform a single action as admin role, but don’t want the rest of the suitelet to run as the current user role. What would be the best way to accomplish that?
Actually, I figured it out using the https module 🙂
👍 1
b
you wouldnt want to do so, it usually involves making the suitelet externally available, which is especially unfavorable with a suitelet running as administrator
d
Yes, you can deploy your suitelet twice, one with current role and one with admin. You can post back to the admin deployment for your one function.
c
@battk Actually I got it to work without making it externally available
d
Yah, never do that if you don't have to.
m
@Cory Weiner how did you do that?
c
@michoel I used the https module to post request to a second suitelet. That suitelet was setup to run as admin and the onRequest function does only the narrowly scoped action it needs to.
d
Thanks for the answer Cory. You wouldn't need a second suitelet though. You could deploy the same suitelet twice, once with admin and use https to post to the admin deployment.
c
Sure but I didn’t want any of the other functionality of the suitelet to be executed as admin, so a second deployment of the same script didn’t really make sense in this context
d
It keeps thing simple if you use one suitelet, one set of code. All you need to do is pass parameters to it.
c
Yeah that makes sense, but technically couldn’t that second suitlet be accessed directly?
So say my suitelet renders a form and on post of the form creates or updates records
if they access an admin version of the exact same suitelet, it would allow them more permissions than their current role may have
d
Depends on the design. I would set the event to POST only. You can also make checks in the script to see which deployment is being executed
m
@Cory Weiner this sounds strange to me, as far as I understand it shouldn't be possible to call a suitelet server side unless it's available without login.