Forums

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

The issuekey cannot be returned by using jql query in the validator part

Şeymanur Karakaya
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!
October 18, 2018

I'm creating request type by using Rest Api in C#. I don't want to create a new issue if there exist an issue with the same summary. I'm checking this control in the validator part with jql query. If the Jql query result is not 0, then the issue is not created. Here I would like to get issuekey in the result returned by JQL query in validator. When I send it with Rest api, because the issue is not created, so it does return the bad request. As a result, the issuekey cannot be returned by using jql query in the validator part. 

 

 

 

def Category log = Category.getInstance("com.onresolve.jira.groovy.OneOrOther")

CommentManager commentMgr = ComponentAccessor.getCommentManager()

def adminUser = ComponentAccessor.getUserManager().getUserByKey("admin")

def jqlQueryParser = ComponentAccessor.getComponent(JqlQueryParser.class)

def searchProvider = ComponentAccessor.getComponent(SearchProvider.class)

def issueManager = ComponentAccessor.getIssueManager()

def commentInfo = ""

 

def query = jqlQueryParser.parseQuery("project = \"BT Hizmet Masası\" AND summary ~ '"+ issue.summary +"' and status = Close and \"Customer Request Type\" = \"Task Error (INC)\" ")

def results = searchProvider.search(query, adminUser, PagerFilter.getUnlimitedFilter())

int issueCount= (results.total)

log.info(issueCount)

def issueForComment

if(!(issueCount==0))

{

    commentInfo=issue.summary?.replaceAll(/Hata Almıştır./, '')

                def currentDate = new Timestamp(new Date().getTime())

                def sdf = new SimpleDateFormat("dd/MM/yyyy HH:mm")

                currentDate=sdf.format(currentDate)

                commentInfo=commentInfo + currentDate + " tarihinde tekrar hata almıştır."

    results.getIssues().each {documentIssue ->;

                issueForComment = issueManager.getIssueObject(documentIssue.id)

    commentMgr.create(issueForComment, adminUser, commentInfo, true)

    log.info(issueForComment)

    invalidInputException = new InvalidInputException(issueForComment)

    }

}

 

 

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events