# UI for Creating a New Jira Issue

While the Jira Integration Framework can have rules that automatically route a record over into a Jira Issue, sometimes it is desired that the user can create a new Jira issue with some basic required fields that are pulled live from Jira.  In those cases, the framework can provide a User Interface for that stage of the creation.&#x20;

## Implementation Steps

### STEP 1: Create a UI Action on the Table

**Name:** \
Choose your own wording (eg. Create Jira Issue)

**Table:**\
Choose a table that you want this control to be present on (eg. "Incident \[incident]")

**Action name:**\
save\_and\_redirect\_page\_to\_form

**Client:**\
true

**Click the checkbox on at least one of the following "Control" fields:**

* Form button
* Form context menu
* Form link
* List bottom button
* List context menu
* List choice
* List link

**Onclick:**\
startClientSideOfProcess()

**Show update:**\
Depends on your use case.  Typically, this would be "true"

**Show insert:**\
Depends on your use case.  Typically, this would be "true"

**Condition:**\
Paste the following code snippet into your condition field.\
\&#xNAN;*<mark style="color:red;">IMPORTANT: change the string, "TODO-INSERT-INTPOINTCODE", with the webhook code from your integration point that you are using for this particular use case.</mark>*

```javascript
!x_yala_jira.IntegrationCommonHelper.recordIsLinkedToJira(current) && x_yala_jira.JiraIssueCreationInterfaceUtil.isSupportedSourceTable(current.getTableName(), "TODO-INSERT-INTPOINTCODE")
```

**Script:**\
Paste the following code snippet into your script field.  \
\&#xNAN;*<mark style="color:red;">IMPORTANT: change the string, "TODO-INSERT-INTPOINTCODE", with the webhook code from your integration point that you are using for this particular use case.</mark>*

```javascript
function saveAndRedirectPageToForm() {
    var intPointCode = "TODO-INSERT-INTPOINTCODE";
    var lib = 'UI Action';
    var func = 'Create Jira Issue';
    var logger = new x_yala_jira.SystemLogHelper(true);
    
    try {
        logger.info(lib, func, 'ENTERING');
        current.update();
        logger.debug(lib, func, "intPointCode: " + intPointCode);
        var referrer = current.getTableName() + ".do?sys_id=" + current.sys_id;
        logger.debug(lib, func, "referrer: " + referrer);
        action.setRedirectURL("/$sp.do?id=jira_new_issue&source_table=" + current.getTableName() + "&source_sysid=" + current.sys_id + "&intPoint=" + intPointCode + "&referrer=" + referrer);
    } catch (e) {
        logger.reportException(lib, func, e);
    } finally {
        logger.info(lib, func, 'LEAVING');
        logger.writeCumulativeEntries(true);
    }
}
if (typeof window == 'undefined') {
    saveAndRedirectPageToForm();
}

function startClientSideOfProcess() {
    if (typeof g_modal == "undefined") {
        gsftSubmit(null, g_form.getFormElement(), 'save_and_redirect_page_to_form');
    }
};
```

On the **Workspace** section on the form, do the following:

**Workspace Form Menu:**\
true

**Workspace Client Script:**\
Paste the following code snippet into your script field.  \
\&#xNAN;*<mark style="color:red;">IMPORTANT: change the string, "TODO-INSERT-INTPOINTCODE", with the webhook code from your integration point that you are using for this particular use case.</mark>*

```javascript
function onClick(g_form) {
    var intPointCode = "TODO-INSERT-INTPOINTCODE";
    var tableName = g_form.getTableName();
    var sysId = g_form.getUniqueValue();
    g_modal.showFrame({
        url: '/$sp.do?id=jira_new_issue&source_table='+tableName+'&source_sysid='+sysId+'&referrer=&intPoint='+intPointCode,
        title: 'New Jira Issue',
        size: 'lg',
        height: 500
    });
}
```

If desired, you may also set up the "**Requires role**" section of the form.  Also, you might consider any "**UI Action Visibility**" rules as well.

### STEP 2: Configure your Integration Point Settings

Navigate to the integration point associated with the UI Action you created above. Add/modify the following settings:

#### Setting #1: Additional fields to include on the New Issue Form

*CSV list of fields to include on the New Jira Issue Form. These are Jira field IDs.*

| Field                 | Value                                                    |
| --------------------- | -------------------------------------------------------- |
| **Name**              | new\_issue\_form.additional\_fields                      |
| **Type**              | Large String                                             |
| **Short Description** | Additional fields to include on the New Issue Form       |
| **Large String**      | *{enter any Jira field IDs in a comma separated format}* |

#### Setting #2: Issue Type ID for Epics

*If your integration involves issues types that represent Jira epics, you will want to include a setting for that here.* &#x20;

| Field                 | Value                                                             |
| --------------------- | ----------------------------------------------------------------- |
| **Name**              | epic\_issuetype\_id                                               |
| **Type**              | Short String                                                      |
| **Short Description** | Epic IssueType ID                                                 |
| **Short String**      | *{enter any issue type ID value that represents an epic (eg. 5)}* |

#### Setting #3: Default User for Unknown External Owner

*If you want some kind of ownership of a Jira issue, but the external owner can not be resolved, what user sys\_id should be used*

| Field                 | Value                                                                                  |
| --------------------- | -------------------------------------------------------------------------------------- |
| **Name**              | ext\_owner\_sysid\_for\_unknown                                                        |
| **Type**              | Short String                                                                           |
| **Short Description** | Sys ID value for a user record when no record can be matched between Jira & ServiceNow |
| **Short String**      | *{sys\_id of the user record}*                                                         |

#### Setting #4: Supported Issue Types

*If you desire to limit the issue types that can be assigned through the New Jira Issue interface, you should add those issue types here.*

<table><thead><tr><th width="202">Field</th><th>Value</th></tr></thead><tbody><tr><td><strong>Name</strong></td><td>supported_issue_types</td></tr><tr><td><strong>Type</strong></td><td>Large String</td></tr><tr><td><strong>Short Description</strong></td><td>Supported Issue Types</td></tr><tr><td><strong>Short String</strong></td><td><em>{csv of Jira Issue Type ids (eg. 2</em>,1,4,10200)<em>}</em></td></tr></tbody></table>

#### Setting #5: Supported Source Tables

*To define which tables the Create Jira Issue feature is supported on, enter the table names in csv format in this setting.*

<table><thead><tr><th width="202">Field</th><th>Value</th></tr></thead><tbody><tr><td><strong>Name</strong></td><td>supported_source_tables</td></tr><tr><td><strong>Type</strong></td><td>Large String</td></tr><tr><td><strong>Short Description</strong></td><td>Supported Source Tables</td></tr><tr><td><strong>Short String</strong></td><td><em>{csv of table names (eg. incident,incident_task)}</em></td></tr></tbody></table>

#### Setting #6: Flow to execute on submitting the new Jira Issue Form

*Once the new Jira issue form is filled out, the component will kick off a flow.  This settings specifies what that flow is that will be executed.*&#x20;

| Field                 | Value                                                                                                          |
| --------------------- | -------------------------------------------------------------------------------------------------------------- |
| **Name**              | new\_issue\_form.flow\_to\_execute\_on\_submit                                                                 |
| **Type**              | Reference                                                                                                      |
| **Short Description** | Flow to execute on submitting the new Jira issue form                                                          |
| **Reference Record**  | *{Table: "Flow \[sys\_hub\_flow]", Record: ${the subflow to trigger when submitting the new Jira Issue Form}}* |

### Step 3: Create your Subflow

#### Flow inputs

| Input               | Description                                                                                                                                                                           |
| ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| source\_record      | GlideRecord of the source table                                                                                                                                                       |
| linked\_record      | Reference to the **Jira Record Linkage** table                                                                                                                                        |
| additional\_payload | A string that will contain JSON data of additional parameters for the Jira Issue                                                                                                      |
| current\_user       | A string that will have the sys\_id of the user triggering the creation                                                                                                               |
| external\_owner     | A string that will have the sys\_id of the ServiceNow user that owns the record.  (Note: while this needs to be an input in the flow, it does not necessarily have to be implemented) |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.yansalabs.com/jira-integration-framework/technical-docs/available-components/ui-for-creating-a-new-jira-issue.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
