The process i followed
### Step-by-Step Guide to Revert Description Using Jira Automation
1. **Create an Automation Rule**:
-Go to **Project Settings** > **Automation**.
- Click on **Create Rule**.
2. **Set the Trigger**:
- Choose a trigger that fits your scenario, such as **Issue Updated** or **Field Value Changed**.
3. **Add an Action to Fetch Change Log**:
- Choose **Send web request**.
- **URL**: `https://your-domain.atlassian.net/rest/api/3/issue/{{issue.key}}/changelog`
- **HTTP Method**: `GET`
- **Headers**: - `Authorization: Basic `
- `Content-Type: application/json`
4. **Extract Previous Description Value**:
- Use a **Create variable** action to extract the previous description value from the change log response.
- **Variable name**: `previousDescription`
- **Smart value**: `{{webhookResponse.body.changelog.histories[-1].items[?(@.field == 'description')].fromString}}`
5. **Add an Action to Update the Description**:
- Choose **Send web request**.
- **URL**: `https://your-domain.atlassian.net/rest/api/3/issue/{{issue.key}}`
- **HTTP Method**: `PUT`
- **Headers**:
- `Authorization: Basic `
- `Content-Type: application/json`
- **Web request body**:
6. **Save and Enable, Run the Rule**:
First, what problem are you trying to solve by immediately reverting a change to the field? That is, "why do this?" Knowing that may help the community to offer better suggestions.
Next, to access list elements in an automation rule, use the get() or getFromEnd() functions:
https://support.atlassian.com/cloud-automation/docs/jira-smart-values-lists/#list.get-index-
Next, the web responses use dot-notation. Perhaps try accessing that attribute directly once you have selected the correct list item.
Finally, if your Description field contains markup / formatting, the endpoint will likely return the value in Atlassian Document Format (ADF), and so the way you are trying to update the field as simple text will not work.
Kind regards,
Bill
Hello @Bill Sheboy
We have a use case where we must revert to the previous value for description.
Do you have any similar workaround?
Thanks!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If you need to return the value with an ADF format, please read the documentation on using the REST API with that format. It is likely additional JSON encoding functions will needed to prevent errors when making the request.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The below Smart value does not fetch the description history/previous value:
`{{webhookResponse.body.changelog.histories[-1].items[?(@.field == 'description')].fromString}}`
Please suggest to me the correct smart value to add as a variable.
Thanks!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.