Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 5 Next »

Setting Content of Message++ Field with Script Runner

Following Script will set content of Message++ field to a table constructed using a template and fields from issue.

You can find JavaDoc of our API here.

Setting Message++ Content from Script Runner
import com.deniz.jira.cf.imp.message.MessageConfigManager;
import com.onresolve.scriptrunner.runner.customisers.PluginModule;
import com.onresolve.scriptrunner.runner.customisers.WithPlugin;
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.Issue;
import java.text.SimpleDateFormat;

@WithPlugin("com.deniz.jira.customfields")
@PluginModule
MessageConfigManager messageConfigManager;
def customFieldManager = ComponentAccessor.getComponent(CustomFieldManager)

def issue = event.issue as Issue;


def body="""
<div>
<div id="header">
  <p>As the Project's Investment Sponsor, please <a href="http://localhost:2990/jira/secure/CommentAssignIssue!default.jspa?action=101&id=${issue.id}" target="_blank">Appoved</a>
    the project closure or request
    <a href="http://localhost:2990/jira/secure/CommentAssignIssue!default.jspa?action=71&id=${issue.id}" target="_blank">Rework</a>.
  </p>
<div>

<div id="summary-table">
<h2>${issue.summary}</h2>
 
<table>
  <tr>
    <th bgcolor="#DCDCDC">Reporter</th>
	<th bgcolor="#DCDCDC">Project Manager</th>
    <th bgcolor="#DCDCDC">Business Case Owner</th>
    <th bgcolor="#DCDCDC">End Date</th>
    <th bgcolor="#DCDCDC">Status</th>
    <th bgcolor="#DCDCDC">CRB Closure</th>
  </tr>
  <tr>
    <td>${issue.reporter?.displayName}</td>
    <td>${issue.getCustomFieldValue(customFieldManager.getCustomFieldObjectByName("Project Manager"))?.displayName}</td>
    <td>${issue.getCustomFieldValue(customFieldManager.getCustomFieldObjectByName("Business Case Owner"))?.displayName}</td>
    <td>${new SimpleDateFormat("d MMM yyyy").format(issue.getCustomFieldValue(customFieldManager.getCustomFieldObjectByName("End date")))}</td>
    <td>${issue.status.name}</td>
    <td>${issue.getCustomFieldValue(customFieldManager.getCustomFieldObjectByName("CRB Closure"))}</td>        
  </tr>
</table>
</div>
</div>
"""
    
messageConfigManager.save(11600L, "error", "Body is set by Script Runner on Message++", body, false);

  • No labels