Making Fields mandatory based on Element Connect SQL feed custom field

Sekhar Chandra September 19, 2022

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

0 votes
Florian Bonniec
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 19, 2022

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 

Sekhar Chandra September 22, 2022

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

Florian Bonniec
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 22, 2022

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