Create an issue of a certain issue type when there is no Create permission
Required apps
Level: INTERMEDIATE
Problem
Some Jira users must have the permission to create issues of a certain issue type and some others must have the permission to create issues or sub-tasks of another issue type and all this must happen in the same project.
Solution
Creating the actions
Scripting through SIL™ is very powerful and now we have Blitz (Power) Actions™ Custom Field to solve this problem, using it together with the permissions and issue type schemes of the project.
Let's consider the case we have an issue type which support two sub-tasks types, like in this issue type schema:
There are two or more users, one of them - let's say userba - has the permission to create issues in the project and another, usertest, does not have this right but must create sometimes a Blitz Sub-Task. Both users belong to the same group, named ForBA Sub-Task.
We can get the work done, by using a Blitz Actions customfield in the View screen of BlitzAction Task and configuring it.
First we create the actions:
Note that userba will be allowed to create any kind of sub-task, while usertest will be allowed to create only Blitz Sub-Tasks.
Condition Scripts
And now let's write the SIL™ scripts.
- the condition for the first action is
number ENABLED = 1; number DISABLED = 2; number HIDDEN = 3; if (hasPermission(11, currentUser(), key) or userInGroup("ForBA Sub-Task", currentUser())) return ENABLED; else return HIDDEN;
- the condition for the second action is
number ENABLED = 1; number DISABLED = 2; number HIDDEN = 3; if (hasPermission(11, currentUser(), key)) return ENABLED; else return HIDDEN;
Screen Scripts
Assuming screens for both actions look the same (both sub-tasks types has the same fields). In this example only Summary and Description for the new created sub-tasks are completed, but obviously all needed fields can be mapped.
string TEXT = "TEXT"; string TEXT_DISABLED = "TEXT_DISABLED"; string[] scr = {"Summary", "TEXT", "Test create BA sub-task", "Description", "TEXT"}; scr = addElement(scr,""); return scr;
or (note that the only difference is the Summary text):
string TEXT = "TEXT"; string TEXT_DISABLED = "TEXT_DISABLED"; string[] scr = {"Summary", "TEXT", "Test create simple sub-task", "Description", "TEXT"}; scr = addElement(scr,""); return scr;
Action Scripts
And, finally, the two action scripts which will create the sub-task; Tasks are created with reporter set to the current user (irrespective of the permissions!) and with the assignee to current assignee.
- for Blitz Sub-Task and
string prt; string[] cmp; date ddate; string est; string sl; string[] cfmap; string k; string us=currentUser(); if (not hasPermission(11, currentUser(), key)) { runAs("userba"); //simulate } k=createIssue(project, key, "Blitz Sub-Task", getElement(argv, 1),prt,getElement(argv, 3),cmp,ddate,est,sl,cfmap); runAs(us); //go back to the real user %k%.reporter=currentUser(); %k%.assignee=assignee;
- for the ordinary Sub-Task
string prt; string[] cmp; date ddate; string est; string sl; string[] cfmap; string k; k=createIssue(project, key, "Blitz Sub-Task", getElement(argv, 1),prt,getElement(argv, 3),cmp,ddate,est,sl,cfmap); %k%.reporter=currentUser(); %k%.assignee=assignee;
Testing
That's all! Now let's have it tested.
The first user who test the results is userba, who has permission to create sub-tasks of any of the two types.
Second user to test, usertest, who does not have permission to create issues in the current project, still may create a Blitz Sub-Task, due to Blitz(Power) Actions custom field configured through SIL™ to run the action script as userba (using the runAs routine)
See also
- Block 'Close' Transition Until All Subtasks are Closed
- Copy the reporter and watchers on duplicate issues
- Forbidding specific priorities for certain projects
- Restricting resolutions based on issue type
- Restrict sub-tasks based on Issue Type