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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
HI @Jack Nolddor _Sweet Bananas_
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
def testLabel = getFieldById("customfield_11100")
def testLabel_value = testLabel.getValue()
System.out.println(" @@@@ 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("\\[]", "()")
System.out.println(" @@@@ Search Iteam : " + lList.get(i))
System.out.println(" @@@@ 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);
System.out.println("@@@ JQL Result : " + jqlSearch)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Do you mind to change this line:
String jqlSearch ="project=DEM and issuetype = Bugs and cf[11100] in ($test)";
with the following?
String jqlSearch ="project=DEM and issuetype = Bugs and cf[11100] in (${testLabel_value.join(', ')})";
Regards
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.
I've updated my previous reponse.
Could you check?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
checked but not getting field values itself
I tried below...but now I need to add a comma (,) in between two labels..
for (int i = 0; i < lList.size(); i++)
{
String test = lList.get(i).toString().replaceAll("\\p{P}","")
System.out.println(" @@@@ Search Iteam : " + lList.get(i))
System.out.println(" @@@@ Search test : " + test)
String jqlSearch ="project=DEM and issuetype = Bugs and cf[11100] in ($test)";
//String jqlSearch ="project=DEM and issuetype = Bugs and cf[11100] in (${test.join(', ')})";
SearchService searchService = (SearchService) ComponentAccessor.getComponent(SearchService.class);
SearchService.ParseResult parseResult = searchService.parseQuery(user, jqlSearch);
System.out.println("@@@ JQL Result : " + jqlSearch)
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.