Non-Post Action Script changes Assignee value but UI does not reflect change until submission.

Jon Starbird
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.
May 16, 2013
public void setFieldsForNotFixed() {
		FormField issueField = getFieldById("id")
		FormField formResolution = getFieldById(fieldChanged)
		FormField commentField = getFieldById("Comment")
		FormField assigneeField = getFieldById("assignee")
		
		def issueId = issueField.getFormValue() as Long
		log.debug("Current issue: $issueId")
		
		Object resolutionId = formResolution.getFormValue() as String
		ConstantsManager constantsManager = componentManager.getConstantsManager()
		
		MutableIssue myIssue = componentManager.getIssueManager().getIssueObject(issueId)
		
		Project project = myIssue.getProjectObject()
		def projectLead = project.getLead()
		def currentAssignee = componentManager.jiraAuthenticationContext?.user
		def assigneeName = assigneeField.getFormValue()
		String resolutionName = constantsManager.getResolutionObject(resolutionId).getName()
		
		log.debug("Current Resolution: $resolutionName")
		log.debug("Current User: $currentAssignee.name")
		log.debug("Project Lead: $projectLead.name")
		log.debug("Current Assignee: $assigneeName")
		
		User usera = componentManager.getInstance().getUserUtil().getUser(projectLead.name)
		
		if (resolutionName == "Won't Fix" || resolutionName == "Cannot Reproduce" || resolutionName == "As Designed") {
			log.debug("Current Resolution: $resolutionName")
			commentField.setRequired(true)
			assigneeField.setFormValue(usera)
			assigneeField.setReadOnly(true)
		} else if (resolutionName == "Incomplete") {
			commentField.setRequired(true)
			assigneeField.setFormValue(currentAssignee)
			assigneeField.setReadOnly(true)
		} else {
			commentField.setRequired(false)
			assigneeField.setReadOnly(false)
		}
		Object newAssignee = assigneeField.getFormValue()
		log.debug("New Assignee: $newAssignee")
	}

Sorry for this text being at the end but the Answers UI is not letting me put the code after my text if I use the Code macro.

I have code to handle setting the assignee to a particular value for certain Non-Fixed Resolutions and then making the assignee field Read Only.Using debug print outs I can see that the value does indeed get changed and if I Resolve the issue it gets set correctly.

However, the UI doesn't show the change until after submission and the field doesn't get set to Read Only.I'm using the Behaviors Plugin and it is attached to the Resolution field and as I said the code is working as far as setting the values. How do I get the UI to update? I've used other scripts to change things on the screen based on other fields and they work fine but this one is setting the Assignee.

Thanks,
Jon


4 answers

0 votes
Jon Starbird
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.
May 21, 2013

Anyone have any clues on this one? Just need to get the UI to reflect the update to the Assignee field correctly.

Thanks,
Jon

0 votes
Jon Starbird
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.
May 17, 2013

Just FYI, I went ahead and upgraded us to 5.2.11 with Behaviors 0.5.3. Still same issue.

0 votes
Jon Starbird
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.
May 17, 2013

Sorry I should have included that, always forget. It's Jira 5.2.9 with Behaviors 0.5.3.

0 votes
JamieA
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.
May 17, 2013

What version of jira? It's possible that it's not working in the most recent. It's very hard to keep track of the UI changes... there is no concept of a public API for the DOM.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events