Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Screen not updating when custom field values are changed

Gökberk Karaca March 24, 2022

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
AUG Leaders

Atlassian Community Events