Auto Updates on the custom Field scripts are not running

Suresh Kumar October 10, 2022

We are currently running on Jira Datacentre 8.20.12 and recently we have upgraded the script runner to 

Adaptavist ScriptRunner for Jira  old version 6.58.0 to new version 7.1.0

 

import com.onresolve.jira.groovy.user.FieldBehaviours  -getting error
import com.onresolve.jira.groovy.user.FormField
FormField bs = getFieldByName("Business Services")
FormField bgroup = getFieldByName("Business Services Groups")

def bgroups = []
List bservices = []

// Below condition added for CCA project as part of JIRA-12541
if (issueContext.projectObject.name != 'Customer Centric Assurance') {

// getValue will sometimes fail with a NumberFormatException when using it with the multi-select frother
try {
  bsValue = bs.getValue()  --- it says bsValue not declared
}catch(NumberFormatException n){  
   return // DON'T carry on
   }
if(bsValue instanceof String) {
 bservices.add(bsValue)  
 //log.debug(bsValue))
} else {
 bservices = bsValue as List
}

2 answers

0 votes
Suresh Kumar November 2, 2022

the issue is identified and we have closed the the bug.

0 votes
Dirk Ronsmans
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 10, 2022

@Suresh Kumar ,

Considering you are running this in a Behaviour I would omit the 2 imports.

And for bsValue you indeed did not declare it. Just put a def in front of it to catch all types and should be good to go

Suresh Kumar October 11, 2022

Thanks Dirk the minor issues are solved now we are facing major issue with the groovy scripts

we have the code for Auto Updates on Field Change when we try to create an issue, for example if select the application the corresponding Team should get populated but now its not getting populated inspite of getting all the functions and the script is running too successfully

Suresh Kumar October 11, 2022

this is the sample code 

 

 

import com.onresolve.jira.groovy.user.FieldBehaviours
import com.onresolve.jira.groovy.user.FormField
FormField bs = getFieldByName("Business Services")
FormField bgroup = getFieldByName("Business Services Groups")

def bgroups = []
List bservices = []
def bsValue = null

// getValue will sometimes fail with a NumberFormatException when using it with the multi-select frother
try {
bsValue = bs.getValue()
}catch(NumberFormatException n){
return // DON'T carry on
}
if(bsValue instanceof String) {
bservices.add(bsValue)
//log.debug(bsValue))
} else {
bservices = bsValue as List
}
// return and carry on


for (bservice in bservices){
// Business Services Group1
switch (bservice){
// Business team 1
case [
'Business case 1'
]:
bgroups.add(12683)
break
}

switch (bservice){
// Business Services Group2
case [
'Business cteam 1'
]:
bgroups.add(13533)
break
}
}

bgroup.setFormValue(bgroups)
def exit=0

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events