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,
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.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.