Hi,
I have 2 custom fields:
1. scripted field that calculates some integer value.
2. Radio button with 5 options.
I want to add a behavior to the scripted field that will cause to a changing of the Radio button field. The condition should be this:
If (scripted field value <= 0 ){
Radio button option = A
}
else{
Keep the original value of the Radio button field.
}
Can anyone please assist me with this?
Thanks in Advance!
Hi Tomas,
I created this script below and is working from my side. Please give a try.
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.service.util.ServiceUtils
import com.atlassian.jira.service.util.handler.MessageUserProcessor
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.user.util.UserManager
import com.atlassian.mail.MailUtils
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.event.type.EventDispatchOption
def userManager = ComponentAccessor.getComponent(UserManager)
def projectManager = ComponentAccessor.getProjectManager()
def issueFactory = ComponentAccessor.getIssueFactory()
def messageUserProcessor = ComponentAccessor.getComponent(MessageUserProcessor)
def subject = message.getSubject() as String
def issue = ServiceUtils.findIssueObjectInString(subject)
if (issue) {
log.warn "==========================SR Incoming Mail issue exists"
log.warn "issue: $issue"
ApplicationUser user = userManager.getUserByName("admin")
def issueManager = ComponentAccessor.issueManager
MutableIssue issueObject = issueManager.getIssueObject(issue.key)
issueObject.setDescription("this is an example")
//Custom Field code here
issueManager.updateIssue(user,issueObject,EventDispatchOption.ISSUE_UPDATED,false)
log.warn "==========================SR Incoming mail Ended"
}
{code}
To update a custom field value, you can append the code in the script before "*issueManager.updateIssue()*" API:
{code:java}
def customField = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Custom Field")
issueObject.setCustomFieldValue(customField,"numbers")
Thank you.
Kind regards,
John Chin
Hi John...it worked like a charm! This line definitely did the trick:
issueManager.updateIssue(user,issueObject,EventDispatchOption.ISSUE_UPDATED,false)
You guys always rock! Thank you so much
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@John Chin I am trying a similar one, however, I need to update the custom field single select drop down after an email is sent out in the escalation service. Is this possible? I was able to send email but cannot update the single select custom field. Can you pleasse help?
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.