<{{Subtitle_Weight}} class="prominent-subhead {{Show_Subtitle}}"> {{Header_Subtitle}}

Autoguid does not work for Dynamic Sql Service Object

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.
This article has been archived, and/or refers to legacy products, components or features. The content in this article is offered "as is" and will no longer be updated. Archived content is provided for reference purposes only. This content does not infer that the product, component or feature is supported, or that the product, component or feature will continue to function as described herein.


Recreating the following scenario (or similar) where the NewID (Unique Identifier) is set as default with an AutoGUID file, will result in a "SmartObject property [Column Name] is required property for selected method Create.Value must be set" error as the K2 SmartObject will request the field to have a value which it obtains from the view/form before it can send the request to SQL. This will then generate the GUID therefore it will be blocked from a K2 SmartObject level and result in this error.

Additional information

Recreation steps:

  • Create a simple table in SQL, create a column called ID of type Unique Identifier.
  • Mark it as a primary key (setting it as unique).
  • Set the default value of ID as (newid)().
  • Add a service instance for that database, exposing the new table as a service object.
  • Add a SmartObject (advanced) via the designer, add the methods and auto create data fields which should create an ID.
  • Note that the SmartObject automatically and correctly identifies this as Autoguid.
  • Create an Item View, linking to this SmartObject.
  • Auto-generate the view fields for ID (which will be a read only label, given it doesn't need to be set).
  • Run the view and click "Create."
  • An error appears that states the ID was not provided even though it is set as an Autoguid.


An error appears that states the ID was not provided while AutoGuid is used.


From an SQL perspective you cannot have a primary key set to "not required/to accept nulls" as this will not work. However from the K2 SmartObject perspective the required property there is not the same as the required property from SQL, they are two different required properties although they work together. The required property from the K2 SmartObject, is a K2 required property which expects a value from a K2 level to be passed into the method before it even reaches SQL. On the other side the SQL required properties which is called the NOT NULL is expecting a value that it provides itself as the field is set to NewID() (Unique Identifier) as default.

Therefore should you turn off the required property from the SmartObject level, that does not mean that it is not a required field anymore as from SQL it will still be a required field and will be generated on insert.