Just a bit of background on me: I've been programming/scripting for 20 years, starting with C+ (forgot all of it) and currently consider myself advanced with PowerShell. No Groovy/Java experince.
Background on task: We have a security form that has 4 potential assignee's. I has approvers so I need to break it down into sub-tasks with each subtask having an approver. Instead of someone creating a subtask for each person I decided to automate it.
My automation got out of hand. So I have a script that figures out who needs a subtask based on the form that was submitted, but if I do something like this in the future, I would like to figure out how to simplify it.
Could someone take a look?
{% if issue.fields.customfield_10121 | find({"value":"Windows"}) != null %}
{% if issue.fields.customfield_10121 | find({"value":"Oracle"}) != null %}
{% if issue.fields.customfield_10121 | find({"value":"Phone"}) != null %}
{% if issue.fields.customfield_10121 | find({"value":"Jira"}) != null %}
NT Sub-task,Oracle Sub-Task,Phone Sub-task,Jira Sub-task
{% else %}
NT Sub-task,Oracle Sub-Task,Phone Sub-task
{% endif %}
{% elif issue.fields.customfield_10121 | find({"value":"Jira"}) != null %}
NT Sub-task,Oracle Sub-Task,Jira Sub-task
{% else %}
NT Sub-task,Oracle Sub-Task
{% endif %}
{% elif issue.fields.customfield_10121 | find({"value":"Phone"}) != null %}
{% if issue.fields.customfield_10121 | find({"value":"Jira"}) != null %}
NT Sub-task,Phone Sub-task,Jira Sub-task
{% else %}
NT Sub-task,Phone Sub-task
{% endif %}
{% elif issue.fields.customfield_10121 | find({"value":"Jira"}) != null %}
NT Sub-Task,Jira Sub-task
{% else %}
NT Sub-task
{% endif %}
{% elif issue.fields.customfield_10121 | find({"value":"Oracle"}) != null %}
{% if issue.fields.customfield_10121 | find({"value":"Phone"}) != null %}
{% if issue.fields.customfield_10121 | find({"value":"Jira"}) != null %}
Oracle Sub-task,Phone Sub-task,Jira Sub-task
{% else %}
Oracle,Phone Sub-task
{% endif %}
{% elif issue.fields.customfield_10121 | find({"value":"Jira"}) != null %}
Oracle,Jira Sub-task
{% else %}
Oracle
{% endif %}
{% elif issue.fields.customfield_10121 | find({"value":"Phone"}) != null %}
{% if issue.fields.customfield_10121 | find({"value":"Jira"}) != null %}
Phone Sub-task,Jira Sub-task
{% else %}
Phone Sub-task
{% endif %}
{% else %}
Jira Sub-task
{% endif %}Just so you know, my brains are mush after keeping everything in mind, but it works!
Source I used to start this: 3. Configuring Post Functions (innovalog.com)