Hi Team,
We have scenario If the ticket priority is critical - automatically add a Priority1 to Label field. If the ticket is any other priority add a Priority2 value to Label field.
The below code is working, but while creating the ticket the priority default value is Minor, so the ticket is updating with Label ="Priority2" as per the requirement, and when i am changing the priority to "Critical on the same page, the Label field values are updating to both "Priority1" and "Priority2" if the priority value is Critical, the Label should be updated to Priority1.
Is there any possibility to clear the Label field when we changing the priority values. For example if the Ticket is minor, Label is "Priority2", and changing the priority to Critical, it should clear the Priority2 and update the Priority1 label value.
Please check the attached screenshots for your reference.
def priorityField = getFieldById(getFieldChanged())
def labelsField = getFieldById("labels")
String priorityVal = priorityField.getValue().getName()
if(priorityVal.equals("Critical")){
labelsField.setFormValue('Priority1')
} else {
labelsField.setFormValue('Priority2')
}
I am not sure but can you try this one?
if(priorityVal.equals("Critical")){
labelsField.setFieldOptions(["Priority1"])
labelsField.setFormValue(['Priority1'])
} else {
labelsField.setFieldOptions(["Priority2"])
labelsField.setFormValue(['Priority2'])
}
No @Tuncay Senturk _Snapbytes_ . Its not working, no value is displaying in the labels field.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Did you not forget the square brackets, did you? I already tried in my environment and it worked.
['Priority1'] rather than 'Priority1'
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Tuncay Senturk _Snapbytes_ , Thanks much for your quick replies. Yes. I tried with the following. Actually its clearing the field value. When i am giving Label is Priority1 manually , and selecting other priority its clearing the value in the label field.
def priorityField = getFieldById(getFieldChanged())
def labelsField = getFieldById("labels")
String priorityVal = priorityField.getValue().getName()
if(priorityVal.equals("Critical")){
labelsField.setFieldOptions(["Priority1"])
labelsField.setFormValue(['Priority1'])
} else {
labelsField.setFieldOptions(["Priority2"])
labelsField.setFormValue(['Priority2'])
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sorry, I am not an expert on this, but this was the first solution that came to my mind.
That's interesting, as it works in my environment.
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.