Accessing the most recently submitted form on a JSM portal ticket

JCameron
Contributor
October 8, 2024

Hey folks,

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 available trigger is "when an inventory form is submitted"
  • Once in the automation, there is no way to disambiguate the specific form that I am interested in from the set of forms attached to the ticket
    • You only see the triggering issue, not specifically the triggering form
  • PDF generation/attachment is not possible
    • Even if I set the inventory form to create a PDF each time it is submitted, there is no way for me to only copy over that specific PDF to the new Jira issue. I can only copy ALL of the attachment data - including all photos and videos pertaining to the other forms
  • Even if the purchasing/requisition project were on the JSM side, the options for the "copy form" automation block do not let you copy the form into an issue that was created within the automation. Copy direction is also wrong (copy 'from', not 'to')
  • We are very much trying to keep inventory requests that pertain to a specific workflow such as what's described here remain as part of that JSM issue, and not be a standalone request. That way it is a single, complete record of what happened.
    • This includes how many inventory requests were made, which is used in some performance metrics reporting.

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:

  1. Get the most recent date, which by definition here would implicitly be the most recently submitted Inventory Request Form.
  2. Use that date to get UUID of the Inventory Request Form in question
    1. Ideally I would instead get the array index of the entry that has the most recent updated date
    2. 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>}}
  3. Use that to use the Forms API to pull the specific form data
  4. Parse the webResponse in some way to get the info into the new Jira issue
    1. 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).

2 answers

1 accepted

0 votes
Answer accepted
JCameron
Contributor
November 8, 2024

There is also a process option that can address my above concern, which would be that an added inventory request form would have to be filled out and submitted prior to adding any other forms to the ticket. That would mean that the last form in the object list is the one we're looking for. It's a reasonable request from a user perspective that makes this a tractable problem.

Currently our solution is to simply have our automation create a new portal request for the user that is an inventory request. We link the new issue to the service ticket with a "created by" link and use smart variables in the summary to indicate what ticket and asset it is for, which makes it easy to find visually under someones "open issues" view in the portal. To keep the asset record cleaner in JSM, we're leaving the custom asset object field blank for inventory requests generated this way. It still appears in the record for the service ticket anyway, just under linked issues rather than the stack of forms. Good enough for our needs.

I'm marking this as "answered" for now since there's been no other suggestions and either of these options here are viable solutions.

0 votes
JCameron
Contributor
November 8, 2024

Updating my own question to the extent that I thought that I had found a workable solution. Unfortunately, this also does not work because advanced branching on a list variable executes in parallel. However, it looks like Atlassian is currently working on a way to toggle parallel execution for advanced branching off for cases like this where you actually need a for iterator.

  • In your main automation branch, make any utility variables that you'll need. For instance:
    • {{newestFormIndex}}
    • {{currentFormIndex}}
    • {{newestFormDate}}
  • Initialize them to some good default values
  • Create a branch in your automation and under advanced, enter the smart value that is a list of values. For instance, {{issue.properties."proforma.forms".forms.updated}}, with utility loop variable to something clear such as {{currentFormDate}}
  • Under the purple branch step:
    • Increment {{currentFormIndex}} - {{#increment}}{{currentFormIndex}}{{/}}
    • Use Smart Value Conditional Statements or a Smart Values if condition block to compare {{newestFormDate}} with {{currentFormDate}}
    • Set the conditional such that if it's newer, it returns {{currentFormIndex}}
    • Assign the results of the conditional to {{newestFormIndex}} in a log function

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