Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Problem Getting FormField by ID (returns null) Edited

Hi guys !

I'm trying to create a script with behaviour (server-side script),

but the problem for me is im getting null from getFieldById("fixVersions));

or either getFieldByName("Fix Version/s");

neither FormField instead of def fixVersions = getFieldById("fixVersions");

import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.project.version.Version
import com.onresolve.jira.groovy.user.FieldBehaviours
import com.onresolve.jira.groovy.user.FormField
import com.atlassian.jira.project.version.Version

Issue issue = event.issue;

Collection<Version> version = issue.getFixVersions();
def fixVersion = getFieldById("fixVersions");
//def values= fixVersion.getValue();

def values = fixVersion.getValue() as List<Version>

if(values == null || values == "" || !values){
fixVersion.clearError();
}

for(int ver = 0; ver < version.size(); ver++){
boolean isReleased = version[ver].isReleased();

if(isReleased){

fixVersion.setError("Cant Assign Issue To A Released Version !");

} else{
fixVersion.clearError();
 }
}

any help solving ?

Thank you!

1 answer

0 votes
Charlie Misonne Community Leader Jul 02, 2021

Hi Shachar, welcome to the Atlassian Communit!

Have you tried:

 getFieldById("fixVersions")

I had to look it up but that is used in the vendor's documentation on this page

Hi Charlie, thanks for the reply, Yes i have tried even copying the documentation code, doesnt seem to catch the field event.

tried getFieldChanged aswell, same result.

affter adding a version, this is the result from the script runner logs :

---- Form field ID: fixVersions, value: null.

 

i have read the decomentation over and over haha.

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Jira

⏰ Day in the life of a Jira Admin!

Hello Community! We thoroughly enjoyed this just-for-fun conversation in the Jira Admin Group about what it's like to be a Jira Admin. For #JiraJuly, our talented designers created these graphics t...

497 views 2 17
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you