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!
we have now solved it in such a way that we read the hidden preset value using an SQL query of the Jira db. This also works when you are in the process of creating the issue. You can also distinguish which project, task type and request type you are in if you have preconfigured the hidden preset value requesttype specifically.
If you work with a behavior, the hidden field may be visible for a short time or, in the event of an error, it may be permanently visible.
Kind regards matti
SELECT
p.pkey AS project_key,
p.pname AS project_name,
vp."NAME" AS service_desk_name,
CONCAT(LOWER(p.pkey), '/', vpform."KEY") AS customer_request_type_key,
vpform."NAME" AS customer_request_type_name,
vpfield."FIELD_ID" AS form_field_id,
vpfield."LABEL" AS form_field_label,
vpfield."FIELD_TYPE" AS form_field_type,
vpfield."REQUIRED" AS form_field_required,
vpfield."DISPLAYED" AS form_field_displayed,
STRING_AGG(vpfieldvalue."VALUE", ', ') AS form_field_default_values
FROM "AO_54307E_VIEWPORTFIELDVALUE" AS vpfieldvalue
INNER JOIN "AO_54307E_VIEWPORTFIELD" AS vpfield ON vpfieldvalue."FIELD_ID" = vpfield."ID"
INNER JOIN "AO_54307E_VIEWPORTFORM" AS vpform on vpfield."FORM_ID" = vpform."ID"
INNER JOIN "AO_54307E_VIEWPORT" AS vp ON vp."ID" = vpform."VIEWPORT_ID"
INNER JOIN project AS p ON vp."PROJECT_ID" = p.id
WHERE
vpfield."DISPLAYED" = false
GROUP BY p.pkey, p.pname, vp."NAME", vpform."KEY", vpform."NAME", vpfield."FIELD_ID", vpfield."LABEL", vpfield."FIELD_TYPE", vpfield."REQUIRED", vpfield."DISPLAYED";
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @mfabris
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!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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 .
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
"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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.