Hi Team,
We are working on the case where whenever the ticket of this project is updated, let's say Field tower should be made mandate whenever any changes made by JIRA user in Assignee field.
So whenever user changes assignee of the ticket , the field tower should be made mandatory, so that even if users forgets to update field tower and clicks update , a pop will arise saying provide value for mandatory field. In our case it's already mandate and tried to run this groovy script as well but doesn't seem to work :
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.component.ComponentAccessor
import org.apache.log4j.Category
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.issue.ModifiedValue
import org.apache.log4j.Logger
import org.apache.log4j.Level
//Get the field tower for update
def TowerValue = getFieldById("Tower");
//Grab Assignee in edit view
def AssigneeName = getFieldById(getFieldChanged());
//grab current Assignee from database
CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager();
CustomField currentAssignee = customFieldManager.getCustomFieldObject("Assignee");
//see assignee was changed in edit view (note null safe operator [?] which allow tower to be null without throwing an exception)
if((AssigneeName ?.value) != currentAssignee) {
//clear Tower field
TowerValue.setFormValue(null);
//require Tower field so that user is forced to enter text
TowerValue.setRequired(true);
}
else {
TowerValue.setRequired(false);
}
Also could you help us guiding where this script should be running in behaviour : initialiser / under filed tower (server side - script)/ under Field Assignee (server side - script)
Regards,
Priyanka.