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

This widget could not be displayed.

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
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted 16 hours ago in New to Jira

Are you planning to trial, or are currently trialling Jira Software? - We want to talk to you!

Hello! I'm Rayen, a product manager at Atlassian. My team and I are working hard to improve the trial experience for Jira Software Cloud. We are interested in   talking to 20 people planning t...

42 views 1 0
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