Hello!
I need to update a default value for Description field when the option is selected in another field (Select List (cascading)), when creating issue.
I created the behaviour and added the field that should be checked when changed, to this behaviour.
But when I'm trying to create an issue and select the needed option in the Select List field, description field is not updated with the default value.
Here is my script:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.customfields.manager.OptionsManager
import com.atlassian.jira.issue.ModifiedValue
def targetField = getFieldByName("Description")
def defaultValue = """[TASKS|]""".replaceAll(/ /, '')
def cField = getFieldByName("Deployment flow")
def selectedOption = cField.getValue().toString()
if (selectedOption == "PHP"){
targetField.setFormValue(defaultValue)
}Please help to understand what I'm doing wrong and how to update description when the option is set in my custom field.
Hi
Try this:
Add this import:
import groovy.json.JsonBuilderAnd this line before the comment that reads "API POST"
def finalJSON = new JsonBuilder(jsonBody).toString()).build()That should output the JSON in the proper format.
Do say if I can help you further.
Cheers!
DYelamos
Thank you for the assist. Managed to get it working. Appreciate the help.
I ended up getting the concatenation working as base and it posts successfully. But will look at your code as well for a more robust method I think.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks:
Could you mark this answer as accepted so that other users know that this thread has been answered?
Do say if I can help you further.
Cheers
DYelamos
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I am trying to update a request using the your code
def body = [:]
body.put("IssueNumber","XCAP-688")
body.put("Priority","P4 (No Impact/Notify)")
def baseUrl = new URL("http://xxx/xxx/UpdatePriority");
HttpURLConnection connection = baseUrl.openConnection() as HttpURLConnection;
connection.requestMethod = "POST"
connection.doOutput = true
connection.setRequestProperty("Content-Type", "application/json;charset=UTF-8")
connection.outputStream
connection.outputStream.withWriter("UTF-8") { new StreamingJsonBuilder(it, body) }
connection.connect();
log.info ("URL=" +baseUrl +" Status= "+connection.getResponseCode() as String)
But it is throwing 500 error(whereas there is no issue with the api.Not sure why is it giving 500 error). If i am trying to pass json data as below I am getting 400 error
def body = """{"Priority": "P4 (No Impact/Notify)", "IssueNumber": "XCAP-688"}"""
Can you help me in passing json data
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.