Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Jira Behaviour Code is not Updating the Field Value?

Felix Trauner
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
September 11, 2025

Hi all,

I'm working on a Jira Behaviour using Scriptrunner, and I’m trying to set the value of a custom field based on an API response. The code runs without errors, and the condition is met (the custom field value is "Nein"), but the field doesn't get updated as expected. Below is the code I'm using:

async function main() {

    // Get the Parent Key from the field (e.g., Parent Issue)

    const parentField = getFieldById("parent").getValue();

    const parentKey = parentField.key;

    console.log('Parent Key:', parentKey);

    try {

        // Perform the API request

        const res = await makeRequest(`/rest/api/3/issue/${parentKey}`);

        // Check the response content

        const data = await res.body;

        console.log('Fetched Data:', data);

        // Check if the custom field has the value 'No'

        const parentAutomSupportValue = data.fields.customfield_10087.value;

        // Automatic support (e.g., set a value)

        if (parentAutomSupportValue === 'Nein') {

            getFieldById("customfield_10087").setValue('10085');

            getFieldById('customfield_10106').setRequired(true);

        }

    } catch (error) {

        console.error('Error during fetch:', error);

    }

}

// Call the main function

main();

I've confirmed the API call is working and the value of customfield_10087 is correctly being retrieved, but the field doesn't seem to update when I expect it to.

Can anyone explain why this might be happening or suggest a solution?

1 answer

Suggest an answer

Log in or Sign up to answer
0 votes
Ram Kumar Aravindakshan _Adaptavist_
Community Champion
September 11, 2025

Hi @Felix Trauner

Could you please clarify what type of custom field you are using with the Behaviour?

I am requesting this so I can try to retest it in my environment.

Thank you and Kind regards,
Ram

Felix Trauner
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
September 12, 2025

Hi @Ram Kumar Aravindakshan _Adaptavist_ ,

thank you for your message.

Both fields in question are radio buttons. I hope this helps clarify things.

Kind regards

Felix

DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
TAGS
AUG Leaders

Atlassian Community Events