Hi everyone,
I am trying to clear Insight field on create screen.
When you select any Component, Insight field fetches data according to Component. If you select any result and then if component changes, data will be changed but u have to select manually new result. (It still keeps old data)
Although Insight Field is required, data is wrong(previous selection value), you can create on this point. I want to clear Insight Field value when component is changed. I am trying Script Runner Behaviour now.
.setFormValue("A-1") is working with specific Object ID. But when I use .setFormValue("") or .setFormValue(null) etc. It did not work.
How can I handle this? Is it possible on Insight fields? Anyone knows?
Thanks,
My Regards
Hi @Batuhan ŞEN
I have done a basic test in my environment, and I don't seem to be encountering any problems.
Below is the sample working code that I have tested with:-
import com.atlassian.jira.bc.project.component.ProjectComponentImpl
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript
@BaseScript FieldBehaviours behaviours
def components = getFieldById(fieldChanged)
def componentsValue = components.value as List<ProjectComponentImpl>
components.clearError()
def insightField = getFieldByName('Support Engineer')
insightField.setFormValue(null)
componentsValue.each {
if (componentsValue.size() == 1) {
if ( it.name == 'Animation') {
insightField.setFormValue('SS-1')
} else if (it.name == 'Database') {
insightField.setFormValue('SS-2')
} else if (it.name == 'Server') {
insightField.setFormValue('SS-3')
} else if (it.name == 'UI') {
insightField.setFormValue('SS-4')
}
} else if (componentsValue.size() == 2) {
if (it.name in ['Animation', 'Database']) {
insightField.setFormValue(['SS-1', 'SS-2'])
} else if (it.name in ['Animation', 'Server']) {
insightField.setFormValue(['SS-1', 'SS-3'])
} else if (it.name in ['Animation', 'UI']) {
insightField.setFormValue(['SS-1', 'SS-4'])
} else if (it.name in ['Database', 'Server']) {
insightField.setFormValue(['SS-2', 'SS-3'])
} else if (it.name in ['Database', 'UI']) {
insightField.setFormValue(['SS-2', 'SS-4'])
} else if (it.name in ['Server', 'UI']) {
insightField.setFormValue(['SS-3', 'SS-4'])
}
} else if (componentsValue.size() == 3) {
if (it.name in ['Animation', 'Database', 'Server']) {
insightField.setFormValue(['SS-1', 'SS-2', 'SS-3'])
} else if (it.name in ['Animation', 'Database', 'UI']) {
insightField.setFormValue(['SS-1', 'SS-2', 'SS-4'])
} else if (it.name in ['Database', 'Server', 'UI']) {
insightField.setFormValue(['SS-2', 'SS-3', 'SS-4'])
}
} else if (componentsValue.size() == 4) {
insightField.setFormValue(['SS-1', 'SS-2', 'SS-3', 'SS-4'])
}
}
Please note that the sample code above is not 100% exact to your environment. Hence, you will need to make the required modifications.
I have configured the Insight Asset to a Multi-Select list in the sample above. Hence, the additional conditions are added based on the Component/s size.
Below is a screenshot of the Behaviour configuration:-
Below are a couple of test screenshots. They display the option selected in the Insight Field according to the option set in the Component/s field.
I all options are selected from the Component/s list, all the options will be selected in the Insight Asset field as well as shown below:-
If the Component/s field is reset, i.e. empty, the Insight field is also empty accordingly, as shown below:-
I hope this helps to answer your question. :-)
Thank you and Kind regards,
Ram
Hi @Ram Kumar Aravindakshan _Adaptavist_,
Thank u.
I tried it but it did not work. Actually, this Insight field configured as
Filter Issue Scope (IQL): Component=${components.label}, because so many objects on the scheme.
For example, I selected one and I removed or selected new one. Field keeps old value. And I have to select manually. setFromValue(null) did not work.
Actual result is No Matches. Even required, you can create because it keeps old one :)
Thank u again,
My Regards
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Batuhan ŞEN
Could you do a quick test and add a log parameter to see the value returned in the Insight Assets field?
I'm not sure if it returns the Insight key alone. This could be possibly why it is not working on your end.
Thank you and Kind regards,
Ram
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Ram Kumar Aravindakshan _Adaptavist_ ,
It is working now. When I tried to use getFieldById("customfield_xxxxx") instead of getFieldByName(), it worked.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Today only! Share what you’re the most excited about for Team ‘25 or just dance out the beginning of a new quarter with us.
Comment the postOnline forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.