I need to set a font color for custom field value using script listener and below is the my code.
Field name : InternalCommunications and AllCommunication
def MutableIssue issueObject = (MutableIssue) issue
def MutableIssue parentIssue = issueObject.getParentObject() as MutableIssue
/* Set debugging level */
log.setLevel(org.apache.log4j.Level.DEBUG)
log.debug(parentIssue)
/* Initialize global objects */
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def issueTypeName = issue.issueTypeObject.name
log.debug("LISTENER CPI Wiki Markup==> STARTED")
if (issueTypeName == "Payment Inquiry" || issueTypeName == "Operational Inquiry" || issueTypeName == "Policy Inquiry" ) {
/* Retrieve Comment data */
//def actualComments = ComponentAccessor.getCommentManager().getComments(issueObject)
def actualComments = ComponentAccessor.getCommentManager().getLastComment(issueObject)
log.debug("Process each comment")
actualComments.each {
//def FromEmail = it.getUpdateAuthorFullName()
def FromEmail = actualComments.getAuthorApplicationUser().getEmailAddress()
log.debug("****** getAuthorApplicationUser FromEmail "+ FromEmail)
if(FromEmail != "")
{
def FromEmail1 = actualComments.getUpdateAuthorFullName()
//def FromEmail = it.getAuthorApplicationUser().getEmailAddress()
log.debug("****** getAuthorApplicationUser "+actualComments.getAuthorApplicationUser())
// FromEmail = it.getAuthorApplicationUser().toString()
log.debug("****** getAuthorApplicationUser FromEmail "+ FromEmail1)
// log.debug ("FromEmail.value: " + FromEmail.value)
def InternalCommunications = customFieldManager.getCustomFieldObjects(issueObject).find {it.name == "Internal Communications"}
def AllCommunication = customFieldManager.getCustomFieldObjects(issueObject).find {it.name == "AllCommunication"}
IssueChangeHolder localFieldChangeHolder = new DefaultIssueChangeHolder()
def newStr = "\n From: " + FromEmail1 + "\n Date and Time: " + actualComments.getCreated() + "\n" +" Body: " + actualComments.getBody() +"\n-----------------------------------------------------------------------------------------------------\n"
log.debug ("newStr: " + newStr)
def newStr1 = newStr
def newStr2 = newStr
def InternalCommunicationOldValue = issueObject.getCustomFieldValue(InternalCommunications)
def ii =InternalCommunicationOldValue.toString()
def OICV = newStr1.toString()
log.debug("New Internal Comments" + OICV)
if(InternalCommunicationOldValue && !ii.contains(OICV))
{
newStr1 = newStr.toString()+InternalCommunicationOldValue
InternalCommunications.updateValue(null, issueObject, new ModifiedValue(issueObject.getCustomFieldValue(InternalCommunications), newStr1), localFieldChangeHolder)
}
log.debug("InternalCommunicationOldValue" + InternalCommunicationOldValue)
if (InternalCommunicationOldValue == null)
{
InternalCommunications.updateValue(null, issueObject, new ModifiedValue(issueObject.getCustomFieldValue(InternalCommunications), OICV), localFieldChangeHolder)
}
// InternalCommunications.setForeground(Color.white)
log.debug("COMPLETED Updating Internal Communication field")
def AllCommunicationOldValue = issueObject.getCustomFieldValue(AllCommunication)
def ac =InternalCommunicationOldValue.toString()
def OACV = newStr2.toString()
if(AllCommunicationOldValue && !ac.contains(OACV))
{
newStr2 = newStr.toString()+AllCommunicationOldValue
AllCommunication.updateValue(null, issueObject, new ModifiedValue(issueObject.getCustomFieldValue(AllCommunication), newStr2), localFieldChangeHolder)
}
log.debug("AllCommunicationOldValue" + AllCommunicationOldValue)
if(AllCommunicationOldValue== null)
{
AllCommunication.updateValue(null, issueObject, new ModifiedValue(issueObject.getCustomFieldValue(AllCommunication), OACV), localFieldChangeHolder)
}
log.debug("COMPLETED Updating AllCommunication field")
}
log.debug("Completed processing all comments")
}
}
event.issue.store()
log.debug("LISTENER CPI Wiki Markup==> COMPLETED for " + issueTypeName)
/* Re-set debugging level */
log.setLevel(org.apache.log4j.Level.WARN)
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.