Auto pick custom fields based on 1 field (dependent custom field) scriptrunner

Manoj January 25, 2023

 Hi All,

I have few custom fields which i want to automate, if i fill the inputs in one custom field then based on first first field, rest few fields get autofill.

for example- am running an hr project and in which i have specific role, standard role and broader role 

so specific role- backend developer, standard role - developer, broader role - development.

How would i start putting in script runner/behavior ? could you pls suggest.

 

So far i have learnt is below :

import com.atlassian.jira.component.ComponentAccessor

def cfSpecific Role = getFieldById("customfield_122321")
def cfStandardized role = getFieldById("customfield_23601")
def cfBroader Category = getFieldById("customfield_24652")
def cfNext Level Category = getFieldById("customfield_24254")

2 answers

0 votes
Ram Kumar Aravindakshan _Adaptavist_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 28, 2023

Hi @M

Sorry for the delay in responding. Was really busy these couple of weeks.

For your requirement, you can use a Server-Side Behaviour for the first field and update the other field values accordingly.

I have given a similar solution in this Community Post.

I can provide a better solution if you could provide more information on the field types and which field you want to trigger the Behaviour.

Thank you and Kind regards,
Ram

Manoj March 1, 2023

Hello Ram, 

No sorry pls, but thanks taking out time to reply me back.  

While you took time to reply, it gave me an opportunity to explore and learn, Also i have checked your community post, which in fact helped as well.

Now, i have another requirement to modify existing workflow for the scrum team. 

There are 12 issues types which has 1 Issue type is "Story", when someone create "Story" it will automatically create Sub-tasks. i know this can be done via post function, could you pls guide me little bit achieve this change request. 

These are the Sub-Tasks which needs to be created when story created. 

  1.  Development
  2. Unit Test
  3. Code Review
  4. Pre-Prod Deployment
  5. E2E-QA
  6. Release Documentation
Ram Kumar Aravindakshan _Adaptavist_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 9, 2023

Hi @M

There are multiple approaches to solving this requirement.

Firstly if you want to create different types of sub-tasks simultaneously, you can follow the steps in this Community Post.

The second approach you can use is to use ScriptRunner Create Sub-Task post-function. You must add multiple copies of this post-function, i.e. each for one of the Sub-Tasks types.  

The third approach will be using the very simple code now doable using ScriptRunner's HAPI feature. You can refer to this Adaptavist Library sample code.

Please note to use the HAPI feature; you must upgrade your ScriptRunner plugin to the latest release, 7.12.0

Thank you and Kind regards,

Ram

Manoj March 10, 2023

@Ram Kumar Aravindakshan _Adaptavist_  Hello, Thanks for helping here, 

i have used ScriptRunner Create Sub-Task post-function. to accomplish the given task but the thing i observed, the leaver Jira Admin use the same transitions when tickets created and moved to start in progress, and also in the transition when tickets get reopened and status back in start in progress, so to simply when ticket created (issue story type) and transit to "start in progress" then all sub-tasks created but tickets get reopened and again same sub-tasks get created. any suggestion? or i do need to break the workflow step and set new function for then tickets get re-open?

 

this is new for me HAPI feature. You can refer to this Adaptavist Library sample code., will explore this too.

0 votes
Manoj January 25, 2023

@Ram Kumar Aravindakshan _Adaptavist 

Hello, could you pls guide. 

Suggest an answer

Log in or Sign up to answer