Hi,
I am trying to add the Value "Testing1" in Organization Field automatically when the status get changed.
For eg if the Status changed to "Waiting Internal" then Organisation field should automatically updated "Testing1"
Below is my script but its not working
*******************
def Organizations = getFieldByName("getFieldByName")
def status = getFieldById("getFieldById")
def customer = getFieldById("customfield_12345")
if (status.getValue() == "Waiting Internal")
if (customer.getValue() == "ABCD"){
Organizations.setFormValue("Testing1")
}
If field update needs to happen only after particular transition, you can try out ScriptRunner Post-function
Post-Function --> Script Post-Function[ScriptRunner] --> Custom script
please find code snippet for custom field update in workflow transition
import com.atlassian.jira.component.ComponentAccessor
def cfUpdate = ComponentAccessor.customFieldManager.getCustomFieldObjectByName("Custom Field Name")
def value = "value to update in field"
issue.setCustomFieldValue(cfUpdate, value)
BR,
Leo
Thanks Leo, I will try it tomorrow and update you.
I also wanted to know if i have 2 requirement and if it meet then only the field to be added automatically.
For eg if the Status changed to "Waiting Internal" and Customer = "ABCDEF" then Organisation field should automatically updated "Testing1" else if
Status changed to "Waiting Internal" and Customer = "XYZ" then Organisation field should automatically updated "Testing2"
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey, It's quite simple
If you add post function in "Waiting Internal" transition, your 1st condition will be always true when this script executes
And for 2nd you just need to add if..else. below snippet may help you :)
import com.atlassian.jira.component.ComponentAccessor
def cfUpdate = ComponentAccessor.customFieldManager.getCustomFieldObjectByName("Organization")
def cfCustomer = ComponentAccessor.customFieldManager.getCustomFieldObjectByName("Customer")
def customer = issue.getCustomFieldValue(cfCustomer)
if(customer == "ABCDEF"){
issue.setCustomFieldValue(cfUpdate, "Value to update here")
}else{
issue.setCustomFieldValue(cfUpdate, "Value to update here")
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks Leo.
I will try this tomorrow..Have a good day
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 tried this script but nothing is happening.
when i update customer "ABCDEF" the Organisation field remains blank
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
There are 2 things,
1. Script I provided for post-function, which will work only during issue transition. if you want it to work during issue update then we can give a try with custom listener with issue update event
2. Also this script is to update normal text field, is your Organization field text field or Select list?
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,
Organisations is a custom field not a list.
I can add only Group name here For eg the group name is "Testing1" and Testing 1 added with several users under customer page
Group Name is Testing1 and it contain several users
1) ambc@XXXX.com
2) dffc@XXXX.com
1) amffffbc@XXXX.com
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey,
I haven't done any script with group picker field, you can refer this post for group field update: https://community.atlassian.com/t5/Jira-Service-Desk-questions/Need-Help-to-Update-Group-Picker-Field-By-using-the-Script-post/qaq-p/1023947
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.