Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

Recognition

  • Give kudos
  • My kudos

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Error updating status through Scriptrunner Edited

Hi,

 

I have written a script to  extract claim numbers and then if there is a single unique claim number, update the status on the issue. But when I try to execute the script, I get the below error. 

 

The claim number updates in the field when I remove the logic to update the status and the code for updating the status runs perfectly fine when I run it on the console. But the problem arises when I run this as part of an automation rule triggered when issue is created.  Can you please help with what I am doing wrong?

 

"Script function failed on Automation for Jira rule: Read and set Claim Number, Issue Type, file: <inline script>, No signature of method: com.atlassian.jira.issue.managers.RequestCachingIssueManager.call() is applicable for argument types: () values: [] Possible solutions: wait(), any(), wait(long), each(groovy.lang.Closure), any(groovy.lang.Closure), tap(groovy.lang.Closure)"

 

Script - 

 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.customfields.manager.OptionsManager
import com.atlassian.jira.issue.comments.CommentManager
import java.util.regex.Pattern
import java.util.regex.Matcher
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.IssueInputParametersImpl
import com.atlassian.jira.issue.MutableIssue;


def summary=issue.getSummary()
def description=issue.getDescription()
def claimNumbers =[]
def issueManager = ComponentAccessor.issueManager()
def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
MutableIssue issueToUpdate = (MutableIssue) issue;

//The transition ID is now hardcoded for To Be Processed. Change this to accomodate all statuses
def tobeProcessedTransitionId = 21
def workflowManager = ComponentAccessor.getWorkflowManager()
def workFlow = workflowManager.getWorkflow(issue)
def issueService = ComponentAccessor.issueService()

def customFieldManager = ComponentAccessor.getCustomFieldManager()

def claimNumberField = customFieldManager.getCustomFieldObjects(issueToUpdate).find {it.name == "Claim Number"}


//Match claim number pattern WCQ****** and return a list of claim numbers from Summary
def claimNumbersInSummary = summary.findAll(Pattern.compile(/\bWCQ[0-9]*/,Pattern.CASE_INSENSITIVE))
//Match claim number pattern WCQ****** and return a list of claim numbers from Description
def claimNumbersInDescription
def claimNumbersInDescriptionUpperCase

def claimNumbersSummaryUpperCase = claimNumbersInSummary.collect{it.toUpperCase()}
claimNumbers.addAll(claimNumbersSummaryUpperCase)

if(description!=null)
{
claimNumbersInDescription =description.findAll(Pattern.compile(/\bWCQ[0-9]*/,Pattern.CASE_INSENSITIVE))
claimNumbersInDescriptionUpperCase = claimNumbersInDescription.collect{it.toUpperCase()}
claimNumbers.addAll(claimNumbersInDescriptionUpperCase)
}
//This is to remove duplicate claim numbers regardless of case
claimNumbers.unique()





// Convert claim numbers list to comma separated string
String claimNumbersCommaSeparated=claimNumbers.asList().join(",").toString()

//Update Claim Number field in the issue
if (claimNumberField) {
def changeHolder = new DefaultIssueChangeHolder()
claimNumberField.updateValue(null, issueToUpdate, new ModifiedValue(issueToUpdate.getCustomFieldValue(claimNumberField), claimNumbersCommaSeparated),changeHolder)

}

log.warn(" Cliam Numbers Size: " + claimNumbers.size())
log.warn("Workflow transitions:"+workFlow.getLinkedStep(issue.getStatus()).getActions().name)
if(claimNumbers.size()==1)
{
def transitionValidationResult = issueService.validateTransition(currentUser,issueToUpdate.id,tobeProcessedTransitionId, new IssueInputParametersImpl())
def issueObjectID = issueToUpdate.getId()

log.warn("Transition Valid? :" +transitionValidationResult.isValid())

if (transitionValidationResult.isValid()) {
def transitionResult = issueService.transition(currentUser, transitionValidationResult)

}
}





 

 

 

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Marketplace Apps & Integrations

5 mobile apps for Jira Cloud to boost productivity

  It’s very important to have access to the workflow process from anywhere. Especially if you manage the work of others. There is no difference whether you’re out of office, or drive a ca...

268 views 2 5
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you