Project ID: This is a numerical project ID that the user enters.
Task ID:
This calls an external REST service that returns a list of Tasks belong to the above project ID.
I have defined a REST endpoint where it takes in the projectID from the query parameter and it is working fine.
https://<jira-home>/rest/scriptrunner/latest/custom/getMLTasks?query=<projectID>
However, in the initialiser for TASK ID, when I am trying to retrieve the value that the user selected from the Project ID field, it keeps returning null. Please note that this project ID has not yet been created. I need this to work during a create/update issue dialogue.
Task ID (initializer code):
import groovyx.net.http.ContentType
import groovyx.net.http.HTTPBuilder
import groovyx.net.http.Method
import org.apache.log4j.Level
import org.apache.log4j.Logger
import com.onresolve.jira.groovy.user.FormField
import groovy.transform.BaseScript
import com.onresolve.jira.groovy.user.FieldBehaviours
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.IssueManager
@BaseScript FieldBehaviours fieldBehaviours
def projectID = getFieldById("customfield_12426").getFormValue()
getFieldByName("MavenLink Tasks").convertToSingleSelect([
ajaxOptions: [
url : getBaseUrl() + "/rest/scriptrunner/latest/custom/getMLTasks?query=${projectID}",
query: true, // keep going back to the sever for each keystroke
minQueryLength: 3,
keyInputPeriod: 500,
formatResponse: "general",
]
])
I have also tried putting the above code as a server-side script for the Task ID but it seems that convertToSingleSelect does not work anywhere else except for the initialiser section.