Forums

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

ScriptRunner, Issues with required custom field based on another field value

Brooke Anglin June 14, 2018

Below is the script I have. Both fields are on the create screen but when I add the behavior and run a test nothing happens.

 

import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript

@BaseScript FieldBehaviours fieldBehaviours

def SegmentField = getFieldById("customfield_12015")
def MerchantOwnerAreaField = getFieldById("customefield_13601")

String SegmentIssueValue = SegmentField.getValue()

if (SegmentIssueValue == "Merchant") {
    MerchantOwnerAreaField.setRequired(true)
} else {
    MerchantOwnerAreaField.setRequired(false)
}

 

when I run it in the script console it gives me the following error Cannot get property 'customfield_12015' on null object

 

I am new to all of this... can anyone tell me more about the import piece at the top? I feel that is why I am getting the error.

 Any help would be greatly appreciated!!!

1 answer

1 accepted

0 votes
Answer accepted
Mark Markov
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 14, 2018

Hello @Brooke Anglin

Where did you place your script? This script in your behaviour must be attached to your customfield_12015. See screen bellow image.png

Brooke Anglin June 19, 2018

this worked !! thank you

Mark Markov
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 19, 2018

You re welcome! If this helps you please mark answer as accepted :)

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events