I have a label type custom field using which i'm writing the behavior script.
Whenever i am selecting the first-time label then the JQL is working, but How to construct JQL with multiple labels using a script.
HI @Jack Nolddor [Sweet Bananas]
Finally the below line works fine.
String test = lList.get(i).toString().replaceAll("\\[","").replaceAll("\\]","")
thanks for your help and quick response.
Hi Yogest,Could you further explain your requirements?
You can use the IN operator to search for multiples labels at the same time, e.g.:
labels IN ("customer", "delay", "deploy")
Regards
Thanks for the response.
Actually the requirement is ...we have a label type custom field on crate screen so whenever a user will select the existing label then it should give an error that means we don't want user should select the existing label to avoid duplication because the same label is already used by one of the Jira issues.
So I have written then server-side behavior using which I'm checking whether the provided label is used or not...if not then the user should go ahead and crate issue.
The current script is working fine with single value but if the user selects multiple label then how I can add those label in JQL to check whether all the provided label is used or not.
The current script returns the JQL result in the below format ..because of the square bracket the JQL is failing.
So i wanted to replace square bracket with an empty string in JQL
def testLabel = getFieldById("customfield_11100")def testLabel_value = testLabel.getValue()@ Values " + testLabel_value)ArrayList lList = new ArrayList<>(Arrays.asList(testLabel_value))//ArrayList<String> lList = new ArrayList<>(Arrays.asList(testLabel_value));for (int i = 0; i < lList.size(); i++){String test = lList.get(i).toString()//.replaceAll("\\[]", "()")@ Search Iteam : " + lList.get(i))@ Search test : " + test)String jqlSearch ="project=DEM and issuetype = Bugs and cf[11100] in ($test)";SearchService searchService = (SearchService) ComponentAccessor.getComponent(SearchService.class);SearchService.ParseResult parseResult = searchService.parseQuery(user, jqlSearch);@ JQL Result : " + jqlSearch)
It looks like you're new here. Sign in or register to get started.