I want to use the Team field to create boards of all issues assigned to their members. It could be that the Team field would auto-populate when you assign someone to that issue, but my testing indicates that this not how Atlassian built it.
If I have to build it as an automation (and have it count towards my action triggers), is there an easier way than When assigned, If User in (User1, User2, User3) edit issue field Team to TeamA, Else If User in (User4, User5, User6, User 7) edit issue field Team to TeamB, Else If...
Looking at this further, the script is updating the value correctly. However, due to the delay between the UI updating and the script completing, the change is not shown. After ~3 seconds we MAY receive a notification that the issue was updated with a link to refresh. We don't always get the notification though.
It looks like this issue is documented here: https://community.atlassian.com/t5/Jira-questions/JIRA-Cloud-ScriptRunner-Modifying-Issue-UI-is-not-updating/qaq-p/265834.
Hi,
First, you can clean your code and remove this block:
// make sure we have the data and we're in the correct project
if (issue == null || issue.fields.project.key != projectKey)
{
logger.info("Wrong Project ${issue.fields.project.key}")
return
}
1. Because "issue" will never be null if "issue update" event is triggered.
2. In the listener configuration you can set on which projects you want it to run, that way you make sure your script runs only on the project you actually want (also reduce the call for listener for irrelevant projects).
Now... try your code this way:
def projectKey = 'TEM'
def issueKey = issue.key
def NumField = 'customfield_10726'
def UrlField = 'customfield_10705'
def result = get("/rest/api/2/issue/${issueKey}?fields=${NumField}")
.header('Content-Type', 'application/json')
.asObject(Map)
def NumVal
if (result.status == 200) {
NumVal = result.body.fields[NumField] as Integer
def post_result = put("/rest/api/2/issue/${issue.key}")
.header("Content-Type", "application/json")
.body([
fields:[
customfield_10705: 'https://support/CSIssue_View.asp?IssueNbr=' + NumVal
]
])
.asString()
if (post_result.status == 204) {
return 'Success'
} else {
return "${post_result.status}: ${post_result.body}"
}
} else {
return "Error retrieving issue ${NumVal}"
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Nir,
Thanks for the above. I had already set the project for the listener, but kept the check in the code just in case. I'll remove it.
Unfortunately it's still updating the URL based on the old NumField value. It seems like it's running the listener before it completes the update. Do I need to put in some kind of a wait? Or use a different event?
Thank you,
~Seth
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Nir,
Looking at this further, the script is updating the value correctly. However, due to the delay between the UI updating and the script completing, the change is not shown. After ~3 seconds we MAY receive a notification that the issue was updated with a link to refresh. We don't always get the notification though.
It looks like this issue is documented here: https://community.atlassian.com/t5/Jira-questions/JIRA-Cloud-ScriptRunner-Modifying-Issue-UI-is-not-updating/qaq-p/265834.
Thanks again for your help.
~Seth
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.