The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Making Fields mandatory based on Element Connect SQL feed custom field

Sekhar Chandra
Contributor
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

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

0 votes
Florian Bonniec
Community Champion
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
Contributor
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 Champion
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