How to automatically increment Assets Integer attribute using Automation for Assets

お困りですか?

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

コミュニティに質問


プラットフォームについて: Cloud のみ - この記事は、 クラウド プラットフォームのアトラシアン製品にのみ適用されます。

要約

Automatically incrementing a numeric attribute among objects from the same object type is useful in scenarios where you need an ID that is exclusive to that particular object type and it needs to be sequential.

It is possible to implement this by making use of automation for Jira. This article will detail steps on how to create a rule that will be triggered every time a new object from a particular object type is created. It will then detect the value from an integer attribute from the second newest created object (because the first would be the object that was just created). It will then increment this value by 1, and add this value to the newly created object.

環境

Jira Service Management Cloud and Assets.

ソリューション

Step 1 - Add an integer attribute to your object type

Navigate to Assets and open the object scheme where you have the object type that needs the auto-increment. Select the object type and add a new integer attribute. In this example, I've named it "Increment".

ステップ 2 - 自動化ルールを作成する

Go to System (Cog Icon) > Global Automation (on the panel to the left) and start a new rule with the following components:

Object Trigger: On the Created tab, select the object schema where the object resides (this trigger is only available in Global Automations).

IQL condition: This will be used so that this rule only applies to objects from the specified object type. In this example, I'm using the "Laptops" object type, so replace this part of the AQL with the name of your object type:

Lookup Objects: This will be used to collect the increment value from the last created object. The AQL used here should be the same as the AQL condition, but we need to add an ORDER BY clause so the objects are returned in the newest to oldest order.

Create Variable: This will be used to store the value from the object returned from the Lookup Objects action with the following smart value:

{{lookupObjects.get(1).Increment}}



Edit Object Attribute: Now that we have the data from the last created object stored in the variable, we'll use the Edit Object Attribute action to edit the integer attribute of the newly created object and increment it with some math expressions. On the dropdown, select the integer attribute that you're using for the auto-increment, and use the following smart value (number being the name of the variable we created earlier):

{{#=}}{{number}} + 1{{/}} 
  • Replace "Increment" with the name of your own attribute.

After that, name the rule and save it. New objects created from that object type will have the integer attribute automatically incremented.

Documentation for reference:


最終更新日: 2024 年 1 月 9 日

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

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