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)
/
Using JavaScript to set custom fields
Published Apr 09

    Using JavaScript to set custom fields

    User-provided JavaScript code is run, allowing custom logic to be used when setting a custom field. See more JavaScript examples.

    Setting the Value

    To set the relevant value on the Custom Field you would need to include setValue(fieldValue) within the script once the value has been extracted.

    JavaScript Context

    API

    Notes

    API

    Notes

    setValue(fieldValue)

    Sets the value for this Custom Field.

    Parameters

    • fieldValue the field value to set

    message.getBody()

    Get body content of email. Not available for preprocessing task.

    message.getSubject()

    Gets the Subject content of email.

    message.getAllHeaders()

    Get all headers of a message.

    message.getHeader(name)

    Get value of a message header

    Parameters

    • name the name of the header to get

    issue

    If the email being processed has been associated with an existing issue, this contains the issue data. Format is as per the Get Issue response from the Jira REST API.

    print(str)

    Adds output that is recorded during execution and shown in the processing report.

    Parameters

    • str (String) the string to be recorded

    RegExp

    Searches within string values for matching content.RegExp - JavaScript | MDN

    Steps to set create a JavaScript Custom Field Default

    1. Go to Profile > Project Mapping > Issue > Edit

    2. Under CUSTOM FIELDS DEFAULTS you will see the available custom fields for the project mapping's project.

    3. Find your custom field, select JavaScript and when you want the field to be updated e.g. On Create/Comment.

    4. Enter the relevant script within the text-box

    Testing JavaScript Custom Field Default

    1. Once the relevant Script has been configured, select a Test Case within the Select Box and Press Run.

    2. Once processed there will be an output of the Results. Allowing you to review if the correct outcome has occurred. For example below.

    The Plugin People
    Teams
    , (opens new window)

    Enterprise Mail Handler for Jira Cloud (JEMHC)
    • Getting started
      Getting started
       This trigger is hidden
    • Documentation
      Documentation
       This trigger is hidden
    • Licensing
      Licensing
       This trigger is hidden
    • How-to articles
      How-to articles
       This trigger is hidden
    • Common Problems
      Common Problems
       This trigger is hidden
    • Support
      Support
       This trigger is hidden
    • Migrating from Server/DC to Cloud
      Migrating from Server/DC to Cloud
       This trigger is hidden
    • Frequently Asked Questions
      Frequently Asked Questions
       This trigger is hidden
    • General Data Protection Regulation (GDPR)
      General Data Protection Regulation (GDPR)
       This trigger is hidden
    Results will update as you type.
    • What is JEMH Cloud?
    • App documentation
      • Getting started
      • Profiles
        • Creating Profiles
        • Profile Configuration
        • Profile Advisories
        • Project Mappings
          • Summary
          • Advisories
          • Project
          • Email only users
          • Security configuration
          • User configuration
          • Issue configuration
            • Custom Field Defaults
              • Using JavaScript to set custom fields
                • JavaScript examples
              • Using Velocity to set custom fields
            • Workflow Advance mappings
          • Attachments
          • Pre-Processing
          • Field Processors
          • Format configuration
          • Templates configuration
          • Rules configuration
        • Project Mapping Tester
        • Profile Auditing
      • Messaging
      • Global Exclusions
      • Notifications
      • Test Cases
      • Tools
      • Licensing
      • Auditing
      • Workarounds
      • Release Notes
      • Blog
      • Project Settings Configuration
      • Workflow Post Function Notifications
    • How-to articles
    • Common Problems
    • App licensing
    • General Data Protection Regulation (GDPR)
    • Maintenance Windows
    • Security
    • Notices
      Calendars
    You‘re viewing this with anonymous access, so some content might be blocked.
    {"serverDuration": 12, "requestCorrelationId": "afb0ece27a8641faaaeb11537571fe52"}