Hi,
I created a behavior to set a readOnly field depending abour value of an other field.
It's work ! There is an initialiser
"import com.atlassian.jira.component.ComponentAccessor
def N_BDC = getFieldById("customfield_10309")
def Charge = getFieldById("customfield_10205")
def ChargePrev = getFieldById("customfield_10207")
def ChargeReel = getFieldById("customfield_10208")
if (N_BDC.getValue() != "") {
Charge.setReadOnly(true)
ChargePrev.setReadOnly(true)
ChargeReel.setReadOnly(true)
}
else {
Charge.setReadOnly(false)
ChargePrev.setReadOnly(false)
ChargeReel.setReadOnly(false)
}"
then the script in server-side for the field
"import com.atlassian.jira.component.ComponentAccessor
import com.opensymphony.workflow.InvalidInputException
def N_BDC = getFieldById("customfield_10309")
def Charge = getFieldById("customfield_10205")
def ChargePrev = getFieldById("customfield_10207")
def ChargeReel = getFieldById("customfield_10208")
if (N_BDC.getValue() != "") {
Charge.setReadOnly(true)
ChargePrev.setReadOnly(true)
ChargeReel.setReadOnly(true)
Charge.setHelpText("les Charges ne sont plus modifiables car un bon de commande est renseigné")
N_BDC.setHelpText("la Charge n'est plus modifiable car un bon de commande est renseigné")
}
else {
Charge.setReadOnly(false)
ChargePrev.setReadOnly(false)
ChargeReel.setReadOnly(false)
Charge.setHelpText("")
N_BDC.setHelpText("")
}"
But if I add groupe or role condition ( when or except), script doesn't work anymore.
Can someone help me ?
Should I change my script ?
Should I include rôle condition in script ? How ? (I'm not developper)
Thanks
Hi, you need to add a condition to the script
example group:
import com.atlassian.jira.component.ComponentAccessor
def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
if (ComponentAccessor.getGroupManager().getGroupsForUser(currentUser)?.find {it.name == "jira-admins"} ){
<your code>
}
Thanks for your answer,
sadly it's doesn't work. I have two conditions. And even for one doesn't work.
First condition, I want exception for group "jira-administrators"
Second condition, I want exception for role "project-admin" (which is inclued in jira-software-user).
I tried first condition with :
if (ComponentAccessor.getGroupManager().getGroupsForUser(currentUser)?.find {it.name != "jira-administrators"} ){
Other question, should I put an other "else" with this "if" ?
Sorry for this basic question, as I said, I'm not developper.
Thanks again
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.