Hi I have a custom field which is a drop down menu(single select) with two options 'A' and 'B'. If I select A due date should be required otherwise not.
I am using the following code as a server side validation using Behaviours plugin
{code}
import org.apache.log4j.Category
import com.onresolve.jira.groovy.user.FieldBehaviours
import com.onresolve.jira.groovy.user.FormField
import com.atlassian.jira.issue.Issue
def Category log = Category.getInstance("com.onresolve.jira.groovy.postfunction");
log.warn("Test log statement"+getFieldByName("duedate"));
log.warn("Finished logging ---"+getFieldByName("End User").getValue()+" ------");
if(getFieldByName("End User").getValue() == "A")
{
getFieldByName("duedate").setRequired(true);
}
Community moderators have prevented the ability to post new answers.
Try
getFieldById("duedate")
But note you have nothing that sets the due date back to not required, if the user changes from option A to something else.
So remove your "if" block and use:
getFieldById("duedate").setRequired(getFieldByName("End User").getValue() == "A")
Hi Jamie,
Thanks for the reply. I made the changes but it still does not work.
Note: This is for the entire workflow so do I need to put any conditions or adding no conditions implies across the entire worklfow.
Thanks.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You've written this as a behaviours script. That's the bestway to do this, although it could also be done as a validator.
Can you send a screenshot of the config.
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.
I don't see a screenshot...
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.