How do i change the description to previous value using Rest API

Yaswanth Vannam February 20, 2025

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**: 

Web request body.png
6. **Save and Enable, Run the Rule**:

2 answers

0 votes
Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 20, 2025

Hi @Yaswanth Vannam 

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

Yaswanth Vannam February 21, 2025

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!

Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 21, 2025

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.

0 votes
Yaswanth Vannam February 20, 2025

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!

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events