Get the Index of the Record In the Record List

When writing rules in a decision service or flow project, you can use the IndexOf function with a record list to return the index of a record in the record list.

The syntax for this function is:

  • IndexOf(record list, record)

For example, if you had a list of maintenance steps, you could have an index applied to each record.

A rule in a decision service project showing the IndexOf function used to apply an index to each maintenance step record

In the example above, the records would be given index numbers as follows:

  • for U1, the maintenance step number is 1

  • for C1, the maintenance step number is 2

  • for C2, the maintenance step number is 3

  • for C3, the maintenance step number is 4

  • for T1, the maintenance step number is 5

  • for S1, the maintenance step number is 6

Tip: You could use a function to count the total number of maintenance steps and then combine this with the maintenance step number to show the maintenance steps on screen as Step x of y.

A rule in a decision service project showing the Count function used to count the number of maintenance step records

A label control in a flow project showing a count of the number of steps

For example:

Check transducer

Step 5 of 6 steps

If there are conditions on the records in the record list, only the records that meet the conditions are given index numbers.

A rule in a decision service project showing the IndexOf function used to apply an index to each maintenance step record when certain conditions are met

In the example above if the Inspection Type is Complex Machine, you would get 4 indexed records as follows:

  • for U1, the maintenance step number is 1

  • for C3, the maintenance step number is 2

  • for T1, the maintenance step number is 3

  • for S1, the maintenance step number is 4

Note that:

  • Record list indexes are 1 based so if the specified record is the first record in the record list, the result will be 1.

  • If either the record list or record is null, the result is null.

  • If the record is not in the record list, the result is null.