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

Setting value for a single choice select list field using a script listener.

Pierre CARRAZ February 23, 2024

Hello,

 

In our project, we are using a cascading select list field named Logiciel to store the application name and the application software version linked to our tickets.

The parent in the cascading select list field being the application name and the child the software version.

As we’d like to use built in gadget named “Issue Statistics” on our dashboard to see the split of the tickets between our applications (without taking care of the version), we must store the application name in a single choice select list field (I have named that field LogicielSimplifie).

To fill this single choice select List field, I have created a listener script using ScriptRunner extension. This listener is executed each time an issue is updated.

The script is called correctly and can correctly retrieve the software name from the cascading select list field.

However, I’m facing an issue within this script as I can’t figure out the syntax to update the single choice List field.

My script is the following:

 

// Copy Software name from Logiciel field to LogicielSimplifie field

 

// get custom fields

def customFields = get('/rest/api/2/field')

    .asObject(List)

    .body

    .findAll { (it as Map).custom } as List<Map>

 

def input1CfId = customFields.find { it.name == 'Logiciel' }?.id

def outputCfId = customFields.find { it.name == 'LogicielSimplifie' }?.id

 

def fields = issue.fields as Map

def project = fields.project as Map

 

//if (issue == null || project.key != projectKey) {

//    logger.info("Wrong Project ${project.key}")

//    return

//}

 

def input1 = fields[input1CfId]?.value as String

 

def output = input1

 

put("/rest/api/2/issue/${issue.key}")

.queryString("overrideScreenSecurity", Boolean.TRUE)

    .header('Content-Type', 'application/json')

    .body([

        fields: [

            (outputCfId): output

        ]

    ])

    .asString()

 

Can someone help me for the syntax to use in the “put” command to indicate that the field to update is my single choice select list field named LogicielSimplifie ? I have tried many syntaxes such as (outputCfId?.value): output or (outputCfId) ?. value: output without any success.

 

I tried also using JSM automation for that purpose, but I can’t access the parent part of the Cascading Select list field within automation.

Thanks for your help

0 answers

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Site Admin
TAGS
AUG Leaders

Atlassian Community Events