I am trying to update a field based on the current user using Script Runner Jira cloud as a post function of a workflow transition.
The script contains
def usr = get('/rest/api/2/myself').asObject(Map)
assert usr.status == 200
This returns the current user, I can use this to update a field using
def resp = put("/rest/api/2/issue/${issue.key}")
.queryString("overrideScreenSecurity", true)
.queryString("overrideEditableFlag", true)
.header("Content-Type", "application/json")
.body(updateDoc)
.asObject(Map)
The problem is that if the script is run as "current user", /rest/api/2/myself returns the current user, but the put call to /rest/api/2/issue/$(issue.key) fails, due to security/admin
nERROR: TSVCM-540: Connect app users with \"admin\" permission and Forge apps acting on behalf of users with ADMINISTER permission can override screen security."
However, if I run the script as ScriptRunner add-on the /rest/api/2/myself returns Script runner add on and not the current user that is executing the transition resulting in post process and the put(/rest/api/2/issue/${issuekey} executes without errors
So, how do I get current user and update a field using the put function.
The situation I ran into for this was similar, however I used the ID of a user with Admin to then apply to a different user so that it ran as that "Super user" instead of the user on screen.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This error is because the user does not have the permission scope to do the transition. If you referred to the documentation here, I mean, the required permissions are: Browse projects and Edit issues project permission for the project that the issue is in
This means that the initiating users do not have enough permission. You may also refer to the documentation here for the Scopes, it has described all the permissions for each scope. You cannot use overrideScreenSecurity to overwrite administrator permission.
I hope it helps.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I'm not an expert with jira and scriptrunner cloud, however this may shed some ligh on your problem with screen security:
https://community.atlassian.com/t5/Jira-questions/Problem-with-overrideScreenSecurity/qaq-p/602226
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Kántor Tibor Thank you for your reply. The ticket you shared, suggests that only Jira admins can override screen security, but I would rather not provide all users/approvers Jira admin privileges. Hence I am looking for an alternate solution. Thanks for your response though.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.