Set value of multiselect field based on value on a single select field

Amzad Khan June 3, 2024

Hello,

I am using the below script to set value of a multiselect field based on a value of single select field, but this is not working.

Country Relevance is a multiselect field.

Retrofit Type is a single select field.

 

const retrotype = getFieldById("customfield_10471");
const countryrel = getFieldById("customfield_10091");

logger.info('Value: ' + retrotype.getValue().value);

if (retrotype.getValue().value == 'PQ Testing') {
countryrel.setValue('US');
}

 

I need to set value of a multiselect field Country Relevance = US if Single Select field Retrofit Type = PQ testing

country rel set value.PNG 

1 answer

0 votes
Geethanjali Katagani
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 3, 2024

Hi @Amzad Khan ,

It is possible by using behaviors in the ScriptRunner plugin.

 https://marketplace.atlassian.com/apps/6820/scriptrunner-for-jira?hosting=cloud&tab=overview 

Script:

const retrotype = getFieldById("customfield_10471");
const countryrel = getFieldById("customfield_10091");

console.log(retrotype.getValue().name)

switch (retrotype.getValue().name) {
case "PQ testing":
countryrel.setValue("US")
break;
default:
break;
}

Regards,
Geethanjali

Amzad Khan June 3, 2024

Hello @Geethanjali Katagani Tried adding the above same code, but this did not work 


country rell set script.PNG

 

 

Screenshot #2

country relse set ss2.PNG

Geethanjali Katagani
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 3, 2024
can you try this
script: 
const changedField = getChangeField();

if (changedField.getId() === "customfield_10084") {
    const singleSelectValue = changedField.getValue().id;

    const multiSelectField = getFieldById("customfield_10085");

    if (singleSelectValue === "10115") { // ID for Option A
        multiSelectField.setValue(["10117", "10118"]); // IDs for User 1 and User 2
    } else if (singleSelectValue === "10116") { // ID for Option B
        multiSelectField.setValue(["10118", "10119"]); // IDs for User 2 and User 3
    }
}

Suggest an answer

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

Atlassian Community Events