Forums

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

Auto load table format based on another field value selection

Omprakash Thamsetty
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 15, 2020

Hi.

I have 2 fields. One is single selection field (Field_A) and second one is wikistyle multi-text field (Field_B).

We needs to load the table format in Field_B based on Field_A selection.

Ex: On Create Field_A selection value is Database then load following table format

def dfValueDatabase="""
||Server Name| |
||Database| |
||Region| | """.replaceAll(/ /,' ')

 

Once we create the issue then user may change the selection in Field_A to "Windows" from "databases" on Edit screen then it should clear the previous loaded data and then load new table format as follows

def dfValuewindows="""
||Server Name| |
||Location| |
""".replaceAll(/ /,' ')

 

Any help on this clearing the old values and then placing the new table to hold the values. I have written the behavior as below on create so far. But on Edit not finding the way to clear the table based on selection.

 

def Field_A = getFieldById ("customfield_17700")
String Field_AVal = (String) Field_A.getValue()


def custField_B = getFieldByName("Field_B")

def customFieldManager = ComponentAccessor.getCustomFieldManager()
def customField_B= customFieldManager.getCustomFieldObject(custField_B.getFieldId())



def dfValueDatabase="""
||Server Name| |
||Database| |
||Region| | """.replaceAll(/ /,' ')

def dfValuewindows="""
||Server Name| |
||Location| |
""".replaceAll(/ /,' ')


if (getActionName()== "Create"){

if (Field_AVal == "database"){
   if (!underlyingIssue?.getCustomFieldValue(customField_B)) { 
   custField_B .setFormValue(dfValueDatabase)
 }
}else if (Field_AVal == "Windows"){
  if (!underlyingIssue?.getCustomFieldValue(customField_B)) {
       MigDetails.setFormValue(dfValuewindows)
}

}

}else

{

//   We needs to write the code to check new value and hold the modified value. When we click on Edit. Can anyone suggest what should be here.

}

 

 

0 answers

Suggest an answer

Log in or Sign up to answer