CraigJB
Novice

Add a field to a SQL table which already has a SmartObject

Hi

I'm very new to K2 and still finding my feet. 

 

I have created a SQL database, Service instance and SmartObjects for some of the data. Using the SmartObjects I have build views and forms. Now I relasise I want another field on one of the tables.

 

Who can I do this?

 

I tried editing the SQL table from SQL Server Managagment Studio, refreshing the serviceInstance and both; "refresh SmartObject" and "Recreat SmartObject". But neith of these show the new field. If I chose "publish smart object, I must delete the existing SmartObject and lose any relationships created in the views.

 

Thanks in advance

Craig   

0 Kudos
Reply
5 Replies
Albarghouthy
Apprentice

Re: Add a field to a SQL table which already has a SmartObject

Dear @CraigJB,

 

To achieve this you will need to :

 

1- Add the field you want to your database table

2- refresh the service instance

3- create smartobject But before publishing you have to change the name to the previous name of your old smartobject

4- there's a button called get existing GUID, when you press it notice that the GUID changed

5- Publish smartobject, it will show a popup to OVERWRITE the smartobject, click yes

 

2190i059A29D7274D4D07.png

 

this way it keeps the old smartobject and add the new fields you've added.

 

 

wish it helps

 

Regards

Reply
Andrew_Blinco
Apprentice

Re: Add a field to a SQL table which already has a SmartObject

Hi Craig

 

Steve's suggestion will work well, however it will delete any associations you have on the SmartObject.

 

Another way to achieve this without deleting the associations is to edit the smartobject - although its a bit more time consuming.

 

  1. Create your new SQL table field and refresh the Service Instance
  2. Find the SmartObject in K2 Designer and click the edit button
  3. On the Properties tab click Add and add a new property to the SmartObject (call it the same as your new table field and give it the correct data type)
  4. On the Methods tab edit each of the methods to remap the properties to the table field (not required for delete) as follows:
  5. Select the method and click the Edit button
  6. Select the "Service object method binding" page
  7. Select the Service object method and click Edit
  8. Click the auto map button. This will remap all of the properties
  9. Save and repeat
Reply
CraigJB
Novice

Re: Add a field to a SQL table which already has a SmartObject

Thank you both!

0 Kudos
Reply
jrwarwick
Novice

Re: Add a field to a SQL table which already has a SmartObject

I had a similar situation: an MSSQL view that was the source for the SmartObject (obviously meant to be read-only object). However, I also had a handful of MSSQL stored procedures that were table-value returning select statements (with a join here and there and/or a few inline string processing functions on some of the columns) that were mapped as custom SmartObject Methods.  While the publishing technique as described in the accepted answer worked, it wiped out the custom method mappings, leaving me with only the default standard List method (a "select * from" the source view).

 

Is there some way to preserve those custom method mappings? Or is it necessary to re-map all custom methods after such a re-publish?

 

- Justin

0 Kudos
Reply
Andrew_Blinco
Apprentice

Re: Add a field to a SQL table which already has a SmartObject

Hi jwarwick

 

See my post above (in this thread) for instructions on how to edit a smartobject after a table definition change to preserve custom methods.

0 Kudos
Reply