I'm having a very hard time figuring out how to do something that I thought would be fairly simple due to the limitations of Jira automations and JSM forms.
Usage details: We have a portal setup for our service techs to access the forms they need for their different workflows. The form in question is a part discrepancy report. Following the workflow through, a series of forms will get added to the ticket based on selections made as they progress.
Each ticket will end up with one or more of each form type used. One form in particular is an inventory request form to pull repair parts.
Problem - I'm trying to have an automation that creates a new Jira issue in our non-JSM project that handles things like purchasing and inventory requests, then copy the request data (or attach a PDF of it) into that new issue.
The form data itself (pulled from the Forms API) within an issue looks like the following:
The example here does not imply any expected order.
[
{
"id": "b47f2887-d8fe-4ba0-8124-8b6d2901599f",
"formTemplate": {
"id": "a7ab7457-49a5-4305-9e85-9be50022cc02"
},
"internal": false,
"submitted": true,
"lock": false,
"name": "Discrepancy Form",
"updated": "2024-10-04T21:20:30.108Z"
},
{
"id": "a8770a40-c083-4d06-bbf3-83d7dcefc53e",
"formTemplate": {
"id": "9a720495-acf4-4681-a2b1-372405742a1d"
},
"internal": true,
"submitted": true,
"lock": false,
"name": "Inventory Request Form",
"updated": "2024-10-08T19:08:41.888Z"
},
{
"id": "b99c251a-a6a0-43d5-ba33-007fd71e85aa",
"formTemplate": {
"id": "0c830a64-e128-4011-8c70-75c59523c93c"
},
"internal": true,
"submitted": true,
"lock": false,
"name": "Repair Action Form",
"updated": "2024-10-08T19:31:23.962Z"
},
{
"id": "597142cb-ba47-4624-a5b7-5c08ec38c1be",
"formTemplate": {
"id": "9a720495-acf4-4681-a2b1-372405742a1d"
},
"internal": true,
"submitted": true,
"lock": false,
"name": "Inventory Request Form",
"updated": "2024-10-08T19:31:47.004Z"
}
]
Since the automation doesn't let me "see" the triggering form itself, I tried using Smart Values to:
- Get the most recent date, which by definition here would implicitly be the most recently submitted Inventory Request Form.
- Use that date to get UUID of the Inventory Request Form in question
- Ideally I would instead get the array index of the entry that has the most recent updated date
- The array index would let me use Smart Value 'get' function directly for the form data in the issue - {{issue.properties."proforma.forms".forms.get(index).<form field id>}}
- Use that to use the Forms API to pull the specific form data
- Parse the webResponse in some way to get the info into the new Jira issue
- The Forms API does have a 'get PDF' endpoint, but I can't find or figure out a way to take the binary blob returned by it and insert that as an actual file into the newly created Jira issue as an attachment.
Using Smart Values and loops combined with the 'Log Action' automation widget:
- {{issue.properties."proforma.forms".forms.updated}} will show a printed, comma separated list of the 'updated' dates above
- {{issue.properties."proforma.forms".forms.updated.max}} prints nothing (got this idea from the Smart Values - lists documentation)
- I tried using some different combinations of .toDateTime(<format string>), .toString tacked on in different places, etc. thinking maybe either 'max' is failing due to 'updated' not being a date/time object, or that 'max' is attempting some implicit conversion that is failing
- Since the log entry is simply blank but the automation says "success" I really have no idea how to actually debug it other than "plug and pray"
So, finally to my question(s).
- Is there an easier way to do this that I haven't found in my days combing through documentation and forums?
- Regardless, what am I doing wrong in getting the most recent date?
- What would the specific syntax be for the Smart Value if-then structure to actually get the UUID? I've seen some "sort of looks like" examples out there but it would be more trial-and-error
Thanks in advance, even just for reading through this. The form automation limitations have been surprising and incredibly frustrating. Especially for what we thought would be a straight forward use case (i.e., attach a PDF of a specific form to a newly created issue).