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

When attempting to create a Package using the Package and Deployment Tool of a SharePoint Online based K2 Solution, all the artifacts are analyzed succesfully, except the SmartObjects. They are marked with an error stating
"Error: Item contains errors that will cause deployment failures".

Image

Symptoms

When opening the Error Details, the following types of errors will be displayed:

[ListName] ServiceObject is referencing the 'ListSetting' ListSetting that could not be found.
[ListName] ServiceObject is referencing the [ListName] List that could not be found.
[ListName] ServiceObject is referencing the 'InternalName' property on the [FieldName] Field that could not be found.
[ListName] ServiceObject is referencing the [FieldName] Field that could not be found.

Image

The following error will also be seen in the K2 Hostserver Log File:
"Error Marshalling SourceCode.SmartObjects.Runtime.SmartObjectClientServer.ExecuteInstance, OAuth token requires authorization."

Troubleshooting Steps

For K2 to successfully authenticate against SharePoint Online, a Microsoft Online AppOnly Token is required for the User. Because the Package and Deployment tool is run as a locally logged on User (e.g. a Domain Account), this account requires a token.

The issue is caused when the user running Package and Deployment has not been issued with a Microsoft Online AppOnly Token to access SharePoint Online to validate the SmartObjects.

To generate a Token, please use one of the following steps:

Option 1:
Open SmartObject Tester Tool using the same user account attempting to create the Package.
Execute any of the SharePoint Online list/library related SmartObjects.
A prompt should display stating: "Please retry the operation after successful OAuth Authorization."
A browser window will display for Microsoft Online Login.
After signing in, an “Authorization Successful” message will display.

Option 2:
Open SmartObject Tester Tool using the same user account attempting to create the Package.
Create a new SQL Server Service Instance.
For Authentication Mode, Select OAuth.
For OAuth Resource, select the MSOA – [GUID]. 
For “Database – Required”, enter any text.
Click Next.
A prompt should display stating: "Redirecting for Authorization. Retry after successful authorization"
A browser window will display for Microsoft Online Login.
After signing in, an “Authorization Successful” message will display.
The Add Service Instance can now be cancelled.

These steps will create the required AppOnly Token and Package and Deployment will be able to successfully package the SharePoint Online SmartObject.