"Get Document" reference Passes 'Modified by' Email as array causing 'System.Object[]' cannot be converted to type 'System.String[]' error to occur

  • 16 February 2021
  • 0 replies

Userlevel 5
Badge +19

Get Document reference passes 'Modified by' Email as array causing 'System.Object[]' cannot be converted to type 'System.String[]' exception to appear


K2 blackpearl
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.


The following error occurs on Workflows at the set data fields event: Object of type 'System.Object[]' cannot be converted to type 'System.String[]'. The error will always appear at this Workflow event regardless of any input being added on the SharePoint Document.


This behavior appears when there is a particular design in place for the Workflow. Refer to the below characteristics that define where this behavior occurs:


- The Workflow is configured to create an Item Reference to a document within a SharePoint Document Library.

- A string type data field is created.

- There is a Set Data Fields event that takes in the Modified By (Email) value and passes it into the string data field that was previously created.


This behavior is logged as a bug within K2. This is tied to the document reference that is used to get the Modified by (Email) value from the document.


The system is passing back an array for the Modified By (Email) field when it is not necessary, since only one value is returned. This is the System.Object[] value. That array is then put into a System.String[] based object (our data field) which will cause an incorrect type conversion to occur.


Workaround: Supply the data field with an email that is grabbed using the Inline function under Sharepoint known as "GetK2EmailsForSharePointUsers()". Supply the site URL, Modified By (not name, value, or email), and K2 for our label parameter for this method.


A video of the workaround can be seen here: https://www.screencast.com/t/szrkAGxq 

0 replies

Be the first to reply!