Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

setting a Task when run as "ScriptRunner for Jira" Using the PUT REST API

Murat Seven
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 8, 2023

I am creating a task using ScriptRunner for Jira. I want the reporter information of this task to be the person triggering this process, but I should do this while keeping the 'ScriptRunner Add-On User' in the 'Run As' section. I do not want the 'Initiating User'. The script I use for this is as follows. I am looking forward to your assistance on this matter.

 

def issueKey = issue.key
def currentUser = get('/rest/api/2/myself').asObject(Map)
assert currentUser.status == 200
def newReporter = currentUser.body.accountId
logger.info("newReporter: "+ newReporter)

put("/rest/api/3/issue/${issueKey}")
.queryString("overrideScreenSecurity", Boolean.TRUE)
.queryString("overrideEditableFlag", true)
.header('Content-Type', 'application/json')
.body(
fields:
[
reporter: [
accountId: newReporter
],
]
)
.asString()

2 answers

0 votes
Kristian Walker _Adaptavist_
Community Champion
November 8, 2023

Hi Murat,

I can confirm that when you run the script as the ScriptRunner add-on user, then this will return this user, and the script will be triggered as this user.

The only way to make it be set to the person who ran the script is to run the script as the initiating user, as the app does not support running as the ScriptRunner add-on user and knowing which user triggered the script.

I hope this information helps.

Regards,

Kristian

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events