I've tried this a few different ways, but I keep getting "null+null".
Any ideas on what I'm doing wrong?
It's a behavior validation script places on the summary field (which is hidden), and runs on the create action.
The custom fields "system" and "access" are radio buttons.
import com.atlassian.jira.component.ComponentAccessor
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript
import static com.atlassian.jira.issue.IssueFieldConstants.SUMMARY
@BaseScript FieldBehaviours fieldBehaviours
def system = getFieldByName("System").value
def access = getFieldByName("Access").value
def summary = getFieldById("summary")
summary.setFormValue("${system} + ${access}")
It's probably due to the summary being hidden. Is that being done through the field config? If so, you may need to show it via the field config but then hide it via Behaviours. If JIRA isn't delivering the summary field to the rendered page in your browser, the Behaviours JS may not be able to find it with your 'getFieldById'.
Hey thanks @Kyle Moseley, it's only hidden in the behavior. I think the problem is that once the summary is set, it's not overwriting the summary with the new values.
So before the custom field value is entered it's already set to "null" so the updated values aren't being caught by the script. But, I'm not sure how to force it to load those values after they're entered in the form.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
And you have the script duplicated on both the Initialiser and the Summary Field? Just confirming if I'm understanding.
EDIT: May be worth extending the code to also the two Radio fields, so the script is triggered on their edits.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
No, it's only a validator for Summary field with the condition that it only runs on the "Create" action.
It works if the summary is deleted from the form. Then it reloads with the correct values of the custom fields.
I guess I need to find a way to have it reload the summary every time the custom field values are changed?
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.
Yes, just add the same script to the fields as you did for Summary. Same method as below:
I have found that when I am triggering actions from multiple CFs on a page, I end up duplicating the script on each field. So it will look a bit strange on the Behaviours interface side (seeing the same script 4 times), but ultimately works.
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.
Awesome, happy to help. Please mark the reply as an accepted answer.
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.