For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
Open sourceSupportFAQsDocs Home
DocumentationAPI referenceRelease notes
DocumentationAPI referenceRelease notes
  • Platform On-Prem
    • Overview
    • Navigate
    • Search resources
  • Apps
      • Overview
      • Navigate
        • Configure and manage tasks
        • Null vs. undefined values
        • Parallel branches
          • Overview
          • addDuration
          • arrayIncludes
          • arrayLastIndexOf
          • arrayPop
          • arrayToString
          • assign
          • calculateTimeDiff
          • charAt
          • charCodeAt
          • childjob
          • codePointAt
          • concat
          • concatArray
          • convertEpochToObject
          • convertTimeFormat
          • convertTimeToEpoch
          • convertTimezone
          • copyWithin
          • csvStringToJSON
          • deepmerge
          • delay
          • endsWith
          • ErrorHandling
          • evaluation
          • eventListenerJob
          • excelToJson
          • extractField
          • fill
          • FlattenJSONFormInput
          • getTime
          • includes
          • arrayIndexOf
          • indexOf
          • isArray
          • join
          • keys
          • lastIndexOf
          • length
          • length (string)
          • localeCompare
          • makeData
          • map
          • match
          • merge
          • modify
          • newVariable
          • normalize
          • objectHasOwnProperty
          • objectToString
          • padEnd
          • padStart
          • parse
          • parseInt
          • pop
          • push
          • pushToArray
          • query
          • repeat
          • restCall
          • reverse
          • runCode
          • search
          • setObjectKey
          • shift
          • slice (array)
          • slice (string)
          • sort
          • split
          • startsWith
          • stringValueOf
          • stub
          • substring
          • toLocaleLowerCase
          • toLocaleString
          • toLocaleUpperCase
          • toLowerCase
          • numberToString
          • toString (array)
          • toString (number)
          • toString (object)
          • toUpperCase
          • transformation
          • trim
          • trimEnd
          • trimStart
          • unshift
          • updateJobDescription
          • values
          • viewData
    • FlowAI
    • Itential Automation Gateway
  • Resources
    • Itential Academy
    • Version lifecycle
    • Itential MCP
    • Accessibility conformance
    • Get support
    • FAQs
LogoLogo
Open sourceSupportFAQsDocs Home
On this page
  • Potential use case
  • Properties
  • Example 1
  • Example 2
AppsStudioTasksTask reference

arrayLastIndexOf

Was this page helpful?
Previous

arrayPop

Next
Built with

The arrayLastIndexOf task searches an array and returns the last index (position) at which a given element is found. The task returns -1 if the element is not present. The array is searched backwards beginning at the fromIndex position. The returned index value is always relative to the beginning of the array — the first element is at index 0, the second at 1, and so on. The original array is not modified.

Potential use case

Use this task to find the last occurrence of a particular element in an array. For example, to find the last time a particular email appeared in an email list, use arrayLastIndexOf to retrieve its most recent index. If the email is not present, the result is -1.

Properties

IncomingTypeDescription
arrArrayRequired. The array to search.
searchElementAnyRequired. The element to locate.
fromIndexNumberOptional. The index position from which to start searching backwards. A positive number counts from the beginning (index 0). A negative number counts from the end. If not provided, the entire array is searched.
OutgoingTypeDescription
indexNumberThe last index where the element is found; -1 if not present.

Example 1

In this example:

  • The arr is statically set to ["a","b","c","a","b","c"].
  • The searchElement is "b".
  • fromIndex is not provided, so the entire array is searched.
  • The result is index 4 — the last position of "b" in the array.
arrayLastIndexOf task returning index 4 for the last occurrence of b

Example 2

In this example:

  • The arr is [1,2,3,2,5,2,3,2].
  • The searchElement is 2.
  • The fromIndex is -2, which means the search starts two positions from the end.
  • The result is index 5 — the last position of 2 within the search range.
arrayLastIndexOf task with fromIndex -2 returning index 5 for the last occurrence of 2