How to force the user to modify a field

Nath April 10, 2019

Hello,

In Jira Server, I would like to block a transition as long as a field (assignee) has not been modified from its original value. Do you have a solution for that ?

Can Script runner be used ?

Thank you.

Nath

1 answer

1 accepted

0 votes
Answer accepted
Antoine Berry
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 10, 2019

Hi @Nath ,

Script Runner could indeed be used for that, more specifically behaviours. You can compare the form value to the actual value (using underlyingIssue object). If they are the same, you can set an error on the form. Let me know if you need more guidance.

Antoine 

Nath April 11, 2019

Hi,

I try to recover the initial value of the field "assignee" and the one entered by the user, but I do not have the same result, while the target user is identical. Is there a method to obtain comparable results, or should I reprocess the initial data obtained, to obtain comparable elements ?
Thank you in advance for your help.

Here is the code in my Behaviours :

String fieldAssignee = getFieldById("assignee")
fieldAssignee.setRequired(true)
String assigned = underlyingIssue.assignee?.displayName
String myValue = underlyingIssue.assignee

if (myValue == fieldAssignee)
{
fieldAssignee.setError("My error")
}

 Nath

Nath April 11, 2019

Hi,

I try to recover the initial value of the field "assignee" and the one entered by the user, but I do not have the same result, while the target user is identical. Is there a method to obtain comparable results, or should I reprocess the initial data obtained, to obtain comparable elements ?
Thank you in advance for your help.

Here is the code in my Behaviours :

String fieldAssignee = getFieldById("assignee")
fieldAssignee.setRequired(true)
String assigned = underlyingIssue.assignee?.displayName
String myValue = underlyingIssue.assignee

if (myValue == fieldAssignee)
{
fieldAssignee.setError("My error")
}

 Nath

Antoine Berry
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 11, 2019

Hi Nath,

Try this (link the behaviours to the Assignee field) : 

def formAssignee = getFieldById("assignee")
formAssignee.setRequired(true)
def formAssigneeValue = (formAssignee.getValue() == null) ? "" : formAssignee.getValue().toLowerCase()

String issueAssigneeValue = (underlyingIssue.getAssignee() == null) ? "" : underlyingIssue.getAssignee().getKey().toLowerCase()

if (formAssigneeValue == issueAssigneeValue){
formAssignee.setError("My error")
}
else {
formAssignee.clearError()
}

Antoine

Like Nath likes this
Nath April 11, 2019

Hi Antoine,

Thank you very much for the help! I just replaced that :

def formAssigneeValue = (formAssignee.getValue() == null) ? "" : formAssignee.getValue().toLowerCase()

with that :

String formAssigneeValue = (formAssignee.getValue() == null) ? "" : formAssignee.getValue().toString().toLowerCase()

Now everything is ok. Thank you so much for your help.

Nath

Like Antoine Berry likes this

Suggest an answer

Log in or Sign up to answer