Forums

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

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

Vijay Sv
Contributor
April 21, 2015

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 votes
Answer accepted
Nic Brough -Adaptavist-
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 21, 2015

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