Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to make custom field appear on screen based on issue type

Manoj
Contributor
December 19, 2022

Hi, 

How to make custom field appear on screen based on issue type,  for example I have 5 issue types and all have one screen configuration but now there is change request,  when user select issue type incident then along with other custom field i need to make due date mandatory on screen and incident type (custom field)  which has drop down list p1 p2 so on appear on the screen. 

Any suggestion pls

 

2 answers

1 accepted

0 votes
Answer accepted
Vamsi Kandala
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 19, 2022

Hi @Manoj

I agree with @Dave Mathijs

But, if you think that you will have to make so many changes to accommodate the new change request and if you have ScriptRunner installed in your instance, you can try this using 'Behaviors'.

Hope this helps.

Thanks,
Vamsi

Manoj
Contributor
December 19, 2022

Hello @Vamsi Kandala Thanks for replying back to me, i really like the response. 

yes i do have ScriptRunner installed but that sound me a new thing which i have very less knowledge, how i can use "Behaviors" (i am going to read about it), any steps you can mention here ? or you can explain it in hypothetical way. 

i will look  forward for your response further. 

Take care!

 

Thanks 

M

Manoj
Contributor
December 20, 2022

@Vamsi Kandala Hello, I am glad to share that i have used scriptRunner to achieve this change request, its working fine!

Vamsi Kandala
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 20, 2022

Hi @Manoj

Sounds good.  I am sorry that I could not check your response and reply earlier.  Glad that you are able to figure it out.

Behaviors is a very useful tool which can be used for many functionalities.

Thanks,
Vamsi

Manoj
Contributor
December 20, 2022

@Vamsi Kandala  Hello, Hope you are fine!

yesterday i tried working in pre-prod and everything worked fine whereas today i have implemented the same thing in prod now it is working partially, fields are appearing based on issue type selected but not becomes mandatory* field.

this is what the script is, and custom field 15780 is due date. 
if (issueContext.issueType.name == "Incident") {
   
   getFieldById("customfield_15870").setRequired(true)
 getFieldById("Incident Priority").setRequired(true)
any idea where is the gap in my work.
Thanks
Vamsi Kandala
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 21, 2022

Hi @Manoj

I am doing good.  Hope you are doing good as well.

In the script, can you replace:

getFieldById("Incident Priority").setRequired(true)

In the above code 'getFieldById' expects the id of the custom field and not the name.  Can you replace 'Incident Priority' with its custom field id and try?

Thanks,
Vamsi

Manoj
Contributor
December 21, 2022

@Vamsi Kandala Thanks for replying me back, can you believe its working i just replaced as you have mentioned above, Kudos to you! 

could you guide me how to get into in ScriptRunner part, and i believe groovy is the base of it, btw i dont know anything about groovy language, could pls tell me how i can give a start into it? 

hope i am taking your too much time. 

Vamsi Kandala
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 22, 2022

Hi @Manoj

Glad that you are able to work it out.

There is plenty of useful documentation for ScriptRunner at their web site: https://www.adaptavist.com/products/atlassian-apps/new-documentation-scriptrunner with examples.

Hope this helps.

Thanks,
Vamsi

Like Manoj likes this
Manoj
Contributor
January 3, 2023

@Vamsi Kandala hello, Happy new year, thanks for sharing above link, it is helpful.

I have to task, i want to create kanban task with pre-defined subject line, and this get created in every 2 months. how do i get this done via script? Kindly suggest.

Vamsi Kandala
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 3, 2023

Hi @Manoj ,

Thank you, Happy New Year to you as well.

If I understand correctly, you want to create a Kanban task automatically every two months.

If that is so, you can user 'Automation rules' with the trigger as 'Scheduled'.  Then you use cron expression to define when you want to create the ticket and how frequently.  More documentation and examples can be found here: https://support.atlassian.com/jira-software-cloud/docs/construct-cron-expressions-for-a-filter-subscription/

Then use the 'Create issue' option for 'New action' component.

Hope this helps.

Thanks,
Vamsi

Like Manoj likes this
Manoj
Contributor
January 12, 2023

@Vamsi Kandala Hello, Hope you are good.

 about that due date mandatory, now it becomes mandatory for all issue types in project, as in my absense another project interrupt setting. now i want to make due date mandatory only for 2 issue types. any suggestion pls.

Vamsi Kandala
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 12, 2023

Hi @Manoj

I am doing good and hoping the same with you as well.

You can use the ScriptRunner Behaviors to set the field as mandatory by adding the project mapping to the related project and for the specific issue types only.

Hope this helps.

If you need further assistance, I can send you the steps about how to do this.

Regards,
Vamsi

Manoj
Contributor
January 13, 2023

@Vamsi Kandala I am also keeping well, Thanks for asking. 

on your given solution, i have tried this and working now :) what i missed earlier is that, i use all issue types and missed to recollect as earlier i read somewhere that the issue types only to be used which we want to have some behavior. 

Also, 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 autofilled.

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

Manoj
Contributor
January 25, 2023

@Vamsi Kandala Hello, hope you are good! 

any suggest on above query.

Vamsi Kandala
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 25, 2023

Hi @Manoj

I am doing good.  How are you?

Sorry, I missed your earlier comment.

If you are familiar with Behaviors, you can write the script for by selecting the field which should trigger the changes.  In this case, it would be 'customfield_122321'.

Then try adding this code and see if that works:

def cfSpecificRole = getFieldById("customfield_122321")
def cfStandardizedRole = getFieldById("customfield_23601")
def cfBroaderCategory = getFieldById("customfield_24652")
def cfNextLevelCategory = getFieldById("customfield_24254")

if (cfSpecificRole.getValue() != "") {

    cfStandardizedRole.setFormValue(cfSpecificRole.getValue());

    cfBroaderCategory.setFormValue(cfSpecificRole.getValue());

    cfNextLevelCategory.setFormValue(cfSpecificRole.getValue());

}

Hope this helps.

Thanks,
Vamsi

Manoj
Contributor
January 25, 2023

@Vamsi Kandala Thanks for your reply, I just tried above given script, but unfortunately it is not working properly, for example- when i select backend developer (in specific role)

then standardized role filled up but broader & next level category does not show the value.

Vamsi Kandala
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 25, 2023

Hi @Manoj

I have tested at my end and it is working.

Can you send me the complete script code if you don't mind?

Thanks,
Vamsi

Manoj
Contributor
January 25, 2023

@Vamsi Kandala Hi am not much familiar with behaviours (willing to learn) 

but here is the script i am using. Not even sure whether its completed or not.

 

import com.atlassian.jira.component.ComponentAccessor

def cfSpecificRole = getFieldById("customfield_23606")
def cfStandardizedRole = getFieldById("customfield_23605")
def cfBroaderCategory = getFieldById("customfield_24652")
def cfNextLevelCategory = getFieldById("customfield_24654")

if (cfSpecificRole.getValue() != "")
{

    cfStandardizedRole.setFormValue(cfSpecificRole.getValue());

    cfBroaderCategory.setFormValue(cfSpecificRole.getValue());

    cfNextLevelCategory.setFormValue(cfSpecificRole.getValue());

}
Manoj
Contributor
January 25, 2023

@Vamsi Kandala what i realized is, i need to make the roles dependent at the backend (dont know how).

like Specific role - Standard role- broader category- next level category

"Developer-BE"-"Developer"-"Development"-Developer"

"DevQA Auto"-"DevQA"-Development"-QA",  

and to project like above in scrip, so that if i select Developer-BE in specific field then rest of the fields pops up.

4 votes
Dave Mathijs
Community Champion
December 19, 2022

HI @Manoj ,

First of all, you need to split the issue operation screens (create, edit, view) per issue type and configure them in the Issue Type Screen Scheme.

Then you need to create a separate Field Configuration per issue type and configure these in the Field Configuration Scheme.

Finally, make the designated fields required in the Field Configuration for that issue type.

Manoj
Contributor
December 19, 2022

Hello @Dav 

Thanks for replying back to me with solution however this required a lot of changes to perform as each issue type has single field configuration in my case and is there any work around to avoid such changes? kindly suggest.

Suggest an answer

Log in or Sign up to answer