PIR - Automation
Asked by Rus Yates-Aylott:

Hi.

<br />

We would like to be able to automate the creation of a PIR when an action is taken on an incident.

For example: An incident is marked as a Major Incident. Several actions are taken including the creation of the PIR case.

We have successfully created a case with the system-level Post-Incident review type. However, this does not appear in the PIR folder/filter view and does not carry the Request Type of 'Create a post-incident review'.  

<br />

Is this possible?


Answers:
author: Eugenio Onofre
body: Hi [@Rus Yates-Aylott](/t5/user/viewprofilepage/user-id/5306962)

Sure! You can create an automation that will have the trigger of "field value changed" and select the MAJOR INCIDENT field. Then, a condition to validate if this field is set and, lastly, the action to create a new issue based on your PIR issue type.

Please remember to accept this answer in case it helps you resolve your question as it may also help other community members in the future.

Regards,  
Eugenio

comments: author: Rus Yates-Aylott
body: I CAN create a PIR (Issue Type) but cannot set the Request type to 'Create a post-incident review'


author: Rus Yates-Aylott
body: **Here's the flow that creates the PIR:**   

![Screenshot 2024-01-12 160043.png](https://community.atlassian.com/t5/image/serverpage/image-id/300360iD7C0FEA56C2D620B/image-size/large?v=v2&px=999 "Screenshot 2024-01-12 160043.png")  
**It creates the PIR case based on the Issue type 'Post-incident review':**   
![Screenshot 2024-01-12 161457.png](https://community.atlassian.com/t5/image/serverpage/image-id/300361i844B48F26601FFD6/image-size/large?v=v2&px=999 "Screenshot 2024-01-12 161457.png")  

**In the branch, we are trying to set the Request type:** ![Screenshot 2024-01-12 161528.png](https://community.atlassian.com/t5/image/serverpage/image-id/300362iB1291835D7140CBC/image-size/large?v=v2&px=999 "Screenshot 2024-01-12 161528.png")  
**This produces the following error:**   
![Screenshot 2024-01-12 161612.png](https://community.atlassian.com/t5/image/serverpage/image-id/300363iC74EBC21DCB30594/image-size/large?v=v2&px=999 "Screenshot 2024-01-12 161612.png")


author: Eugenio Onofre
body: You can! The request type is a custom field, so you can set it using the smart values. Something linke "customfield_XXXX.name": "value" in JSON.


author: Rus Yates-Aylott
body: I am still having an issue.  

When I first used the action to update the Request Type, I received the error shown above. This gave me the name of the custom field.  

So now I tried your suggestion of amending the custom field using json.  

Here is my code:  
![Screenshot 2024-01-15 084628.png](https://community.atlassian.com/t5/image/serverpage/image-id/300531i9B8C32E4055DCE76/image-size/large?v=v2&px=999 "Screenshot 2024-01-15 084628.png")  

This now produces a different error:  
![Screenshot 2024-01-15 084751.png](https://community.atlassian.com/t5/image/serverpage/image-id/300532iDBEFD3CE7C2AF269/image-size/large?v=v2&px=999 "Screenshot 2024-01-15 084751.png")  
I cannot believe there is no way to update this field. Maybe I have something wrong?


author: Rus Yates-Aylott
body: I have read this article and have tried amending the Actor from Automation to myself. This made no difference:<https://confluence.atlassian.com/automationkb/automation-for-jira-reporting-unknown-fields-set-during-edit-they-may-be-unavailable-for-the-project-type-1130727699.html>


author: Eugenio Onofre
body: [@Rus Yates-Aylott](/t5/user/viewprofilepage/user-id/5306962)

You are not using the appropriate structure of the Request Type field!  
The JSON for the Request Type field is not correct.

Best approach would be to set this field manually in a single ticket, do a GET request for this specific field, so you can check the correct JSON structure for the Request Type field.


author: Rus Yates-Aylott
body: Thanks. We finally discovered the issue was that, when attempting to use the 'Edit the Request type' action, it was reporting an issue against an incorrect customfield name.   
When we went in to look at Request Types linked to Issue Types (Atlassian admin level) we discovered the correct customfield name and used that in the json to amend the field. We also had to you the code that represented the value rather than a string of text.  

All rather convoluted, but that's jira I guess.  

Still. Thanks for your assistance \& support. Much appreciated.


author: Eugenio Onofre
body: [@Rus Yates-Aylott](/t5/user/viewprofilepage/user-id/5306962) great to hear. Please remember to accept this answer so it can be seen by other community members and help them out with the finds we had on this thread!


Tags: jira-service-management

jira-service-management-cloud