how to set costum field value nulled using behaviour

Hello ,

I need to set custom field value to NULL when i edit other custom field using add-on behaviour , 


1 answer

1 accepted

Hi Taher.

Your description of your issue is rather shallow, so I'm going to try my best with the little information that you provided.

If you have 2 fields, A, and B, and you want to reset A when B is changed. You need to set a behaviour on field B, and when it gets changed, you need to change the value of A to "empty" rather than null. Null could cause issues.

If A is a textField you could do this:

def A = customFieldManager.getCustomFieldObjectByName("A")   
issue.setCustomFieldValue(A, "")

I hope this helps.




thank you :)

 but i want to use it with behaviours add-on 

yes, that should work in the behaviours part of SR. 

Oh wait, aren't you using SR at all?


i have this error 

Sans titre33.png

Can you send the whole of your script? I might be able to help you better with more information taher. I want to help you mate but you keep sending very little info, and that doesn't really help.

If you are in behaviours you need to use something like this:


when component is changed i want to set the other custom field nulled

import com.onresolve.jira.groovy.user.FieldBehaviours import groovy.transform.BaseScript import static com.atlassian.jira.issue.IssueFieldConstants.* @BaseScript FieldBehaviours fieldBehaviours def ff = getFieldById(COMPONENTS) def values = ff.getValue() def URL = getFieldById("customfield_15008") def URLD =getFieldById("customfield_15009") def Request =getFieldById("customfield_15011") def URLField = getFieldById("customfield_15012") def TOBE = getFieldById("customfield_15013") def source = getFieldById("customfield_15014") def dest = getFieldById("customfield_15015") def port = getFieldById("customfield_15016") def InApp = getFieldById("customfield_15021") def ReqR = getFieldById("customfield_15022") def specy = getFieldById("customfield_15023") def res = getFieldById("customfield_15024") def SON = getFieldById("customfield_15027") def SOT = getFieldById("customfield_15028") def SOL = getFieldById("customfield_15029") def SPEP = getFieldById("customfield_15030") def IPSE = getFieldById("customfield_15031") def SERV = getFieldById("customfield_15032") def RIGHTS = getFieldById("customfield_15033") /*---------------------------------------- Declation variable -----------------------------------*/ SPEP.setHidden(true) IPSE.setHidden(true) SERV.setHidden(true) RIGHTS.setHidden(true) SOL.setHidden(true) SOT.setHidden(true) SON.setHidden(true) res.setHidden(true) specy.setHidden(true) ReqR.setHidden(true) source.setHidden(true) InApp.setHidden(true) dest.setHidden(true) port.setHidden(true) URLD.setHidden(true) URL.setHidden(true) Request.setHidden(true) URLField.setHidden(true) TOBE.setHidden(true) /*---------------------------------------- hide all -----------------------------------*/ if(values.toString().contains("NEW URL")){ URL.setHidden(false) URLD.setHidden(false) }else if (values.toString().contains("Publishing URL / OPENING PORT")){ Request.setHidden(false) }else if (values.toString().contains("INTERNAL APPLICATION ACCESS")){ InApp.setHidden(false) }else if (values.toString().contains("NETWORK SHARED")){ res.setHidden(false) }else if (values.toString().contains("NEW SOFTWARE")){ SON.setHidden(false) SOL.setHidden(false) SOT.setHidden(false) }else if (values.toString().contains("PHYSICAL ACCESS")){ }else if (values.toString().contains("SERVER ACCESS")){ SPEP.setHidden(false) IPSE.setHidden(false) SERV.setHidden(false) RIGHTS.setHidden(false) }

well you would do it as I told you.

You get the id of the field you want to set to empty, in your case that's SPEP I believe and you do this:


Tell me if this works.


hello daniel

thank you it work :D 

but i need another thnik i juste need how to chek if component is changed on edit screen and based to this  boolean value i will set the next status 

can you help me 

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

3,308 views 14 20
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot