Skip to main content

I've been trying to create a SmartObject from a SQL table.  I understand the process using the service tester ... refreshing the SQL service instance and then selecting create SmartObject which works properly.  When I take a look at the resulting SMO the key field shows as an integer which is required.  Attempting to use this SMO in SmartForm to create a record fails on the primary key which makes sense because I'm not specifying what the value should be and it's required.

 

I compared against other existing SMO's in my environment and they show the PK field as Autonumber and not required.  I found that I could set the options on the PK in the SmartObject to Autonumber using the designer or studio but I'm unable to remove the REQUIRED.  I must be missing something.

 

SQL Table - Simple testing table with two fields:

CREATE TABLE dbo]. Test_J2](
     test2_id] tbigint] NOT NULL,
     CONSTRAINT >PK_Test_J2] PRIMARY KEY CLUSTERED
(
     test2_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON EPRIMARY]
) ON IPRIMARY]

Blackpearl version is 4.6.9.  Any help would be appreciated.

 

Hi James

 

Changing the data type for the ID field to autonumber on the SmartObject itself won't change it to a not-required field. K2 does not generate autonumbers, it simply reflects what the underlying data store expects.

 

When K2 creates or refreshes the service instance (and creates/refreshes the service objects) it interrogates the SQL database to see what the column datatypes and required values are. 

 

You will need to either:

  1. change the data type in the SQL table to autonumber (Is Identity = Yes) and refresh the service instance
  2. generate a unique ID at runtime and pass into the create method

Reply