< class="prominent-subhead ">

Error using ErrorLog SmartObject Reference to loop through errors - Index was out of range

~~repeating-content.html~~
This article was created in response to a support issue logged with K2. The content may include typographical errors and may be revised at any time without notice. This article is not considered official documentation for K2 software and is provided "as is" with no warranties.

Issue

In a design where one has the need to loop through K2 Workflow errors in a workflow using the 'System > Management > Workflows > SmartObject > Error Log' SmartObject with method 'GetErrorLogs' or 'GetErrorLogsFiltered' in a Reference Event, the workflow fails with error as shown below.

Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: startIndex

Symptoms

The Workflow fails with the error:

Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: startIndex

Resolution

This is a known issue in K2 Cloud as well as supported K2 on-premise versions and will be addressed in a future release.

Workaround
Create a new Advanced SmartObject based off the 'GetErrorLogsFiltered(Int32 ErrorProfileID)' from Service Instance K2 Management > Workflow > Management > ManagementService

Reconfigure the Create Reference Event to use the new SmartObject created:

Input Mappings : ErrorProfileID : 1 (This is the All Error Profile ID)

Depending on the design there might be a need to reconfigure the Loop step and any other steps that used the Previous Reference.