Using the createIssue() Routine

Problem

The createIssue() function takes the most arguments of any SIL function and the easiest to create syntax errors. The examples here are intended to make the process of creating a script using createIssue() as easy as possible.

Solution - The Easy Way

When testing a script with createIssue(), start with the least amount of arguments.

string newIssueKey = createIssue(     "DEMO",      "",      "Task",      "Summary goes here" );   if (isNotNull(newIssueKey)){     runnerLog("Issue " + newIssueKey + " was created."); } else {     runnerLog("An issue was not created"); }

Adding Custom Field Information After Issue Creation

After you have created the issue, then you can add values to custom fields as you would normally. See the "Variable Resolution" documentation page on how to set custom fields.

%newIssueKey%.#{custom field name here} = "string value goes here";

Custom Field Mapping

While the method above tends to be easier to implement, doing everything at once is easier to read. 

One of the trickiest createIssue() arguments (and most prone to error) is the custom field mapping. Keep in mind that the custom field mapping argument is intended to accept key/value pairs such as the following example. Let's say I have a custom field named "textField" and another with the id of "1234". You can set those values using the following:

string [] custom_fields_mapping = "textField|text value here|customfield_1234|jira-users";

If you wish to pass an array value to a custom field, pass it using the curly braces to denote an array.

I find it helps to place each argument on a separate line with the comment for each one to keep each argument straight.

createIssue() in the Cloud

The arguments for the createIssue() function are exactly the same, except there is no argument for the due date.

Additional Help

Need help implementing this script? Talk to me directly to me by clicking on the bot on this page.

Related articles

Filter by label

There are no items with the selected labels at this time.

Peacock