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

This widget could not be displayed.

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

This widget could not be displayed.

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
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Wednesday in New to Jira

Are you planning to trial, or are currently trialling Jira Software? - We want to talk to you!

Hello! I'm Rayen, a product manager at Atlassian. My team and I are working hard to improve the trial experience for Jira Software Cloud. We are interested in   talking to 20 people planning t...

83 views 1 0
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