Skip to main content

LAST

Use the LAST function to return the last item from an Array.

Use

LAST( array )
Returns the last item from an array.

ParameterRequiredDescription
arrayYesany array to return the last item from

ReturnsAn item from the array matching the type of array

Examples

Displaying the Most Recent Reviewer Comment

In a multi-step approval process, you may use a Text Array to store a running log of comments from various reviewers. To ensure the final decider sees only the most recent feedback without scrolling through the entire history, you can use LAST in an Input Mapping Formula.

  • Scenario: A "Legal Review" step produces an array of notes called CommentsLog. The next step, "CEO Approval," needs to display just the last comment added.
  • Formula: LAST(@LegalReview.out.CommentsLog)
  • Logic:
    • @LegalReview.out.CommentsLog: Pulls the collection of all comments captured in the legal step.
    • Result: The function scans the array and returns only the text item at the very last position, providing the CEO with the most up-to-date context.

Identifying the Final Approver in a Sequence

When using User-defined assignment patterns, a submitter might provide a Person Array containing several names. You can use the LAST function within a Variable Update Formula to record who the final authority in that specific run will be.

  • Scenario: A user submits a request and lists three approvers in order: "Adele Vance," "Megan Bowen," and "Fred Blogs".
  • Formula: LAST(@Trigger.out.ApproverList)
  • Logic:
    • @Trigger.out.ApproverList: Accesses the array of people provided at the start of the approval.
    • Result: While the FIRST function would return "Adele Vance," the LAST function returns "Fred Blogs". This value can then be stored in a variable like $FinalAuthority to be used for final notifications or summary reports.

Pro Tip: In GoApprove, arrays are strictly typed to ensure robustness and reliability. The LAST function will always return a value that matches the data type of the array it is processing (e.g., if you use it on a Date Array, it returns a Date; if used on a Person Array, it returns a Person literal).