Renaming SmartObject Properties

Last post 04-15-2008, 2:38 PM by endpointsys. 0 replies.
Sort Posts: Previous Next
  •  04-15-2008, 2:38 PM 23209

    Renaming SmartObject Properties

    Recently while working with SmartObjects I ran into a situation where I needed to rename SmartObject properties in the .sodx files. Thinking this was no big deal, I went through the process of selecting the property, clicking the Edit button, making my changes, saving and deploying. Where I initially went wrong was my assumption that this was not a big deal.

    For what I'm doing specifically I need to access my SmartObjects programmatically and read/write the properties for particular records. When I went to programmatically access the renamed fields, I suddenly found myself getting "key not found" exceptions with the new property field names. Yet when I went back to the Visual Studio project to review the .sodx files, the new names existed there. What gives?

    My next step was to fire up the BrokerManagement tool in the ServiceBroker directory of the K2 installation. Using the tool i was able to open the SmartObject definition of the object I had made my property changes to and take a look at what was going on.

    Here's what my SmartObject property initially looked like:

    - <property name="Property1" type="text" unique="true" system="false" required="false">
    - <metadata>
    - <display>
      <displayname>Property1</displayname>
      <description />
      </display>
      </metadata>
      </property>
     

    Here's waht it looked like after the change I made:

    - <properties>
    - <property name="Property1" type="text" unique="true" system="false" required="false">
    - <metadata>
    - <display>
      <displayname>MyKeyProperty</displayname>
      <description />
      </display>
      </metadata>
      </property>

    To make an already long story short, the only thing that was changed was the <displayname>  property -- the name stayed the same where it mattered to me, which was at the API level. True renaming of SmartObject properties only occurs when you are adding a property, so if you are really trying to rename, the best way to do it is to delete and then add the property again with the name you desire, keeping in mind the consequences of deploying your new SmartObject structure to the runtime.


    Lucas Vogel
    Senior Managing Consultant
    Endpoint Systems
    http://endpoint-systems.net
    Filed under:
View as RSS news feed in XML