Forums

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

How to set a font color for custom field text value using script listener

Pradeep Kumar
Contributor
January 31, 2018 edited

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)

 

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, aafp, jira migration, marketing collaboration, end siloed work, streamline workflows, kerrie gottschalk, jira cloud admins, unified marketing, process visibility, team efficiency, cross-team collaboration

How Kerrie Gottschalk unified AAFP’s marketing team with Jira

At the American Academy of Family Physicians, siloed marketing teams faced delays and duplicate work. Kerrie Gottschalk shook things up by moving the department to Jira, streamlining processes, boosting visibility, and sparking stronger collaboration.

Read the story
AUG Leaders

Atlassian Community Events