Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Info
titleAvailability

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)

...

Button handy
blanktrue
color#0052CC
nameSend Feedback
linkhttps://docs.google.com/forms/d/e/1FAIpQLScmToBe3vynAlb5fdKwCGxYqnTbDc66sIBgeecG2BuFDuHc7g/viewform?entry.2002826954=createIssue+-+15486180
widthauto

Table plus
applyColStyleToCelltrue
heading0
columnTypess,s,s,s
multiplefalse
columnAttributesstyle="background:#e5e7ea;font-weight:bold,,style="background:#e5e7ea;font-weight:bold,
enableSortingfalse

Syntax

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)  

Info

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

...

Package

Alias

Pkg Usage

Description

Excerpt
hiddentrue

Creates an issue based on the provided arguments.

Creates an issue based on the provided arguments.

Parameters

Table plus
applyColStyleToCelltrue
columnTypess,s,s,s
heading0
multiplefalse
enableSortingfalse

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.

Note

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

...

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

...

Return Type

String

The key of the created issue

...

...

Examples

Example 1

Code Block
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

Code Block
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

Code Block
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,

...

 

...

 

...

 

...

 

...

 

...

 

...

 

...

 

...

 

...

 

...

 

...

Will create an Improvement  with no components and the assignee set for user with the username "someUserName".

Example 4  (Cloud only)

...

 custom_fields_mapping
           

...

)

...

;
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)

...

Example 4

Code Block
JFieldValue[] cfMappings;
JFieldValue cfValues;
cfValues.fieldName = "

...

my_multi_

...

field";

...

for(int i=0; i<3; ++i) {
    string tempLabel = "my label " + i;
    string tempVal = "my value " + i;

    cfValues.values[i*2] = tempLabel;
    cfValues.values[i*2 + 1] = tempVal;
}
cfMappings += cfValues;
createIssue("JSD", "", "Task", "summaryyy", "", "", "", "", "", "", cfMappings);
print ("On the project " + project + ", issue " + k + "is created.");

Will create a Task, on the ‘JSD’ project, and will fill the ‘my_multi_field’ with 3 values (“my label 0”, “my label 1” and “my label 2”).

This is useful, for example if you have a field that allows multiple values to be selected (E.G. Power Custom Fields' - “PCF - Multi Select“.

Optionally, for Power Custom Fields, you can set the option’s value. If you don’t want the option’s value set, you can just use simple strings instead of the JFieldValue structure.

See also

Filter by label (Content by label)
showLabelsfalse
max25
showSpacefalse
cqllabel = "

...

issue_routine" and space = currentSpace ( )
labels

...

array_

...

routines