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 Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

3,331 views 14 20
Join discussion

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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot