How to set and get user properties in automation

お困りですか?

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

コミュニティに質問

アトラシアン社外秘

この記事は未検証なのでお客様と共有できません。


Platform Notice: Cloud - This article applies to Atlassian products on the cloud platform.

要約

Currently, there is no way to set/get a global attribute for either a user/project/issue using Jira. This knowledge-based article provides a way to do that using REST API and Jira automation.

環境

Jira Cloud

ソリューション

シナリオの例

In a typical business scenario, the users should be able to set their status to Out of Office, and when their status is set to OOO, no issues should be assigned to them

Suggested Solution

The Jira Cloud REST API provides the following endpoints to set and get global attributes/properties for users/issues/projects.

Automation Rule (Setting User Property)

  • A new custom field representing the user's status needs to be created using a single select custom field. The field should only have two options (Yes/No).
  • The users would have to choose their current status from this drop-down and as soon as they make a choice, the automation rule will trigger and set the user property (*propUserAvailability*) based on the value of the drop-down custom field. This property would be accessible across the site wherever this user is present.

  • The below-mentioned REST end-point is used to set the user property
https://your_site_name.atlassian.net/rest/api/3/user/properties/propUserAvailability?accountId={{initiator.accountId}}}

The following JSON body will be sent as the payload of the REST call.

{
  "val": "{{issue.PH Flag.value}}",
  "aid": "{{initiator.accountId}}"
}

val : This will store the user's choice that they made when setting their status.

aid : This will store the user's account ID who made that choice.

Automation Rule (Getting User Property)

  • This automation will be triggered when the issue is assigned to a user.
  • The below-mentioned REST end-point is used to check whether the issue assignee has set the availability flag?


https://Your_site_name.atlassian.net/rest/api/3/user/properties/propUserAvailability?accountId={{issue.assignee.accountId}}


  • Use the same credentials that you generated for the first rule and put the generated string in the Authorization header in the following format.
Basic <64-bit encoded auth string>

Create a smart variable to store the value of user property returned through the web response object.

{{webResponse.body.value.val}}


.


Since we don't have control over or the knowledge of who the next assignee will be by round robin method or balance workload method, therefore, we wait for the issue to be assigned and then check if the assignee has set the availability flag as OOO or not. 

  • If the issue assignee has set the flag field to No (No represents OOO) then unassign the issue.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              


最終更新日 2024 年 11 月 27 日

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

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