Can i automate a workflow so if i push the completed button it raises a new ticket?
Asked by Mate Major:

Hello,

I would like to have a workflow where if i click on 'Resolve' the ticket it automatically raises another issue. Is that possible in Jira Cloud?

Best

M?t?


Answers:
author: Mate Major
body: Allrighty so i have tried everything and it still doesnt work. Which variables would you need in order to make it work, could you maybe send a screenshot how the issue looks in the backend and then i can compare it to mine. Sorry for the many questions, im kind of a noob in this :)

Thanks a lot for all your help!


author: Alexey Matveev
body: Hello,

You would need an add-on for it.

For example, you could use the Power Scripts add-on:

[https://marketplace.atlassian.com/apps/43318/power-scripts-jira-script-automation?hosting=cloud\&tab=overview](https://marketplace.atlassian.com/apps/43318/power-scripts-jira-script-automation?hosting=cloud&tab=overview)

You could create a post function for the Resolve transition, which would create another issue. You can find an example of such a code here:

<https://confluence.cprime.io/display/SIL/createIssue>

comments: author: Mate Major
body: Thanks very much for your answer Alexey,

Could you maybe help me how to implement this exactly?

Im having trouble with it, it does not seem to work.

Thanks


author: Alexey Matveev
body: You need to install first the Power Scripts add-on. Then you need to add a post function to the transition, which leads to the Resolved status with a code like this:

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


author: Mate Major
body: Thanks a lot, however this code gives me an \<EOF\> error at line 18.


author: Alexey Matveev
body: Try like this:

string project = "TP";  
string parent_key = "";  
string issue_type = "Story";  
string issue_summary = "Sample Issue #";  
string priotity;  
string issue_description = "";  
string\[\] components;  
date dueDate;  
interval estimate;  
string securityLevel;  
string\[\] issue_fields_mapping;

<br />

string newIssue = createIssue(project, parent_key, issue_type, summary, priority, issue_description, components, dueDate, securityLevel, issue_fields_mapping);


author: Mate Major
body: Still gives an error :(

Error reads:   
Exception while executing SIL program \>\>create new issue\<\<: \[SIL Error on line: 14, column: 19\] null


author: Alexey Matveev
body: Some of the variable are empty in my script. I guess, you ve got some of the fields required. Try to fill variables with values.

string project = "TP";  
string parent_key = "";  
string issue_type = "Story";  
interval estimate;  
string securityLevel = "";  
string\[\] issue_fields_mapping;

<br />

string newIssue = createIssue(project, parent_key, issue_type, summary, priority, description, components, dueDate, securityLevel, issue_fields_mapping);


author: Mate Major
body: Ah okkay, and what would string parent_key mean in this case?


author: Alexey Matveev
body: If you create a sub task, you need to provide the key of the parent issue in this variable.


author: Mate Major
body: Okay so i understand now why it says null. Could you maybe help how to add values to the variables in the Create Issue bracket? IT doesnt let me do it and thats why it doesnt work.

Thanks a lot


Tags: cloud

confluence-cloud