Changing field types for a Smart Object property

  • 28 January 2008
  • 5 replies
  • 1 view

Badge +5
How can I change a field type for a smart object property after I've already published it?

I understand that a smart object maps to a table in the smartbox database, and that you can't just change a field (column) type without messing up existing data, but what if I don't have any data in the smartbox? I'd expect a warning that data would be lost, and then possibly an alter table script to change the column type in the smartbox database the smart object maps to?

As it stands at the moment, Visual Studio crashes and dies as soon as I change the field type in the smart object even before I save the it (i.e. long before I can even deploy it) so I'm stuck. In a development environment where these things are changing along with requirements I'm finding this a tad limiting...

Any ideas?

5 replies

Badge +9
Quick question - are you using SP1?  If so, were the SmartObjects originally created in a previous version?
Badge +5
icon-quote.giftbyrne:
Quick question - are you using SP1?  If so, were the SmartObjects originally created in a previous version?


Good question - should have mentioned that. I am using SP1 and the smart object was created in SP1 (this morning using the same VPC).
Badge +9
Hmmm... I guess the next question is what data types are you changing from and to?  I just changed a 'Text' type to 'Memo', and got he error on deployment that I can't change the data type because data already exists.  I cleared all of the data in the smart box table, tried again and it deployed fine.  I was unable to duplicate any error on save, unfortunately.  Let me try and get in as close a scenario as you are in to see if I can duplicate the issue.
Badge +5
Ok - that's interesting. You get much further than I can - mine crashes long before I get to deploy. I have tried clearing all the data out of the table before changing the type.

I have tried changing text to number and also text to memo - both crashed.

I will try to figure out why it's crashing here before I take it further then - thanks for the help!

Trentino
Badge +9

I see two issues here.


1.  Visual Studio Crashing.


Do you happen to have .NET Framework 2.0 SP1 installed?  There was some issues with this SmartObject edit dialog with this framework serivice pack.  A hot fix was just release for this. For more information please refer to:  http://kb.k2workflow.com/Articles/KB000201.aspx


2.  Changing Data Type.


SmartBox will not permit changing of data type once data exists in the underlying table.  You should receive a compile time error similar to this if you make a change and then compile:


"Deploy smartobjects: Task error: SmartObjectServer Exception: Could not publish SmartObjectDefinition to server: Error: Cannot update the object definition.Cannot change the type of property "StoreName" from Text to Number. Data already exist for the object.[]"


I would recommend trying the following:


1. Backup the SmartBox SQL database


2. Within SQL Server copy/extract all the all data from this underlying SmartBox table (the table name should match you smartobject name)


3. Delete all records from this table


4. Make change in your SmartObject definition and deploy.


5. Copy data back into this table from the copied data, taking into account the data type change.


I would recommend creating a test SmartObject to try this out on before attempting on a real one in order to refine your steps/scripts.


HTH.

Reply