高度なフィールド編集 (JSON)

Jira のプロセスとワークフローを自動化する

このページの内容

お困りですか?

アトラシアン コミュニティをご利用ください。

コミュニティに質問

robotsnoindex

The More options additional fields should only be used if a field cannot be edited using Choose fields to set. This may be necessary for custom fields provided by other applications.

The following automation actions provide additional fields for advanced field editing:

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.

JSON のフォーマット

The JSON object can contain the attributes update or fields, for example:


{
	"update": {
        "description": {
            "set": "a new description"
        },
        "labels": [{
                "add": "test-label"
        }]
    },
    "fields": {
        "summary": "woohoo! a new summary"
    }
}

What's the difference between update and fields?

fields is a shortcut for calling update with the set operation.  In the example above, calling set for the description field is the equivalent to including the description in the fields section like this: {"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 an issue, using the set operation would overwrite all existing labels, while using update would add the label without removing any existing labels.


JSON の update セクションと fields の両方に同じフィールドが同時に表示されることはありません。

課題フィールドを参照する

You can reference custom fields by name rather than ID. 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"
    }
}


When referencing by name, fields are case insensitive and you can replace spaces with underscores.

If there are custom fields with the same name, or a custom field has the same name as a system field, you will need to use the custom field ID.

サポートされているフィールドとオペレーション

If you’re creating or editing issues, you can query a project’s createmeta or an issue’s editmeta information to view supported fields and operations.

You can retrieve the metadata for both operations by visiting:

  • GET /rest/api/3/issue/createmeta?projectKeys=<string>&expand=projects.issuetypes.fields

  • GET /rest/api/3/issue/{issueIdOrKey}/editmeta

This JSON returns all fields that can be used in the Additional fields, including their possible operations and values.

Consider the following response for 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...
          }
        }
      ]
    }
  ]
}


The editmeta object allows you to search for the Single Select custom field and find its operations and values – only set and red, blue, green.

For example, to set the Single Select field to green during an edit, you can use the following JSON:


{
    "update": {
        "Single Select": [
            {
                "set": {"value": "green"}
            }
        ]
    }
}


You can also use the meta information to look up the custom field ID for a particular custom field.

フィールドを編集できない理由

If you've retrieved the createmeta or editmeta for your project or issue, 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 issue, 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 project. To address this, go to Jira settings > Issues > 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 issues on your project.

スマート バリューを使用する


Due to recent GDPR changes, referencing user fields (such as reporter, 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. Learn more about the JSON functions available as smart values.

For example, to change the current assignee to the user who initiated the event:


{
    "fields": {
        "assignee": { "id": "{{initiator.accountId}}" }
    },
}


To make the referencing of other fields easier, the above can be written as:


{
    "fields": {
        "assignee": {{initiator.accountId.asJsonObject("id")}}
    },
}


This not only creates the JSON in the right format, but also encodes the text correctly. To encode text by itself:


{
    "fields": {
        "assignee": { "id": {{initiator.accountId.asJsonString}} }
    },
}


To transform the value into JSON object with a key:


{
    "fields": {
        "assignee": {{initiator.name.asJsonObject("key")}}
    }
}


This will produce:


{
    "fields": {
        "assignee": { "key": "username" }
    }
}


For fields that take arrays of text:


{
    "fields": {
        "labels": {{issue.parent.labels.asJsonStringArray}}
    },
}


For fields that take an array of single field object:


{
    "fields": {
        "Multi User Customfield": {{issue.parent.Multi User Customfield.accountId.asJsonObjectArray("id")}}
    },
}

フィールドの構文の例

For more examples, view the Jira Cloud platform REST API documentation.

要約

A system field that is a single line of text.


"summary": "A summary is one line of text"

説明

複数の行のテキストからなるシステム フィールド。


"description": "A description is many lines of text\n separated by\n line feeds"

時間トラッキングと作業の記録

If you’re using time tracking, you can use automation to update associated field. Because time tracking represents multiple values, originalEstimate and remainingEstimate are parts of the parent field.

課題に対する作業を記録できます。


{
  "update": {
    "worklog" : [
      {
        "add": {
          "timeSpent" : "6m"
        }
      }
    ]
  }
}


または、作業を記録すると同時に残余見積もりを設定する場合は、以下の手順で行います。


{
"update": {
    "worklog" : [
      {
        "add": {
          "timeSpent" : "6m"
        }
      }
    ]
  },
    "fields": {
        "timetracking": {
              "originalEstimate": "10",
              "remainingEstimate": "5"
        }
    }
}


You can combine this with smart values to log work using a calculated value:


{
  "update": {
    "worklog" : [
      {
        "add": {
          "timeSpent" : "{{now.diff(issue.created).businessDays}}d"
        }
      }
    ]
  }
}


別の課題から時間トラッキングのフィールドをコピーするには、次のようにします。


{
    "fields": {
        "timetracking": {
              "originalEstimate": "{{issue.timetracking.originalEstimate}}",
              "remainingEstimate": "{{issue.timetracking.remainingEstimate}}"
        }
    }
}

コンポーネント

A system field that is multiple values addressed by name.


"components" : [ { "name": "Active Directory"} , { "name": "Network Switch" } ]

影響バージョン

A system field that is multiple values addressed by name.


"versions" : [ { "name": "Version 1.0"} , { "Version": "1.1" } ]

修正バージョン

A system field that is multiple values addressed by name.


"fixVersions" : [ { "name": "2.0"} , { "name": "Network Switch" } ]

期限

「YYYY-MM-DD」フォーマットの日付のシステムフィールド。


"duedate" : "2015-11-18"

ラベル

テキスト値の配列のシステム フィールド。


"labels" : ["examplelabelnumber1", "examplelabelnumber2"]

ラベルを追加する

既存のラベル セットにラベルを追加します。


{
    "update": {
        "labels": [
            {
                "add": "my-new-label"
            }
        ]
    }
}


You can also use remove or set as the operation instead of add.

課題のセキュリティ レベルを設定する


{
    "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 project.

課題をリンクする

You can also create issue links. For example, create a new issue as a result of editing an existing issue, then create a link back to the edited issue:


{"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 issue.

リクエスト参加者

The request participants field for Jira Service Management must be in a certain structure. For example, to add the last commenter of the issue to participants:


{
  "update": {
    "Request participants" : [
      {
        "add": {
          "id":"{{issue.comments.last.author.accountId}}"
        }
      }
    ]
  }
}

チェックボックス型カスタム フィールド

Select multiple values from a defined list of values. You can address them by value or 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

ラジオ ボタン型カスタム フィールド

Select a single value from a defined list of values. You can address them by value or 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.


"customfield_11447" : { "value": "parent_option1", "child": { "value" : "p1_child1"} }

or

"customfield_11447" : { "id": 10112, "child": { "id" : 10115 } }

複数選択カスタム フィールド

Select multiple values from a defined list of values. You can address them by value or id.


"customfield_11448" : [ { "value": "option1" }, { "value": "option2" } ]

or

"customfield_11448" : [ { "id": 10112 }, { "id": 10115 } ]

単一選択カスタム フィールド

Select a single value from a defined list of values. You can address them by value or 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 カスタム フィールド

Takes a URL.


"customfield_11452" : "http://www.atlassian.com",

シングルユーザー ピッカー カスタム フィールド

1 人のユーザーを選択できます。


"customfield_11453" : { "id":"2s1863211f0z284c45269423" },

マルチユーザー ピッカー カスタム フィールド

複数のユーザーを選択できます。


"customfield_11458" : [ { "id":"2s1863211f0z284c45269423" }, { "id":"332212e13z52142111269423" }]

Elements Connect (旧 nFeed) カスタム フィールド

文字列識別子の配列。


"customfield_10700" :  [ "10300", "10400" ]


For example, copying the value of an Elements Connect field:


"customfield_10700" :  {{ issue.customfield_10700.asJsonStringArray }}
最終更新日 2021 年 4 月 28 日

この内容はお役に立ちましたか?

はい
いいえ
この記事についてのフィードバックを送信する
Powered by Confluence and Scroll Viewport.