Custom field(Scripted field) value is not showing up in the change History

Custom field(Scripted field) value is not showing up in the change History.

Below is my Script:

ComponentManager componentManager = ComponentManager.getInstance()

CustomFieldManager customFieldManager = componentManager.getCustomFieldManager()
Date versionDate = null;
String sqtr="";
MutableIssue myIssue = issue;
def versions = myIssue.getFixVersions();
CustomField approveFixDateField = customFieldManager.getCustomFieldObjectByName("Approved for Fix Date");
Object approveFixDate = approveFixDateField.getValue(issue);

for(version in versions){
if (version!=null){
versionDate = version.getReleaseDate();
}
}
if((versions == null) || (versions.size() <= 0)) {
CustomField origDept = customFieldManager.getCustomFieldObject("customfield_12189");
String origValue = origDept.getValue(issue).toString();
CustomField severity = customFieldManager.getCustomFieldObject("customfield_12356");
String severityValue = severity.getValue(issue).toString();

if ((approveFixDate != null) && (origValue.equals("Customer")) && (severityValue.equals("S2") || severityValue.equals("S3"))){

def dt = issue.getCreated();
int mm;
int yr;
String cqtr;

if(severityValue=="S2"){
def ms = dt.getTime()+10368000000;
def ms1 = approveFixDate.getTime()+7776000000;
if (ms > ms1)
{
def ts = new Timestamp(dt.getTime()+10368000000);
mm = ts.month +1;
yr = ts.year+1900;
}
else
{
def ts = new Timestamp(approveFixDate.getTime()+7776000000);
mm = ts.month +1;
yr = ts.year+1900;
}
}
if(severityValue=="S3"){
def ms = dt.getTime()+23328000000;
def ms1 = approveFixDate.getTime()+15552000000;
if (ms > ms1)
{
def ts = new Timestamp(dt.getTime()+23328000000);
mm = ts.month +1;
yr = ts.year+1900;
}
else
{
def ts = new Timestamp(approveFixDate.getTime()+15552000000);
mm = ts.month +1;
yr = ts.year+1900;
}

}

if(mm >=1 && mm <=3)
cqtr="Q1";
else if(mm >=4 && mm <=6)
cqtr="Q2";
else if(mm >=7 && mm <=9)
cqtr="Q3";
else if(mm >=10 && mm <=12)
cqtr="Q4";
return yr + " " +cqtr;
}
}

else if( (approveFixDate!=null) && (versionDate != null) ){
Date today = new Date();
if (versionDate.minus(today)>=30){
if(versionDate.month >=0 && versionDate.month <=2)
sqtr="CQ1";
else if(versionDate.month >=3 && versionDate.month <=5)
sqtr="CQ2";
else if(versionDate.month >=6 && versionDate.month <=8)
sqtr="CQ3";
else if(versionDate.month >=9 && versionDate.month <=11)
sqtr="CQ4";
return versionDate[Calendar.YEAR] + " " +sqtr;
}
else if (versionDate.minus(today)<30)
{
String newDate = versionDate.format('MMM');
return versionDate[Calendar.YEAR]+ " "+newDate;
}


}


else
return null;

 

I will be glad if any one can guide me right direction.

Thanks,

 

1 answer

1 accepted

0 vote

Scripted fields do not hold data, so there's no history for them.  If you want them to have a history, you need to do the logic in a post function or listener and actively store the results in a standard custom field.

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Monday in Jira Software

How large do you think Jira Software can grow?

Hi Atlassian Community! My name is Shana, and I’m on the Jira Software team. One of the many reasons this Community exists is to connect you to others on similar product journeys or with comparabl...

633 views 6 12
Read article

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you