---
title: "Update asset"
canonical: "https://support.appfire.com/space/AIP/10256644/Update%20asset"
format: markdown
---
> Macro (aura-html)

This guide explains how to configure a workflow post function to update asset data when an issue transitions in Jira. The **[AIP] - Update Asset workflow post function** allows you to modify specific asset custom fields based on various conditions.

## Add post function

1. Navigate to the desired workflow in Jira.
2. Locate the workflow editor and identify the transitions.
3. Add **[AIP] - Update Asset workflow post function** to the workflows.
4. Drag and drop the **[AIP] - Update Asset workflow post function** after *Issue updates* and before the *GenerateChangeHistoryFunction* and *Re-index* post functions.

> 📝 If the condition passes, the post function is executed for each asset separately. This includes assets that are removed from the asset custom field during the transition. You can leverage the `assetStatus` context parameter to control the function's behavior for removed assets. 
> 📝 
> 📝 - To skip updating removed assets, add a condition within your Groovy script that checks for `assetStatus == 'removed'`. If the condition is true, return `null`.
> 📝 - Use `null` to indicate that you don't want to modify the asset attribute value.
> 📝 - Use an empty string (`''`) to clear the existing value in the attribute.
> 📝 - For practical examples, refer to the sections on [Sample Groovy scripts](https://appfire.atlassian.net/wiki/spaces/AIP/pages/10256592).

### <span style="color: #172b4d">Workflow parameters</span>

| **Parameter** | **Description** |
| --- | --- |
| <span style="color: #172b4d">Condition</span> | Groovy script for the post function condition. The function must return true, or the condition must be empty to pass. If the condition fails, the post function will be ignored. |
| Target Asset custom fields | Specify the custom field to update assets. Leave it blank to update all Asset custom fields. |
| Default groovy script | This is the default script to be executed for the options that have no specific Groovy script. Type script returning the value to update asset attribute; for example, return `issue.summary`. |
| Attributes to be updated (one or more) | - **Form:** Define a specific Form or select **Any form** to update the assets having the attribute.
- **Attribute: **Target attribute to set its value. |
| Groovy Scripts to execute<br>(one for each attribute definition) | There are two options to use as source value:<br>- **Use default Groovy script:** *Default Groovy script* result will be set to the attribute value
- **Custom Groovy script:** Specify attribute specific Groovy script to set as value.<br>**Jira Custom field value** will be added later as the third value source. |

### Context parameters for Groovy scripts

Please see [Sample Groovy scripts for asset management in Jira workflows](https://appfire.atlassian.net/wiki/spaces/AIP/pages/10256592) for more examples.

| **Variable Name** | **Description** |
| --- | --- |
| `asset` | Access AIP asset class instance.<br>> ⚠️ Only valid for Default Groovy Script and Attribute Groovy Script. |
| `assetStatus` | The string value gives the status of each asset's edit operation for Asset custom fields. This value may help with the increase or decrease decision for inventory tracking.<br>- **noChange**: The asset already exists before the transition, and it still exists.
- **removed**: The asset is removed in this transition.
- **added**: The asset did not exist before the transition, and it is added in this transition.
- **unknown**: A serious error occurred and failed to determine the status. |
| `issue` | Access current issue. Instance of `com.atlassian.jira.issue.Issue`. Refer to the [Atlassian documentation](https://docs.atlassian.com/software/jira/docs/api/latest/index.html?com/atlassian/jira/issue/Issue.html). |
| `originalIssue` | Access original issue before the transition. Instance of `com.atlassian.jira.issue.Issue`. Refer to the [Atlassian documentation](https://docs.atlassian.com/software/jira/docs/api/latest/index.html?com/atlassian/jira/issue/Issue.html). |
| `ComponentAccessor` | Access Jira components. Refer to the [Atlassian documentation](https://docs.atlassian.com/software/jira/docs/api/latest/index.html?com/atlassian/jira/component/ComponentAccessor.html). |
| `customFieldManager` | Access Jira Custom Field Manager class. Refer to the [Atlassian documentation](https://docs.atlassian.com/software/jira/docs/api/latest/index.html?com/atlassian/jira/issue/CustomFieldManager.html). |
| `loggedInUser` | ApplicationUser instance for current logged-in user. Refer to the [Atlassian documentation](https://docs.atlassian.com/software/jira/docs/api/latest/index.html?com/atlassian/jira/user/ApplicationUser.html).<br>**Example:**<br>` loggedInUser == issue.getAssignee()` |
| `DefaultIssueChangeHolder` | Default implementation of a change holder. It’s used to update a custom field. |
| `aipUtils` | Helper class for the post function Groovy script. See [AIP utils](https://appfire.atlassian.net/wiki/spaces/AIP/pages/10256550) for details. |

> 📝 You can add multiple post functions or multiple attributes to one post function.

## Try Groovy scripts

You can immediately execute a Groovy script to see the result. This will let you write and try your own Groovy scripts faster.

> 📝 Please remember that scripts will be actually executed. If you modify anything, please use test objects (issue, asset, etc.).

### Groovy examples for asset attribute types

| **Attribute Type** | **Description** | **Groovy example** |
| --- | --- | --- |
| Cascading Dropdown | The value must be cascading dropdown option IDs. Add `"-"` between options. | <sup>return "1-2"</sup>  
<sup>return "1-2-3-4"</sup> |
| <span style="color: #172b4d">CheckboxList</span> | Return valid option values wrapped with three “@” characters. For example: `@@@ada@@@@@@ist@@@`<br>For a single option value, you don’t need to wrap with `@` characters. | <sup>return "@@@ada@@@@@@ist@@@"</sup> |
| <span style="color: #172b4d">DatePicker</span> | The result must be in ISO format ("yyyy-MM-dd"). For example, `"2018-12-26"`.<br>You do not need to format if you use the LocalDateTime class, as it returns in ISO format by default.<br>Jira Issue's date field example:<br>- issue.created.format("yyyy-MM-dd'T'HH:mm") | <sup>import java.time.*  </sup><br><sup>  LocalDateTime t = LocalDateTime.now();  </sup><br><sup>  return (t as String) </sup> |
| <span style="color: #172b4d">DateTimePicker</span> | The result must be in ISO format ("yyyy-MM-ddTHH:mm"). For example, `"2018-12-26T20:20"`.<br>You do not need to do formatting if you use the LocalDateTime class, as it returns in ISO format by default.<br>> ℹ️ If you need to format a date to string, use the format as: <span style="color: #008000">"yyyy-MM-dd'T'HH:mm" </span><span style="color: #800000">(Please notice extra single quotes!)</span><br>Jira Issue's date field example:<br>- issue.created.format("yyyy-MM-dd'T'HH:mm") | <sup>import java.time.*  </sup><br><sup>  LocalDateTime t = LocalDateTime.now();</sup><br><sup>  return (t as String) </sup> |
| <span style="color: #172b4d">DropdownList</span> | Return a valid option value. | <sup>return "ada"</sup> |
| Encrypted | The value must be text. | <sup>return "password123"</sup> |
| <span style="color: #172b4d">InventoryList</span> | Return reference asset ID. | <sup>return "3"</sup> |
| <span style="color: #172b4d">InventoryListByForm</span> | Return reference asset ID. | <sup>return "10"</sup> |
| <span style="color: #172b4d">IP</span> | Any text is possible, there is no format control. | <sup>return  "10.0.0.2"</sup> |
| <span style="color: #172b4d">IPv6</span> | Any text is possible, there is no format control. | <sup>return "2001:0db8:85a3:0000:0000:8a2e:0370:7334"</sup> |
| Jira Organizations | The value must be one of Jira Organization IDs. If there are multiple values, you must add "@@@@@@" between them.<br>> ✅ Here is how to get [Jira Organization IDs](https://appfire.atlassian.net/wiki/spaces/AIP/pages/10256790). | <sup>return "1"</sup><br><sup>return "1@@@@@@2"</sup> |
| Jira Project | The value must be one of Jira Project IDs. If there are multiple values, you must add "@@@@@@" between them.<br>> ✅ Here is how to get [Jira Project Components IDs](https://appfire.atlassian.net/wiki/spaces/AIP/pages/10256790). | <sup>return "10000"</sup><br><sup>return "10000@@@@@@10001"</sup> |
| Jira Project Components | The value must be one of "**Jira Project Id - Jira Project Component Id**". If there are multiple values, you must add "@@@@@@" between them.<br>> ✅ Here is how to get [Jira Project Components IDs](https://appfire.atlassian.net/wiki/spaces/AIP/pages/10256790). | <sup>return "10000-1"</sup><br><sup>return "10000-1@@@@@@100001-2"</sup> |
| Jira Project Versions | The value must be one of "**Jira Project Id - Jira Project Version Id**". If there are multiple values, you must add "@@@@@@" between them.<br>> ✅ Here is how to get [Jira Project Version IDs](https://appfire.atlassian.net/wiki/spaces/AIP/pages/10256790). | <sup>return "10000-1"</sup><br><sup>return "10000-1@@@@@@100001-2"</sup> |
| Jira User Picker | The value must be a username. It doesn't need to be a Jira User. | <sup>return "tyler-durden"</sup> |
| <span style="color: #172b4d">TextArea</span> | Any text is possible. | <sup>return issue.description</sup> |
| <span style="color: #172b4d">URL</span> | Any text is possible, there is no format control. | <sup>return "http://www.snapbytes.com/"</sup> |
| <span style="color: #172b4d">UserPicker</span> | Any text is possible, there is no control. You may use `issue.reporter.username` or `issue.assignee.username`. | <sup>return issue.reporter.username</sup> |