Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,361,397
Community Members
 
Community Events
168
Community Groups

Making Fields mandatory based on Element Connect SQL feed custom field

Hi Team - 

I'm new to Element Connect live feed custom fields, I need your help here.

I'm trying to make fields mandatory in the transition screen based on the value of a custom field which is a live SQL feed.

I have put a behaviour script for this and the script is simple and has a few lines as below

/* 
Making Fields reqired on transition screen based on another field's value. 

*/

def dropDown = getFieldByName("Internet Facing Apps")
def requiredField1 = getFieldByName("Test link Field")
def requiredField2 = getFieldByName("Test text field")
if (dropDown.getValue() == "App 5") {

requiredField1.setRequired(true)
requiredField2.setRequired(true)
}
else if (dropDown.getValue() == "App 10") {

requiredField1.setRequired(true)
requiredField2.setRequired(true)
}

else {
requiredField1.setRequired(false)
requiredField2.setRequired(false)
}

This is working for normal custom fields but not working for Element Connect's custom field which is a SQL feed custom field as already mentioned above.

Please anyone help me with this code. 

 

Thanks

Chandra

 

1 answer

Hi @Sekhar Chandra 

 

What is the Connect field "Internet Facing Apps" or Test field ?

 

/* 

Making Fields reqired on transition screen based on another field's value.

*/

import com.atlassian.jira.component.ComponentAccessor

 

def pluginAccessor = ComponentAccessor.getPluginAccessor();

def plugin = pluginAccessor.getPlugin("com.valiantys.jira.plugins.SQLFeed");

def serviceClass = plugin.getClassLoader().loadClass("com.valiantys.nfeed.api.IFieldDisplayService");

 

def fieldDisplayService = ComponentAccessor.getOSGiComponentInstanceOfType(serviceClass);

//def dropDown = getFieldByName("Internet Facing Apps")

def cfDropDownId = "customfield_XXXX"

def requiredField1 = getFieldByName("Test link Field")

def requiredField2 = getFieldByName("Test text field")

if (fieldDisplayService.getDisplayResult(underlyingIssue.key, cfDropDownId)?.getDisplay() == "App 5") {

requiredField1.setRequired(true)

requiredField2.setRequired(true)

}

else if (dropDown.getValue() == "App 10") {

requiredField1.setRequired(true)

requiredField2.setRequired(true)

}

else {

requiredField1.setRequired(false)

requiredField2.setRequired(false)

}

Replace XXX by the customfield ID of the COnnect field

Regards 

Hi @Florian Bonniec 

 

Thanks for your quick response and help.

I have tried your script in behaviours but getting error in displayService function.

 

image.png

 

Could you please help me here?

 

Thanks

Chandra

Hi 

 

Can you add

import com.valiantys.nfeed.api.IFieldDisplayService

and then replace

def fieldDisplayService = ComponentAccessor.getOSGiComponentInstanceOfType(serviceClass);

 by

 

IFieldDisplayService fieldDisplayService = ComponentAccessor.getOSGiComponentInstanceOfType(serviceClass);

Regards

Suggest an answer

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

An update on Jira Software customer feedback – June 2022

Hello Atlassian Community! Feedback from customers like you has helped us shape and improve Jira Software. As Head of Product, Jira Software, I wanted to take this opportunity to share an update on...

5,069 views 18 32
Read article

Atlassian Community Events