My team wants to add a custom field that is read only until specific Components are selected. I have created a Behaviour on the field already. Currently the field is read only. I would like to create a custom script that can change the custom field to "writable" once the"Sys Admin" or "SysAdmin" component's are chosen. I've been banging my head on this for the last two days and I just feel lost now. Getting the list for the components seems to be the hardest part. Please help me out. (We have the server addition)
Hi @Terrell
I'm not a efficient coder, though below snippet will do the trick for you
import com.atlassian.jira.bc.project.component.ProjectComponent
def componentFF = getFieldById(fieldChanged)
def field = getFieldByName("Field name to be read-only")
field.setReadOnly(true)
List <ProjectComponent> components = componentFF.getValue() as List
def isThere = false
for(c in components){
if(c.getName() == "Sys Admin" || c.getName() == "SysAdmin"){
isThere = true
break
}
}
if(isThere){
field.setReadOnly(false)
}
Note: this behaviour should be added for Component/s field not for Custom field
BR,
Leo
Hey Leo, thanks for taking the time to reach out... I've implemented the code example you suggested and I'm not getting any errors but I am also not getting any results. I have the code executing as a server-side script. I am expecting the issue to attempt submission, but fail because I have set the "sysAdminCF" field as required. Is the logic incorrect?
Also, I'm not sure if I am using the correct component id as there are multiple id's within the man Div.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ahh yes! I wasn't sure if "fieldChanged" was just used as a placeholder for the id of the component field or what. That explains why I wasn't getting any results. Thanks for your help, it works like a charm!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.