Atlassian uses cookies to improve your browsing experience, perform analytics and research, and conduct advertising. Accept all cookies to indicate that you agree to our use of cookies on your device. Atlassian cookies and tracking notice, (opens new window)
/
Setting System Fields using Script Field Processor
Published Jun 14, 2019

    Setting System Fields using Script Field Processor

    Jun 14, 2019

    In this example, we'll be setting the due date and description fields in Jira using Script Field Processor.

    The basic functionality is to set the due date a week from the current time and if the body of the mail is empty, we'll use a default/short message.

    function nextweek(){ var today = new Date(); var nextweek = new Date(today.getFullYear(), today.getMonth(), today.getDate()+7); return nextweek; } function toLocalIsoDateString(date) { function pad(n) { return n < 10 ? '0' + n : n } var localIsoDateString = date.getFullYear() + '-' + pad(date.getMonth() + 1) + '-' + pad(date.getDate()); return localIsoDateString; } if (toAddresses) { for (i =0 ; i< toAddresses.length ; i++) { if (toAddresses[i].getAddress().toLowerCase() == 'special@example.com'.toLowerCase()) { if (body === '') { resultMap.put("description", "Email import"); } resultMap.put("dueDate", toLocalIsoDateString(nextweek())); } } }

    Do note the following:

    • The description + due date is set if the receiver is special@example.com

    • Description is set to Email import if there is no body in the mail

    The Plugin People
    Teams
    , (opens new window)

    Knowledge Base
    • How-to articles
      How-to articles
       This trigger is hidden
    Results will update as you type.
    • Enterprise Mail Handler - JEMH - (Server/DataCenter)
      • Auditing History purge does not work with "Retain Failures" enabled (JIRA 7.x)
      • Concurrent mail retrieval resulting in duplicate issue creation
      • Configuration screen won't save updates
      • Creating duplicate issues to multiple projects fails
      • Diagnosing Slow or Stopped Incoming Mail
      • Duplicate issues are created when using JEMH and JIRA Data Center
      • Email client shows encoded attachment name instead of decoded file name
      • Enable Auto Labelling
      • Event Listener JSD issue transition notifications do not send if a comment is present in the transition
      • Exception during issue update validation for non-Service Desk issue
      • File Attachments cause Out Of Memory problems
      • Gmail confidential mode
      • How to supply a default value for the Tempo Account custom field
      • How to support email addresses with international characters
      • Issue fails to create with indexing errors
      • JEMH Is not yet licensed through Atlassian Marketplace
      • JIRA fires Issue Assigned event for newly created Issues
      • Jira Service Desk problems
      • Jira 7 *Wrong JVM Version!* Error
      • JSD Organization field
      • Mail fails to be retrieved from mail server
      • MYSQL exception - Caused by: java.sql.SQLException: Incorrect string value
      • MYSQL Duplicate entry '0'. No Valid License
      • Non-JIRA recipient custom field values have been updated but JEMH is notifying the old values
      • Notification History tab does not show on issues
      • Problems with IMAP
      • Problems with POP
      • Slow Jira startup with PostgreSQL
      • Sorry, you can't create any issues right now, as you need to have access to a JIRA application to be able to create issues
      • You do not have permission to assign issues
      • How to change the event type of a notified event
      • Diagnose no inbound mail handled
      • JSD (Jira Service Desk) - Who is notified when?
      • HTML extraction method to Wiki mark up
      • Setting System Fields using Script Field Processor
      • Test case editor fails to load
      • MessageRemovedException in log files during email processing
      • Characters appearing as question marks
      • UI not visible after upgrading to version 3+
      • Default Project Mapping and unwanted inheritance causing inbound mail to be forwarded
      • JEMH is disabled on startup in Manage Apps
      • Configure JSD Customers for use with JEMH
      • Custom Field values are cached causing recipients to not receive notifications (JIRA 7.3.0 - 7.3.4 , JEMH 2.1.0 - 2.1.11)
      • Restrict commenting to one project
      • Foreign key constraint violation during Audit Event history purge
      • Request participants not sent JEMH notification
      • Handling out of disk space
      • Profile import timeout error
      • Zendesk integration
      • Outlook sending formatting
      • Attachment links added as comments, Jira Service Management/Desk
      • Incoming Auditing Actions Error Popup
      • Updating JEMH's issue event listener to listen for IssueEventBundle's (JEMH-6994)
      • Template Set Responsibility Devolution (JEMH-5403)
      • Support non-ascii characters in email addresses (JEMH-6431)
      • Custom Fields don't get added during creation phase causing creation notifications to not fire for User/Group field types. (JEMH-306)
      • Cant stop reporter being added as a watcher (JEMH-790)
      • Handle re-index failure during watcher setup (JEMH-7180)
      • Inline User Macros sometimes don't render (velocity 2.0 needed) (JEMH-5536)
      • "Stuck" emails in queues after post condition test (JEMH-5366)
      • Dealing with 'Undisclosed Recipients' (JEMH Server/DC)
      • Missing Methods in TemplateIssue Class since Jira 8.19.0
      • Why do FolderClosedException occur
      • Customer Permissions for Request Participants
      • User Anonymization Fails - SQL Server 2019
      • Maintaining JEMH Attachment Property Set values
      • Display Issue Notifications in Right To Left Languages
      • Jira Server/DC - when mail polling stops, fixing without a Jira restart
      • A3 BAD User is authenticated but not connected error message when using JIRA with Office365
      • JEMH not enabling on upgrade to Jira 8.13.x and 8.20.x LTS releases made after 23-MAY-2022
      • Using an inactive user with user creation enabled
      • Missing Created/Timestamp Columns Causing Problems
      • -1 Values for the "Comment count limit" and "Comment char length limit" in the Default Project-Mapping
    • Enterprise Mail Handler - JEMHC - (Cloud)
    • EMQ
      Calendars
    You‘re viewing this with anonymous access, so some content might be blocked.
    {"serverDuration": 10, "requestCorrelationId": "f0d6ddfcb8ec4905bbabe294489c0727"}