Hi Team,
I did not find the solution in our community and tried with behaviors also. We have field "Escalation?". If we change the "Escalation?" to Yes, the priority should change to Critical (after ticket creation). I tried below code behaviors, but still not updating when we changed Escalation is yes. Could you please help me on this.
-------------------------------------------------------------
def escalationfield = getFieldByName("Escalation?")
def prio = getFieldByName("Priority")
if (escalationfield.getValue() == "Yes")
{
prio.setFormValue("Critical")
}
------------------------------------------------------------
Hi @Lakshmi CH,
Below is the script for behaviour, I tested in project too
Note: you should use "Escalation" field as source field & mapped to it
if (getFieldById(getFieldChanged()).getValue() == "Yes") {
getFieldById("priority").setFormValue("Critical")
}
And below script used for the same but in Script Listener
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.IssueInputParametersImpl
import com.atlassian.jira.issue.Issue
def issue = event.issue as Issue
def constantsManager = ComponentAccessor.getConstantsManager()
def user = ComponentAccessor.getJiraAuthenticationContext().getUser()
def issueService = ComponentAccessor.getIssueService()
def issueInputParameters = new IssueInputParametersImpl()
def cfField = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Custom Field Name")
def value = issue.getCustomFieldValue(cfField)
if(value == "Value 1"){
issueInputParameters.setPriorityId(constantsManager.getPriorityObjects().findByName("P1").id)
}else if(value == "Value 2"){
issueInputParameters.setPriorityId(constantsManager.getPriorityObjects().findByName("P2").id)
}else{
issueInputParameters.setPriorityId(constantsManager.getPriorityObjects().findByName("P3").id)
}
def validationResult = issueService.validateUpdate(user, issue.id, issueInputParameters)
if (validationResult.isValid()) {
issueService.update(user, validationResult)
} else {
log.warn validationResult.errorCollection.errors
}
Hope it gives you some idea
BR,
Leo
Perfect. This is working as expected. Thank you @Leo
if (getFieldById(getFieldChanged()).getValue() == "Yes") {
getFieldById("priority").setFormValue("Critical")
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Leo Leo,
We have same scenario but diff custom field
If user select the value "minor" from impact custom field and "likely" from the probability custom field automatically priority must set to "medium"
Will this possible to achieve in behavior
Waiting for the your reply
Thanks!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @balaji,
I would say YES. that is possible
As I mentioned above you'll have to map/write this behaviour with your custom field(Impact) and then the same script in server side script
if (getFieldById(getFieldChanged()).getValue() == "Minor") {
getFieldById("priority").setFormValue("Medium")
}
BR,
Leo
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.
you can map behaviour with single field which will be executed when the associated field changed/updated
Of course you can validate 2 field values in priority, but the drawback is below
1. If you map with 1st field, the script will be executed only when 1st field changed. if you change your 2nd field after 1st one. the validation will fail and priority will not be applied
The same goes for if you map with 2nd one.
If you really want to go with behaviour, you'll have write 2, and map each one with each field but with same script(I won't suggest that personally)
In this situation you can consider custom listener. where you can map with your project with issue created & updated event. here you can validate both fields values and update priority
you can refer my listener script above
BR,
Leo
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Leo , I know this is a bit old but I came across this and it might help me. But I was wondering would this work if the custom field is a single choice list?
Would you need to add the name of the field and the choice or would it just be the choice alone?
if (getFieldById(getFieldChanged()).getValue() == "Cyber Incident Categorisation - Account Compromise") {
getFieldById("priority").setFormValue("P4")
}
I tried both ways but it did not seem to update accordingly.
Any help would be appreciated.
Thanks!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
When trying to set priority value on create screen a warning pops up:
These fields have default values for this project and issue type combination. We have preserved the existing values in case you need them.
Priority: 1
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.