Versions Compared

Key

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

Button handy
blanktrue
color#0052CC
nameSend Feedback
linkhttps://docs.google.com/forms/d/e/1FAIpQLScmToBe3vynAlb5fdKwCGxYqnTbDc66sIBgeecG2BuFDuHc7g/viewform?entry.2002826954=Using+the+createIssue%28%29+Function+-+491001406
widthauto

Problem

Info

The createIssue() routine function takes the most arguments of any SIL routine 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.

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

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

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

Code Block
string [] custom_fields_mapping = {"checkbox", {"released", "accepted"}};
 
 
string newIssueKey = createIssue(    
    "DEMO",                 // project key    
    "",                     // parent key    
    "Task",                 // issuetype    
    "Summary goes here",    // summary   
 
    "",                     // priority    
    "",                     // description    
    "",                     // components    
    "",                     // due date    
    "",                     // estimate
    "",                     // security level  
    custom_fields_mapping   // custom fields mapping    
    );

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() routine 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.

Filter by label (Content by label)
showLabelsfalse
max5
spacescom.atlassian.confluence.content.render.xhtml.model.resource.identifiers.SpaceResourceIdentifier@135a7
sortmodified
showSpacefalse
reversetrue
typepage
cqllabel = "kb-troubleshooting-article" and type = "page" and space = "PKB"
labelskb-troubleshooting-article
Page Properties
hiddentrue

Related issues

We've encountered an issue exporting this macro. Please try exporting this page again later.