Hi,
For first look qustion is very simple, but i don't know what is going on. I have two if else in my code. Create task and update custom field from transition post function in Create. Here is a code:
def type = issue.getIssueTypeId()
// ---------- CREATE TASK -------------
if (type == "11") // tylko dla IssueType = System
{
def sum = issue.getSummary()
issueInputParameters.with {
projectId = projectManager.getProjectObjByKey("SYS").id
summary = "$sum"
issueTypeId = "12"
reporterId = user.name
}
def validationResult = issueService.validateCreate(user, issueInputParameters)
def issueResult = issueService.create(user, validationResult)
def newIssue = issueResult.getIssue()
log.debug "$newIssue"
}
else
{
log.debug "Task nie został stworzony - IssueType inny niż System"
}
// ----------UPDATE RELACYJNY CUSTOM FIELD-----------
if (type == "11")
{
def fieldToChange = "customfield_11067"
def newValueIssueKey = "SYS-15810"
def cf = customFieldManager.getCustomFieldObject(fieldToChange)
List newValue = new ArrayList()
newValue.add(newValueIssueKey)
issue.setCustomFieldValue(cf, newValue)
log.debug "test2"
}
else
{
log.debug "Custom Field Not Updated - IssueType inny niż System"
}
Where is a problem? Task is created, but in logs i have:
"Task nie został stworzony - IssueType inny niż System"
Custom field is updated, but in logs i have:
"Custom Field Not Updated - IssueType inny niż System"
I don't have test2 or $newIssue value. I think that could be very stupid mistake, but where... If works fine because Issue is created just for type == 11.
I believe your compiler hadn't gone through the if loop. The task got created and updated by some other mean. Use type.equals("11") method instead. Refer this.
https://www.geeksforgeeks.org/difference-equals-method-java/
Thanks for response! if I tried with equals("11") issue isn't created - just loading and nothing happens. I tried something else. I give to log.debug value "$type" and i have returned... 12 (when I creating 11).
Next I tried to Create another issue (another than 12 and 11) and in log i have good number - 14. So... Qustion is:
Possible is that when I creating issue with ID 11 IssueTypeID is somehow changing to new value and this deleting my loop?
EDIT: I Made this with equals, like this:
def type = issue.getIssueTypeId()
def typecorrect = "11"
if (type.equals(typecorrect))
{
....
but i have this same problem... Script Runner returning value from else and it is "12" not from If. Still creating issue and update issue.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Refer this and debug the first piece of code for creating ticket, code line by line.
CreateValidationResult createValidationResult = issueService.validateCreate(appUser, issueInputParameters);
if (createValidationResult.isValid())
{
IssueResult createResult = issueService.create(appUser, createValidationResult);
if (createResult.isValid())
{
Issue newIssue = createResult.getIssue();
def changeHolder = new DefaultIssueChangeHolder();
jiraTicket.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(jiraTicket), newIssue.getKey().toString()),changeHolder);
}
else{
log.error("could not create issue: " + createResult.getErrorCollection());
}
}
else{
log.error(createValidationResult.getErrorCollection())
}
I have added loggers on multiple loops for CreateValidationResult & IssueResult
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.