Hello need help please
I have to make the system field due date mandatory only if the custom field delivery date desired is filled. Here is my script:
import com.atlassian.jira.component.ComponentAccessor
import com.onresolve.jira.groovy.user.FormField
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.CustomFieldManager
def issueManager = ComponentAccessor.getIssueManager()
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def desired_delivery_date = customFieldManager.getCustomFieldObject("customfield_12303")
def issueObject = issue
def duedate = issueObject.getDueDate()
if ( desired_delivery_date != null){
duedate.setRequired(true)
}
When I execute this script I get this error :
groovy.lang.MissingMethodException: No signature of method: com.atlassian.jira.issue.fields.ImmutableCustomField.setRequired() is applicable for argument types: (Boolean) values: [false] at Script1288.run(Script1288.groovy:21)
Thanks for your help
Hi @Alice Are you trying to make due date mandatory using Sripted Validator or using ScriptRunner Behaviour ?
Thanks
Hi @Alice Apply Below Script in ScriptRunner >> Behaviours > in delivery date desired field server side script to make due date mandatory when delivery date desired is not empty.
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript
import com.atlassian.jira.component.ComponentAccessor
import java.sql.Timestamp
@BaseScript FieldBehaviours fieldBehaviours
def formfield = getFieldById("customfield_35350")
def duedate = getFieldById("duedate")
def releaseDate = formfield.value as Date
if (releaseDate){
duedate.setRequired(true)
} else if (!releaseDate) {
duedate.setRequired(false)
}
Kindly replace field id 35350 with your custom field id.
Thanks
VY
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I am using Scriptrunner Behaviours. Thanks for the script I test.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Alice In Behaviour above script works fine.
kindly accept the answer if this resolves your issue!! It helps other user to find right solution who is having same query.
Thanks!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Can we have same script Make a field mandatory based on another field (dropdown list)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Here is the sample script :-
//Apply Scriptrunner behaviour on select list field
def team = getFieldByName("Accuracy") //select list field
def desc = getFieldById("description") //multi-line text field
log.debug("dropdown value" + team.getValue())
if (team.getValue() == "Satisfied") {
desc.setFormValue("Test Case 1")
}else if (team.getValue() == "Very Satisfied") {
desc.setFormValue("Test Case 2")
}else {
desc.setFormValue("")
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for your quick reply.
What I am looking for I have list of Meeting if the user selects others, he should type the name of meeting on the text field and the text field become mandatory field
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I used below script, but the field not marked as Mandatory once user select Others.
------------------------------------------------------------------------------------
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Shaikha alketbi What is the field type of "Meeting" field ?
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.
Hi @Alice , do you have the add-on JMWE or Script Runner ?
If you have JMWE, you can use validators with the required field based on condition. :)
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 believe the @Vikrant Yadav resolved the problem already :)
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.