JSON を使用した詳細なフィールド編集
[その他のオプション] 追加フィールドは、フィールドが [Choose fields to set (フィールドを選択して設定)] を使用して編集できない場合のみ使用してください。これは他のアプリケーションによって提供されるカスタム フィールドで必要になる場合があります。
次の自動化アクションでは、フィールドを詳細に編集するためのフィールドが追加されます。
To access these fields, select More options when configuring the action. These additional fields require you to specify a valid JSON object using the format specified by the Jira REST API. When configuring field updates, avoid setting fields to copy from themselves if they are empty, as this can result in no changes being applied. Instead, ensure the source field contains valid data or specify an alternate field with the desired values.
JSON のフォーマット
JSON オブジェクトには、属性 update または fields, などを含めることができます。
{
"update": {
"description": {
"set": "a new description"
},
"labels": [{
"add": "test-label"
}]
},
"fields": {
"summary": "woohoo! a new summary"
}
}update と fieleds の違い
fields とは、update を set 操作付きで呼び出すためのショートカットです。上記例では、説明フィールドとして set を呼び出すことは description を fields セクションに含めることと等しくなります (例: {"fields": {"description":"a new description"}})。
update can be useful for fields with multiple values, where you want to add and/or remove from the existing set. For example, when adding labels to a work item, using the set operation would overwrite all existing labels, while using update would add the label without removing any existing labels.
JSON の update セクションと fields の両方に同じフィールドが同時に表示されることはありません。
What problems may occur when editing fields?
JSON が無効
This warning may occur if the JSON you entered was invalid. Check the syntax of your JSON and try again. If an automation rule fails to execute correctly, check the audit logs to ensure that the rule is triggering as expected. Common errors include:
Missing permissions for the rule actor. Ensure the automation rule actor has permissions to view or edit fields in the space.
Invalid configuration in the rule, such as referencing unavailable fields (verify `editmeta` and `createmeta`).
Incorrect syntax in the JSON for fields such as cascading selects or users.
JSON は有効だがスマート値が検証できない
In this case, the JSON is valid, but the smart values you entered into the field can’t be validated. This is because smart values can only be validated once a rule is executed. Check the audit log once your rule runs to ensure the smart values have worked as you planned. If a rule runs successfully but expected updates are not applied, verify that all necessary steps (for example, Re-fetch work item data) are included and ensure fields are not set to copy values from themselves unless they contain valid data.
JSON が、検証できないスマート値で入力されている
This warning may occur if you’ve attempted to enter all of your JSON through a smart value, however we can’t validate smart values until a rule is executed. Check the audit log once your rule runs to ensure the smart values have worked as you planned. If a rule runs successfully but expected updates are not applied, verify that all necessary steps (for example, Re-fetch work item data) are included and ensure fields are not set to copy values from themselves unless they contain valid data.
JSON は有効でキーが欠落
この場合、JSON は有効ですが、更新またはフィールドのキーがないため、追加フィールドを解析できません。入力に、これらのキーを少なくとも 1 つ追加してからもう一度お試しください。
Referencing work item fields
You can reference custom fields by name rather than ID. For example, when referencing user fields such as the reporter, ensure you specify the desired subproperty. Instead of using just {{issue.reporter}}, you should include the subproperty like {{issue.reporter.displayName}} or {{issue.reporter.emailAddress}} to pull accurate and detailed reporter information.
{
"fields": {
"summary": "Reporter: {{issue.reporter.displayName}}"
}
}
In the example below, the same field is referenced by its ID and its name:
{
"fields": {
"customfield_10003": "the value I want to set",
"My Text Customfield": "this is the same field as above and using both causes an error"
}
}
名前で参照される場合、フィールドは大文字と小文字を区別しません。また、スペースはアンダースコアで置き換えることができます。
同じ名前のカスタム フィールドがある場合、またはカスタム フィールドの名前がシステム フィールドと同じ場合、カスタム フィールド ID を使用する必要があります。
サポートされているフィールドとオペレーション
If you’re creating or editing work items, you can query a space’s createmeta or a work item's editmeta information to view supported fields and operations. Additionally, ensure automation rules involving updates after actions (for example, assigning a user) include the 'Re-fetch Work item data' step to fetch updated work items details before subsequent steps. This ensures the latest data is available for dependent actions, such as updating custom fields.
この 2 つのオペレーションのメタデータは、以下より取得できます。
GET /rest/api/3/issue/createmeta?projectKeys=<string>&expand=projects.issuetypes.fields
GET /rest/api/3/issue/{issueIdOrKey}/editmeta
この JSON は、可能なオペレーションおよび値を含め、Additional fields で使用できるすべてのフィールドを返します。
createmeta の応答としては以下が考えられます。
{
"expand": "projects",
"projects": [
{
"expand": "issuetypes",
"self": "https://jira.atlassian.com/rest/api/2/project/10240",
"id": "10240",
"key": "JRA",
"name": "Jira (including Jira Work Management)",
"avatarUrls": {
"48x48": "https://jira.atlassian.com/secure/projectavatar?pid=10240&avatarId=17294",
"24x24": "https://jira.atlassian.com/secure/projectavatar?size=small&pid=10240&avatarId=17294",
"16x16": "https://jira.atlassian.com/secure/projectavatar?size=xsmall&pid=10240&avatarId=17294",
"32x32": "https://jira.atlassian.com/secure/projectavatar?size=medium&pid=10240&avatarId=17294"
},
"issuetypes": [
{
"self": "https://jira.atlassian.com/rest/api/2/issuetype/10000",
"id": "10000",
"description": "",
"iconUrl": "https://jira.atlassian.com/secure/viewavatar?size=xsmall&avatarId=51505&avatarType=issuetype",
"name": "Suggestion",
"subtask": false,
"expand": "fields",
"fields": {
"summary": {
"required": true,
"schema": {
"type": "string",
"system": "summary"
},
"name": "Summary",
"hasDefaultValue": false,
"operations": [
"set"
]
},
// other fields removed for brevity...
"components": {
"required": false,
"schema": {
"type": "array",
"items": "component",
"system": "components"
},
"name": "Component/s",
"hasDefaultValue": false,
"operations": [
"add",
"set",
"remove"
],
"allowedValues": [
{
"self": "https://jira.atlassian.com/rest/api/2/component/36920",
"id": "36920",
"name": "System Administration - Support Tools"
},
{
"self": "https://jira.atlassian.com/rest/api/2/component/43995",
"id": "43995",
"name": "User Management - Delete User"
}
]
}
// other fields removed for brevity...
}
}
]
}
]
}editmeta オブジェクトを使用すると、単一選択カスタム フィールドを検索し、演算子と値を検索できます (set と red、blue、green のみ)。
たとえば、編集中に [シングル セレクト] フィールドを緑色に設定するには、次の JSON を使用できます。
{
"update": {
"Single Select": [
{
"set": {"value": "green"}
}
]
}
}特定のカスタム フィールドのカスタム フィールド ID を確認するためにメタ情報を使用することもできます。
フィールドを編集できない理由
If you've retrieved the createmeta or editmeta for your space or work item, the field you're trying to edit may not show up in the resulting JSON. This means when a rule attempts to edit or create the work item, it will fail with an error in the audit log.
This will most likely be due to the field missing on the appropriate edit or create screen in your space. To address this, go to Jira settings > Work items > Screens and ensure the field you’re trying to update is on the appropriate edit or create screen.
Additionally, ensure that the automation rule actor has the right permissions to edit or create work items in your space.
スマート バリューの使用
Due to recent GDPR changes, referencing user fields such as reporter or assignee now require the property id to be set with a user's account ID rather than using name.
Advanced field values also support smart values. Check the audit logs after rule execution to confirm that values were correctly processed. Learn more about the JSON functions available as smart values.
べストプラクティス
Always specify the property and, if applicable, the subproperty when referencing user fields in a smart value.
For example:
{{issue.reporter.displayName}}or{{issue.reporter.accountId}}
Use
.asJsonStringor.asJsonObjectwhere complex values need encoding for JSON.
For example, to copy a reporter's email address into a custom field, use:
{
"fields": {
"customfield_12345": "{{issue.reporter.emailAddress}}" }
}
}
And to change the current assignee to the user who initiated the event, use:
{
"fields": {
"assignee": { "id": "{{initiator.accountId}}" }
}
}
他のフィールドの参照を簡単にするには、上記を次のように記述できます。
{
"fields": {
"assignee": {{initiator.accountId.asJsonObject("id")}}
}
}
これによって、JSON が正しいフォーマットで作成されるだけでなく、テキストも正しくエンコードされます。テキストを自動でエンコードするには、次のようにします。
{
"fields": {
"assignee": { "id": {{initiator.accountId.asJsonString}} }
}
}
値をキー付きの JSON オブジェクトに変換するには、次のようにします。
{
"fields": {
"assignee": {{initiator.name.asJsonObject("key")}}
}
}
結果は次のようになります。
{
"fields": {
"assignee": { "key": "username" }
}
}
テキストの配列を受け入れるフィールドの場合:
{
"fields": {
"labels": {{issue.parent.labels.asJsonStringArray}}
}
}
1 つのフィールド オブジェクトの配列を受け入れるフィールドの場合:
{
"fields": {
"Multi User Customfield": {{issue.parent.Multi User Customfield.accountId.asJsonObjectArray("id")}}
}
} フィールドの構文の例
その他の例を見るには、「Jira Cloud プラットフォーム REST API のドキュメンテーション」を参照してください。
要約
1 行のテキストからなるシステム フィールド。
"summary": "A summary is one line of text" 説明
複数の行のテキストからなるシステム フィールド。
"description": "A description is many lines of text\n separated by\n line feeds"時間トラッキングと作業の記録
タイム トラッキング機能を使用している場合、自動化を使用して関連フィールドを更新できます。タイム トラッキングは複数の値を表示するため originalEstimate と remainingEstimate は親フィールドの一部になります。
You can log work against a work item:
{
"update": {
"worklog" : [
{
"add": {
"timeSpent" : "6m"
}
}
]
}
}
または、作業を記録すると同時に残余見積もりを設定する場合は、以下の手順で行います。
{
"update": {
"worklog" : [
{
"add": {
"timeSpent" : "6m"
}
}
]
},
"fields": {
"timetracking": {
"originalEstimate": "10",
"remainingEstimate": "5"
}
}
}
これをスマート バリューと組み合わせると、計算した値を使用して作業を記録できます。
{
"update": {
"worklog" : [
{
"add": {
"timeSpent" : "{{now.diff(issue.created).businessDays}}d"
}
}
]
}
}
To copy the time tracking fields from another work item:
{
"fields": {
"timetracking": {
"originalEstimate": "{{issue.timetracking.originalEstimate}}",
"remainingEstimate": "{{issue.timetracking.remainingEstimate}}"
}
}
}コンポーネント
name で処理される、複数の値からなるシステム フィールド。
"components" : [ { "name": "Active Directory"} , { "name": "Network Switch" } ]影響バージョン
name で処理される、複数の値からなるシステム フィールド。
"versions" : [ { "name": "Version 1.0"} , { "Version": "1.1" } ]修正バージョン
name で処理される、複数の値からなるシステム フィールド。
"fixVersions" : [ { "name": "2.0"} , { "name": "Network Switch" } ]期限
「YYYY-MM-DD」フォーマットの日付のシステムフィールド。
"duedate" : "2015-11-18"ラベル
テキスト値の配列のシステム フィールド。
"labels" : ["examplelabelnumber1", "examplelabelnumber2"] ラベルを追加する
既存のラベル セットにラベルを追加します。
{
"update": {
"labels": [
{
"add": "my-new-label"
}
]
}
}
複数のラベルを既存のラベル セットに追加します。
{
"update": {
"labels": [
{
"add": "Label1"
},
{
"add": "Label2"
}
]
}
}また、「add」の代わりに「remove」または「set」を演算子として使用できます。
Setting the security level of a work item
{
"update": {
"security": [
{
"set": {"name": "Public"}
}
]
}
}In this case, Public is the name of the security level. Substitute this with a valid security level in your space.
作業項目をリンクする
You can also create work item links. For example, create a new work item as a result of editing an existing work item, then create a link back to the edited work item:
{"update": {
"issuelinks": [
{
"add": {
"type": {
"name": "Relates"
},
"outwardIssue": {
"key": "{{issue.key}}"
}
}
}
]
}
} To lookup the link type name (Relates in the above example), you can consult <yoursite>/secure/admin/ViewLinkTypes!default.jspa on your site. The {{issue.key}} smart value replaces the key of the trigger work item.
リクエスト参加者
The request participants field for Jira Service Management must be in a certain structure. For example, to add the last commenter of the work item to participants:
{
"update": {
"Request participants" : [
{
"add": {
"id":"{{issue.comments.last.author.accountId}}"
}
}
]
}
}チェックボックス型カスタム フィールド
値の定義リストから複数の値を選択します。value または id で指定できます。
"customfield_11440" : [{ "value" : "option1"}, {"value" : "option2"}]
or
"customfield_11440" : [{ "id" : 10112}, {"id" : 10115}] 日付ピッカー カスタム フィールド
"YYYY-MM-DD" 形式の日付。
"customfield_11441" : "2015-11-18"日時ピッカー カスタム フィールド
ISO 8601 "YYYY-MM-DDThh:mm:ss.sTZD" 形式の日時。
"customfield_11442" : "2015-11-18T14:39:00.000+1100"ラベル カスタム フィールド
テキストの配列です。
"customfield_11443" : [ "rest_label1", "rest_label2" ] 数値型カスタム フィールド
数字を含みます。
"customfield_11444" : 664ラジオ ボタン型カスタム フィールド
値の定義リストから、単一の値を選択します。value または id で指定できます。
"customfield_11445" : { "value": "option2" }
or
"customfield_11445" : { "id": 10112 } カスケード選択カスタム フィールド
Select a single parent value and a related child value. You can address them by value or id. Ensure the correct JSON syntax is used for cascading fields. Use the appropriate metadata (`editmeta`) to verify valid values for the parent and child fields before updating the JSON.
"customfield_11447" : { "value": "parent_option1", "child": { "value" : "p1_child1"} }
or
"customfield_11447" : { "id": 10112, "child": { "id" : 10115 } } 複数選択カスタム フィールド
値の定義リストから複数の値を選択します。value または id で指定できます。
"customfield_11448" : [ { "value": "option1" }, { "value": "option2" } ]
or
"customfield_11448" : [ { "id": 10112 }, { "id": 10115 } ]
複数選択カスタム フィールドに値を追加します。たとえば、複数選択カスタム フィールドを持っていて、このフィールドに別のカスタム フィールドの値を追加したい場合などです。
{
"update": {
"customfield_12345": [{
"add": { "value": "{{issue.customfield_12224}}" }
}]
}
}単一選択カスタム フィールド
値の定義リストから、単一の値を選択します。value または id で指定できます。
"customfield_11449" : { "value": "option3" }
or
"customfield_11449" : { "id": 10112 } 複数行テキスト カスタム フィールド
複数行のテキスト。
"customfield_11450": "Multiples lines of text\n separated by\n line feeds" テキスト カスタム フィールド
1 行のテキスト。
"customfield_11450": "a single line of text"URL カスタム フィールド
URL を取得します。
"customfield_11452" : "http://www.atlassian.com"シングルユーザー ピッカー カスタム フィールド
1 人のユーザーを選択できます。
"customfield_11453" : { "id":"2s1863211f0z284c45269423" } マルチユーザー ピッカー カスタム フィールド
複数のユーザーを選択できます。
"customfield_11458" : [ { "id":"2s1863211f0z284c45269423" }, { "id":"332212e13z52142111269423" }]
Appending values in a multi-user picker custom field – for example you want to append the reporter of the work item to a multi-user picker custom field. In that case, you would have to add the below under “More options”.
{
"update": {
"customfield_12346": [{
"add": {"id":"{{reporter.accountId}}"}
}]
}
}Elements Connect (旧 nFeed) カスタム フィールド
文字列識別子の配列。
"customfield_10700" : [ "10300", "10400" ]
たとえば、Elements Connect フィールドの値をコピーするには、以下の手順で行います。
"customfield_10700" : {{ issue.customfield_10700.asJsonStringArray }}この内容はお役に立ちましたか?