how to set costum field value nulled using behaviour

taher shili July 11, 2017

Hello ,

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

 

1 answer

1 accepted

1 vote
Answer accepted
Daniel Yelamos [Adaptavist]
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.
July 11, 2017

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.

Cheers

DYelamos

 

taher shili July 11, 2017

thank you :)

 but i want to use it with behaviours add-on 

Daniel Yelamos [Adaptavist]
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.
July 11, 2017

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

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

 

taher shili July 11, 2017

i have this error 

Sans titre33.png

Daniel Yelamos [Adaptavist]
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.
July 11, 2017

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.

Daniel Yelamos [Adaptavist]
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.
July 11, 2017

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

getFieldById(SPEP.id).setFormValue("")
taher shili July 11, 2017

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) }
Daniel Yelamos [Adaptavist]
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.
July 11, 2017

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:

SPEP.setFormValue("")

Tell me if this works.

 

taher shili July 13, 2017

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 Sign up to answer