Forums

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

How to Dynamically Retrieve Form Field Values in Jira Service Management

川目 沙英 December 2, 2024 edited

Jira Service Managementで自動化ルールを作成して、フォームフィールドの値を取得しようとしています。現在、UUIDが指定されている場合、次のスマート値を使用してフィールド値を取得できます:
{{issue.forms.."フォームフィールド名".label.first}}

さらに、次のスマート値を使用してUUIDを動的に取得できることを確認しました。
proforma.forms".forms.first.uuid}}

しかし、動的に取得したUUIDを組み合わせてフォームフィールドの値を取得するのに問題があります。たとえば、次の試みは期待どおりに機能しませんでした:{{issue.forms.{{issue.properties."proforma.forms".forms.first.uuid}}."PCRequired".label.first}}

また、REST APIを使用してフォームフィールドの値を動的に取得することも検討しています。誰かが特定の手順やコード例を提供していただければ、非常に役立ちます。以下のようなAPIエンドポイントの使用を検討していますが、詳細がわかりません:
https://api.atlassian.com/jira/forms/cloud/{cloudid}/issue/{{issue.キー}}/form/{{issue.properties."proforma.forms".forms.first.uuid}}/field/FormFieldName

 

どなたかこの問題を解決する方法を知っているか、提案する具体的なアプローチをお持ちの方がいらっしゃいましたら、ご指導いただければ幸いです。

2 answers

1 accepted

2 votes
Answer accepted
Rudy Holtkamp
Community Champion
December 2, 2024

Hi @川目 沙英 ,

The most reliable way to get form field values is to use the end point: 
GET Get form simplified answers

I've tried other methods (e.g. issue properties), but they are not reliable. Especially when you change the form or the form has too many fields & sections.

With the response you get from the API call, you can create a lookup table for each answer you are interested in and use that throughout your rule.

 

川目 沙英 December 3, 2024

@Rudy Holtkamp 

GET Get form simplified answers
Is it possible to specify a specific form field with this endpoint and get its value?

I'm also trying to create a lookup table using the response I get from the API call based on your advice.
I'd also like to know about a smart value that will get the "answer" that corresponds to a specific "label".
The method below didn't work for me, is there any other suitable way?
{{webResponse.body..[label="job title")].answer}}

Rudy Holtkamp
Community Champion
December 3, 2024

To create a lookup table, first create a variable:

Variable name: response 
Smart value: {{webResponse.body}}

Then create the lookup table and use the regex below to find the answer:

Lookup table variable name: answers
Key                      > Value
Short description > {{response.match("\{label=Short description.*?answer=(.*?)[,|\}]")}}
Location              > {{response.match("\{label=Location.*?answer=(.*?)[,|\}]")}}

With the lookup table you can use:

{{answers.get("Short description")}

In the rest of your automation rule.

川目 沙英 December 9, 2024

@Rudy Holtkamp 
Problem solved. Thank you very much for your help.

Like John Funk likes this
0 votes
John Funk
Community Champion
December 2, 2024

Hi @川目 沙英 

Is there more than one Form associated with the Issues that you are pulling data for? 

Are you using the Form Submitted trigger? 

If you have only one form, you should be able to just use:

{{forms..Field Name.label.first}}

川目 沙英 December 3, 2024

@John Funk 

There is only one associated form.
But the trigger will be when the issue transitions.
Is it possible to use {{forms..fieldname.label.first}}?

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
TAGS
AUG Leaders

Atlassian Community Events