I have a behavior I am attempting to only set form default value on if the form is empty. In the intialiser I have an if statement checking the freetext field for a value. I've tried about every combination of logic to check the field for data and I keep getting unexpected results.
What is the return on a free text field? For error checking I've added HelpText of the value being read in from the field using getValue() and I am consistently seeing "null" being returned even when there is data in the field.
What would be code used to check for an empty free text field? I feel like this rudimentary as I use it all over in other places scripts and behaviors, does the initialiser behave differently?
I've tried booleon comparison, string comparison, and nothing seems to be working well.
Hi @Steven Mustari,
This seems to be a known issue with Behaviour's initialiser,
as a workaround you can add a field level behaviour to fix this
def field = getFieldByName("Field Name")
if (!field.getValue()) {
field.setFormValue("Default Value")
}
BR,
Leo
This should satisfy the requirement.
Thanks again Leo!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Well sort of, unfortunately, it wont let me submit a blank form. I need this to only run once. Could I trick it some how to only run one time when the field loads with out using the initialiser section?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Steven Mustari,
I don't think there is a way to add condition like this. but below workaround would meet your requirement if not 100% at least 80%
Instead of adding this behaviour for a needed field, add/map this behaviour to "Project" field so that this script will run only when create form loads
and it won't run until unless you change Project field value
Normally I map Issue type as I need different values based on issue types but for your requirement Project field should be appropriate one
BR,
Leo
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
So in essence any field mapped will run one time when the form loads, and then will run again when that field is interacted with?
If I understand this correctly, you've provided me with some excellent insight for future configs.
Regards,
Steven
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.