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,298,490
Community Members
 
Community Events
165
Community Groups

Screen not updating when custom field values are changed

Hello, 

 

When the fields in the custom field change, I want new fields to appear depending on some selections. When I change the values, the fields I want to appear do not appear on the screen and also the fields belonging to the old selection do not disappear from the screen. I can't figure out if the code is completely broken or what is missing.

 

Thanks for help.

Ekran Alıntısı1.PNGEkran Alıntısı.PNG


import com.atlassian.jira.ComponentAccessor
import com.onresolve.jira.groovy.user.FieldBehaviours
import com.onresolve.jira.groovy.user.FormField
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.context.IssueContext
import com.atlassian.jira.issue.context.IssueContextImpl
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.fields.customfields.*
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.customfields.manager.OptionsManager
import com.atlassian.jira.issue.fields.config.FieldConfigImpl
import com.onresolve.jira.groovy.user.FormField
import groovy.transform.BaseScript

@BaseScript FieldBehaviours fieldBehaviours


import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.IssueManager;

def insightCF = getFieldById("customfield_10301")
log.warn "ingishtCF:"+insightCF


def insightKey = insightCF.getValue()
log.warn "insightKey:"+insightKey


Class objectFacadeClass = ComponentAccessor.getPluginAccessor().getClassLoader().findClass("com.riadalabs.jira.plugins.insight.channel.external.api.facade.ObjectFacade")
def objectFacade = ComponentAccessor.getOSGiComponentInstanceOfType(objectFacadeClass)
def insightObject = objectFacade.loadObjectBean(insightKey)
def insightCustomFieldName = insightObject.getName()

log.warn "insightCustomFieldName:"+insightCustomFieldName

def ProjectProductInformationCF = getFieldById("customfield_11337")
def PurposeofUsageCF = getFieldById("customfield_11338")
def PurposeofUsageValue = PurposeofUsageCF.getValue().toString()
def isTrueSelected = PurposeofUsageValue == "A"

def ServerRoleCF = getFieldById("customfield_11339")
def RiskAciklamaCF = getFieldById("customfield_10608")
def RamCpuCF = getFieldById("customfield_113400")


def sethiddenfunction(){
def ProjectProductInformationCF = getFieldById("customfield_13587")
def PurposeofUsageCF = getFieldById("customfield_11338")
def ServerRoleCF = getFieldById("customfield_11339")
def RiskAciklamaCF = getFieldById("customfield_10608")
def RamCpuCF = getFieldById("customfield_11340")


ProjectProductInformationCF.setRequired(false)
PurposeofUsageCF.setRequired(false)
ServerRoleCF.setRequired(false)
RiskAciklamaCF.setRequired(false)
RamCpuCF.setRequired(false)

ProjectProductInformationCF.setHidden(true)
PurposeofUsageCF.setHidden(true)
ServerRoleCF.setHidden(true)
RiskAciklamaCF.setHidden(true)
RamCpuCF.setHidden(true)
}

if(insightCustomFieldName == "Billing Service"){
sethiddenfunction()

ProjectProductInformationCF.setRequired(true)
ProjectProductInformationCF.setHidden(false)

PurposeofUsageCF.setRequired(true)
PurposeofUsageCF.setHidden(false)

}

else if(insightCustomFieldName == "Email Service"){
sethiddenfunction()

ServerRoleCF.setRequired(true)
ServerRoleCF.setHidden(false)

PurposeofUsageCF.setRequired(true)
PurposeofUsageCF.setHidden(false)

}

else if(insightCustomFieldName == "ERP Service"){
sethiddenfunction()

ProjectProductInformationCF.setRequired(true)
ProjectProductInformationCF.setHidden(false)

PurposeofUsageCF.setRequired(true)
PurposeofUsageCF.setHidden(false)

if(PurposeofUsageValue == "A"){
//sethiddenfunction()

RiskAciklamaCF.setRequired(true)
RiskAciklamaCF.setHidden(false)
}
else{
RiskAciklamaCF.setHidden(false)
RiskAciklamaCF.setRequired(true)
}


}
else {
sethiddenfunction()
}

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Confluence

An update on Confluence Cloud customer feedback – June 2022

Hi everyone, We’re always looking at how to improve Confluence and customer feedback plays an important role in making sure we're investing in the areas that will bring the most value to the most c...

188 views 1 3
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you