Just a heads up: On March 24, 2025, starting at 4:30pm CDT / 19:30 UTC, the site will be undergoing scheduled maintenance for a few hours. During this time, the site might be unavailable for a short while. Thanks for your patience.
×Hi,
I have a workflow process with three screens attached to the screen schemes (edit, view, create).
However one of our requirement is adding a fourth screen which is attached to the transition between status.
I have added a "Custom Script Validation" script using Script Runner to validate the fourth screen's user input. Upon testing the validation I noticed the validation captured my input and displayed the scripted error message. However during this process the values in my custom fields cleared out
This is the following two lines of code I used to output my error message and prevents the transition
import com.opensymphony.workflow.InvalidInputException
throw new InvalidInputException(errMsg)
I have tested this on screens attached to the screen scheme and it operated successfully
Can someone elaborate if this is a bug with script runner or by design
Just to clarify, you say that your custom fields are purged by the script. Are the purged fields only those on the fourth screen or does it also impact fields tied to the screen scheme?
No, the script does not purge custom field values. It only parses the values for validation
Once I hit the transition button, the fourth screen appears for user input, I input invalid data and click on the transition button.
The validation kicks in returning the expected error message and the invalid values are purged from the custom field.
All other custom field values (un-associated with the script) are untouched
I copied the validation script and applied the script to the "Create" transition ("initial" to "Open" status) and tested issue creation process. The validation picked up the invalid data, presented the error message and both invalid and valid data is untouched
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
So the issue is not with the fourth screen but with the failure to clear the invalid data on the create screen?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The below is the expected successful response
1. In the issue view, I click on the transition button and the fourth screen opens
2. I input invalid values to custom field
3. I click the transition button
4. Validation script checks the invalid values and generates an error message
5. Since validation script captured the invalid values, the fourth screen will present the error message of invalid values
6. The error message is displayed and ALL values from Custom Field remains untouched
However if I repeat steps 1-5 in my test environment then below are the unwanted results
6. The invalid values are cleared from the custom field while the other valid values are untouched
I am expecting ALL values inputted in the fourth screen remains untouched after running the Custom Validation Script
Script example
import com.atlassian.jira.component.ComponentAccessor
import com.opensymphony.workflow.InvalidInputException
import com.atlassian.jira.issue.IssueFieldConstants
def cfm = ComponentAccessor.getCustomFieldManager()
def cfBundledFields = cfm.getCustomFieldObjectByName("IP-Address-Range")
def cfValueClone = issue.getCustomFieldValue(cfBundledFields)
if (...validation check...){
//Validation fails
String errMsg="Failed"
throw new InvalidInputException(IssueFieldConstants.ISSUE_LINKS,errMsg)
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Based on the script excerpt you've given above that's not a behaviour I would expect to see. I'll have to see if I can replicate the issue.
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.