Behaviour: Making nfeed fields required

Hi,

 

I have checkbox field with 3 options and a nfeed field which is populated from a database. My use case: When option 1 is checked i want to show the nfeed field via formField.setHidden(false) and make it required via formField.setRequired(true).

 

However when i try it, nothing happens but a loading icon at the end of the create form. Only when I remove the line formField.setRequired(true), the field appears. Other customfields work fine with showing and make them required.

 

Is there a way to make behaviour work with the nfeed field? I'm using Scriptrunner 3.1.4, nfeed 5.4.1 and JIRA 6.4.12

2 answers

1 accepted

Hi Ja,

I have managed to replicate your issue using Scriptrunner 3.1.4, nfeed 5.4.1 and JIRA 6.4.12.

The reason that the behaviour fails to execute is due to the fact that the nFeed field does not support being made required. This is due to the fact that the field is a field which is programmatically populated from an external data source and cannot have its data updated by a user inside of JIRA.

This means that all you can do is hide and un hide the field based on check box options using the behaviours plugin.

I have enclosed an example script below which shows how you can hide and un hide an nFeed field based on a selected option in a checkbox field.

import com.onresolve.jira.groovy.user.FieldBehaviours
import com.onresolve.jira.groovy.user.FormField

// Get a pointer to my check box field
FormField checkBoxField = getFieldByName("DemoChecbox")

// Get a pointer to my nFeed field
FormField nFeedField = getFieldByName("DemoNfeedField")

// Get the checkbox option value as a String
def checkBoxVal = checkBoxField.getValue()

// if Option-1 was selected make the nFeed field visible
if(checkBoxVal == "Option-1"){
 nFeedField.setHidden(false)
// if any other option was selected hide the nFeed Field 
}else{
    nFeedField.setHidden(true)
}

I hope this helps

Kristian

Hi Kristian,

thanks for the fast answer, now I know I don't have to look for a solution anymore. It's fine for me.

 

Jan

Hi Jan,

Glad I was able to help.

If the answer is useful could you please mark it as accepted incase other are searching for a question similar to this one.

Thanks

Kristian

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Sep 18, 2018 in Jira

What modern development practices are at the heart of how your team delivers software?

Hey Community mates! Claire here from the Software Product Marketing team. We all know software development changes rapidly, and it's often tough to keep up. But from our research, we've found the h...

23,028 views 2 7
Join discussion

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you