createIssue
- Service Account
- Jonathan Muse
- Elena Kolesnik
Looking for the documentation on the newest versions of SIL Engine and the Simple Issue Language for Jira 8 for Server/Data Center?Ā Click hereĀ !
Availability
This routine is available starting with katl-commons 1.0.
Syntax
createIssue(projectKey, parentIssueKey, issueType, issueSummary)
or
createIssue(projectKey, parentIssueKey, issueType, summary, priority, description, components, due date, estimate, security_level, custom_fields_mappings)
Starting with version 3.0.2
createIssue(projectKey, parentIssueKey, issueType, summary, priority, description, components, due date, estimate, security_level, field_mappings) Ā
Cloud Syntax
createIssue(projectKey, parentIssueKey, issueType, summary)
or
createIssue(projectKey, parentIssueKey, issueType, summary, priority, description, components, estimate, security_level, field_mappings)Ā Ā
To avoid conflicts regarding the custom field names, please use the custom field id instead of the name in the field_mappings. For some of the fields (eg: the fields provided by Jira Software, the set by name won't work at all).
Description
Creates an issue based on the provided arguments.Parameters
Parameter name | Type | Required | Description |
---|---|---|---|
projectKey | string | Yes | Key of the project, where the issue will be created, as it is saved in the Administration part. |
parentIssueKey | string | Yes | Key of the parent issue. Though the parameter is required, it can take an empty value to specify that the issue is not a sub-task, but a regular issue. |
issueType | string | Yes | Type of the issue that will be created. |
summary or issueSummary | string | Yes | Summary of the issue that will be created. |
priority | string | No | Priority. |
description | string | No | Description of the issue that will be created. |
components | array of strings | No | Components of the issue that will be created. |
due date | date | No | Due date of the issue that will be created. |
estimate | interval | No | Original estimate of the issue that will be created. Parameter is missing in the cloud version. |
security level | string | No | Security level of the issue that will be created. |
custom fields mappings/ field mappings (since version 3.0.2) | array of strings (or, an array ofĀ JFieldValue) | No | Mappings of the custom field of the issue that will be created. Starting with version 3.0.2 the mappings of the custom and system fields of the issue will be created. The more complex custom fields will be able to be mapped using the object JFieldValue. |
Return type
string (the key of the created issue)
Example
Example 1
string issue_priority;//Possible values: "Major", "Critical" etc. string issue_description; string[] issue_components; string issue_security_level; string[] custom_fields_mapping; issue_priority = "Critical"; issue_description = "Description of the issue"; issue_components = components; //an array containing all the components of the current project issue_security_level = "Administrator"; custom_fields_mapping = "STDUP|fmanaila|STDGP|jira-users"; string k = createIssue( "PROJECT", "PRJ-300", "Sub-task", "Summary of the sub task" , issue_priority, issue_description, issue_components, currentDate() + "30d", "1h 30m", issue_security_level, custom_fields_mapping ); print ("On the project " + project + ", issue " + k + "is created.");
Result: On the project PROJECT, issue PRJ-300 is created. Issue details are as declared above.
Example 2
string issue_priority;//Possible values: "Major", "Critical" etc. string issue_description; string issue_security_level; issue_priority = "Critical"; issue_description = "Description of the issue"; issue_security_level = "Administrator"; string k = createIssue( "PROJECT", "", // passing in empty to create a regular issue rather than subtask "Bug", "Summary of the sub task" , issue_priority, issue_description, {}, // no components currentDate() + "30d", "1h 30m", issue_security_level, {} // and no custom field mappings ); print ("On the project " + project + ", issue " + k + "is created.");
Will create a Bug with no components and no special custom field values (all defaults).
Example 3
string issue_priority;//Possible values: "Major", "Critical" etc. string issue_description; string issue_security_level; string[] assigneeUser; issue_priority = "Critical"; issue_description = "Description of the issue"; issue_security_level = "10000"; assigneeUser = "assignee|someUserName"; string k = createIssue( "PROJECT", "", // passing in empty to create a regular issue rather than subtask "Improvement", "Summary of the sub task" , issue_priority, "", {}, // no components currentDate() + "30d", "1h 30m", issue_security_level, assigneeUser ); print ("On the project " + project + ", issue " + k + "is created.");
Will create an ImprovementĀ with no components and the assignee set for user with the username "someUserName".
Example 4Ā (Cloud only)
string issue_priority;//Possible values: "Major", "Critical" etc. string issue_description; string issue_security_level; string[] assigneeUser; issue_priority = "Critical"; issue_description = "Description of the issue"; issue_security_level = "10000"; assigneeUser = "assignee|someAccountId"; string k = createIssue( "PROJECT", "", // passing in empty to create a regular issue rather than subtask "Improvement", "Summary of the sub task" , issue_priority, "", {}, // no components currentDate() + "30d", issue_security_level, assigneeUser ); print ("On the project " + project + ", issue " + k + "is created.");
Will create an ImprovementĀ with no components and the assignee set for user with the username "someUserName".
For more complex custom fields like the ones describedĀ here in the section Setting custom field data for other field types, for exampleĀ CascadingSelectField that has a structure like
"customfield_10001": {"value": "green", "child": {"value":"blue"} }
orĀ MultiUserPicker that has a structure like
"customfield_10009": [ {"name": "charlie" }, {"name": "bjones" }, {"name": "tdurden" }]
we have made an object JFieldValue that you can find inĀ predefined structure types . With it we can define what we could not with just a stringĀ [].
Example 5Ā (Cloud only)
JFieldValue simpleStringCF; JFieldValue simpleNumberCF; JFieldValue selectList; JFieldValue multiselect; JFieldValue cascadingSelect; JFieldValue groupPicker; JFieldValue multiGroupPicker; JFieldValue projectByKey; JFieldValue projectById; simpleStringCF.fieldName = "customfield_10041"; simpleStringCF.values[0] = "some string"; simpleNumberCF.fieldName = "customfield_10033"; simpleNumberCF.values[0] = 12.34; selectList.fieldName = "customfield_10040"; selectList.values[0] = "option 1"; multiselect.fieldName = "customfield_10038"; multiselect.values[0] = "option 1"; multiselect.values[1] = "option 2"; multiselect.values[2] = "option 3"; cascadingSelect.fieldName = "customfield_10046"; cascadingSelect.values[0] = "option 2"; cascadingSelect.values[1] = "2.b"; groupPicker.fieldName = "customfield_10036"; groupPicker.values[0] = "administrators"; multiGroupPicker.fieldName = "customfield_10044"; multiGroupPicker.values[0] = "administrators"; multiGroupPicker.values[1] = "jira-administrators"; projectByKey.fieldName = "customfield_10050"; projectByKey.values[0] = "TESTPRJ"; //this will overwrite the one by key projectById.fieldName = "customfield_10050"; projectById.values[0] = "10100"; JFieldValue[] mapping; mapping[0] = simpleStringCF; mapping[1] = simpleNumberCF; mapping[2] = selectList; mapping[3] = multiselect; mapping[4] = cascadingSelect; mapping[5] = groupPicker; mapping[6] = multiGroupPicker; mapping[7] = projectByKey; mapping[8] = projectById; string key = createIssue("TESTPRJ", "", "Task", "summary", "", "", "", "", "", mapping); return key;
See also
-
Page:
-
Page:
-
Page:
-
Page:
-
Page:
-
Page:
-
Page:
-
Page:
-
Page:
-
Page:
-
Page:
-
Page:
-
Page:
-
Page:
-
Page: