Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,552,334
Community Members
 
Community Events
184
Community Groups

Get the value of hidden fields with preset value in request form using JIRA behaviour.

Hello Community, @Hana Kučerová 

I am trying to set a behavior by getting a value of custom field (which is hidden and has a preset value, in customer form), but sadly unable to achieve the same.

I have a custom field - location which is hidden and the value is preset to say 'ABC' for a request type.

I want to achieve that for all the request type which have location set to 'ABC', certain fields should be visible in customer request form, else if location is not ABC then dont show up in request form.


my code is - 

def customfield = getFieldbyID("customfield_12")

def cfval = customfield.getvalue()  {also tried cfval = customfield.getvalue()  as string}

if (cfval == ABC) {

desciption.setHidden(false)

.

.

.

}

else true

 

Can you suggest if this is the correct approach.

Thanks!

2 answers

Hello @Harsh,
I have the same problem in theory. Have you made any progress here? Currently I have not found a way to read the hidden preset value in a behaviour. The special feature is that I am in create and therefore cannot use methods based on event or issue (because there is no issue yet).


I have a custom field as hidden with a preset value depending on the IssueType.

 The customfield is however available, as other customfields referencing it work, but it is not usable for JQL and is hidden in the view screen.

Best regards Matti

Hello @Matti Dennstaedt 

 

Yes. What I did is, I called the individual request type where I want to hide the fields explicitly and hid the fields. 

Instead of using the hidden custom field. 

I hope this helps. 

 

Thanks! 

0 votes
kjfqw094u
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.
Apr 12, 2023

Maybe like this:

 

def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()

def name = user.displayName

 

if (getActionName() == "Create") {

    def customfield = getFieldById("customfield_12")

    def customfieldToBeHidden = getFieldById("customfield_34")

    def cfval = customfield.getValue()

 

    if (cfval == "ABC") {

        customfieldToBeHidden.setHidden(true)

    } else {

        return null

    }

}

This would work on the "create" form and should be added to the "initialiser" section in your form. 

 

Good luck, I hope it does the job. 

Hi @kjfqw094u 

I already tried this but unfortunately it did not work. Is there any other way we can achieve this.

I think the issue is since the field in hidden with preset value in request type, it is not able to get up the value.

Thanks!

kjfqw094u
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.
Apr 13, 2023

well but it depends.. what do you mean by hidden?

because actually my code here is a bit silly... the issue does not exist yet, so it has no field filled, neither visible nor hidden.

Or are you talking about making a dynamic form? 

A little background, I have 2 issue type Info, Req

For issue type Info, when you go in request type(create a request type), and then in edit fields there is an option to hide fields from customer request form with preset value(eg XYZ). I have done this for issue type Info

Now I want to show some extra field using behavior for all the issue type Info where the hidden preset value of the custom field in XYZ.

I hope this helps.

Thanks.

kjfqw094u
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.
Apr 14, 2023

MMm let's try to use the right wording here. 

So you have one issue type in your Jira Project, which is mapped to two request types in the Jira Service Management portal.

For the request type "Info" you are showing all the fields apart from one specific one that you keep hidden (let's call it "field 1"), and you have mapped a default value to this field when one of these request types gets submitted.

For the request type "Req" instead you not only show the  "field 1", but you would also like to show additional fields, is this the case? 

 

If this is the case, the behavior will not work because the value for "Field 1" does not exist until the ticket is submitted and created.

But you can add the additional fields to the issue type screen, and just hide them from "Info" and show them just on "Req", like you do for "field 1".

 

If i have not understood, please explain again, I am happy to help if I can .

"For the request type "Info" you are showing all the fields apart from one specific one that you keep hidden (let's call it "field 1"), and you have mapped a default value to this field when one of these request types gets submitted."

- This part is correct. 

 

Now for the request type 'Info', i want to show additional field based on hidden 'field 1' default value. 

But i got your point for the field not being existed until it's is created. That's a totally valid point. 

 

So as a workaround I'll directly get request type name using behaviour and show/hide fields. Is this approach valid? I hope it works. Also adding fields only on req type which i want to and hiding from other would also work. 

Thank you for the suggestion. It was a great help. 

Suggest an answer

Log in or Sign up to answer