Hi All,
I have two custom fields called "cf1 and cf2" . The ask is make cf2 read only and it should update depending on cf1 single select options. Please help me to address this situation. I'm a new bee to the scripting part.
Hi @kk4065896
With Behaviours in Scriptrunner!!
Example here
Another example is here
Define the Behaviour for fruits field and get the field ID of the field you need to make it as read-only, change the relevant options below
def fruits = getFieldById(getFieldChanged()).getValue().toString()
if (fruits == "Apple") {
getFieldById("customfield_10402").setFormValue("20 Rs");
}
else if (fruits == "Mango") {
getFieldById("customfield_10402").setFormValue("10 Rs");
}
else {
getFieldById("customfield_10402").setFormValue("5 Rs");
}
Let me know if you have any queries
Thanks,
Pramodh
Thank you for sharing your answer and I tried to use the code but it is not working for me.
Here is the script what I used:
import com.atlassian.jira.issue.IssueFieldConstants
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript
@BaseScript FieldBehaviours fieldBehaviours
def ManagerRole = getFieldById("customfield_10214")
def DeploymentState = getFieldById("customfield_11111")
if (ManagerRole == "None") {
getFieldById("customfield_11111").setFormValue("None");
}
else if (ManagerRole == "HR") {
getFieldById("customfield_11111").setFormValue("HR");
}
else if (ManagerRole == "A&Z") {
getFieldById("customfield_11111").setFormValue("A&Z");
}
else if (ManagerRole == "GA") {
getFieldById("customfield_11111").setFormValue("GA");
}
else if (ManagerRole == "T") {
getFieldById("customfield_11111").setFormValue("T");
}
else if (ManagerRole == "Dev") {
getFieldById("customfield_11111").setFormValue("Dev");
}
else if (ManagerRole == "Go") {
getFieldById("customfield_11111").setFormValue("Go");
}
else if (ManagerRole == "DI") {
getFieldById("customfield_11111").setFormValue("Unknown");
}
else if (ManagerRole == "New") {
getFieldById("customfield_11111").setFormValue("New");
}
else if (ManagerRole == "Unknown") {
getFieldById("customfield_11111").setFormValue("Unknown");
}
else if (ManagerRole == "CEO") {
getFieldById("customfield_11111").setFormValue("CEO");
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.