Forums

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

How to clean single select field(convert from text field) value?

lizong wei
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
March 15, 2021

I used the Behaviours function to simulate the secondary interactive drop-down menu

import com.atlassian.jira.component.ComponentAccessor;
def dutyCode = getFieldById(getFieldChanged())
def rootCauseCode = getFieldByName("Root Cause Code")
def dutyCodeValue = dutyCode.value as String
def queryValue = dutyCodeValue.split(' ')[0] as String

//convert text field to single select field
rootCauseCode.convertToSingleSelect([
ajaxOptions: [
url : getBaseUrl() + "/rest/scriptrunner/latest/custom/getRootCauseCodeByDutyCode?query=" + queryValue,
query: false,
formatResponse: "general"
]
])

//clean rootCauseCode value when options updated
rootCauseCode.setFormValue('') //this line don't work

How should I do?  thanks!

 

1 answer

0 votes
John Chin
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.
March 17, 2021

Hi @lizong wei 

What about move the clear value line before converting the text field? 

//clean rootCauseCode value when options updated
rootCauseCode.setFormValue("")

//convert text field to single select field
rootCauseCode.convertToSingleSelect([
ajaxOptions: [
url : getBaseUrl() + "/rest/scriptrunner/latest/custom/getRootCauseCodeByDutyCode?query=" + queryValue,
query: false,
formatResponse: "general"
]
]) 

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, atlassian community, loom ai, atlassian loom ai, loom, atlassian ai, record recaps of meetings, meeting recaps, loom recaps, share meeting recaps,

Loom’s guide to great meetings 📹

Join us to learn how your team can stay fully engaged in meetings without worrying about writing everything down. Dive into Loom's newest feature, Loom AI for meetings, which automatically takes notes and tracks action items.

Register today!
AUG Leaders

Atlassian Community Events