≡ Menu

Using Property Operations

Share the knowledge

I recently got to try out a new tool from the Teamcenter developers toolbox that I’ve never used before, property operations. I think I’m going to be using them again. If you haven’t used property operations before, take a look and see if you can find a way to use them.

The Problem

We have an in-house system that maintains a lot of our important part and document information. You can think of it as an in-house version of TC Enterprise. We want to know if items we create in Teamcenter are also in that external system. If the item is found we pull back some data from that external system to make it visible inside of Teamcenter. We do this with custom post-actions on item creation. Every time an item is created the item ID is sent to the external system and if there is a match the relevant data is pulled back.

The problem is that sometimes item IDs are changed, and there was no automatic re-check with the external system. There are many legacy items with badly formed item IDs (prefixing the part number with the program code was a common sin). The old, incorrect, item IDs were not found in the external system so no data had been pulled back. Once the item ID is fixed we want the fields to be updated. Conversely, sometimes it’s possible that a valid ID is changed to an invalid ID and we want the fields cleared. The third possibility is that one valid ID is changed to another valid ID, in which case we want the fields to be updated so we can avoid having data that appears valid but is actually wrong.

As a stop-gap solution we created a workflow handler that made the call and pulled the data back and a 1-step workflow to invoke the handler. Running the workflow process forces a re-sync of the data fields, but users have to run that manually. It’s a difficult error to catch if they forgot to run the re-sync workflow.

The Solution: Property operations

The solution I came up with was to use property operations, something I’ve never done before. If you’re familiar with pre-conditions, pre-actions, and post-actions on things like item creation and revisioning, property operations are very similar. The difference is that these events are triggered by either getting or setting a property value.

Defining property operations

New property operations are defined in the BMIDE.

  1. First, if you haven’t done so already you need to create a library in which the new property operation will be defined.

    1. In the Extensions view, navigate to the [ProjectName]/Code Generation/Libraries folder and right click on it.
    2. Select “New Library” and fill in the fields in the dialog that opens

    Create new library dialog

  2. Second, define the new extension definition.

    1. Right click in the Extensions view on the [ProjectName]/Rules/Extensions folder.
    2. Fill in the fields appropriately.

    Define new extension dialog
    Defining extension availability as a property operation

  3. Third, attach the new property extension.

    1. Open the page for the object type you want to affect. It should be the type you chose in the extension definition’s availability field, or a subtype of that type.
    2. Select the Operations tab
    3. Expand the Property Operations folder and select the correct property.
    4. Choose Extension Attachments – Pre-Condition, Pre-Action or Post-Action as appropriate.
    5. Add your custom extension

    Attaching property operations

Implementing property operations

  1. In the Extensions view, right click on the extension you defined.
  2. Choose “Generate Extension Code”. New source files will be created. You can find them in the Navigator view under output/server/gensrc/[operationName]. This is skeleton code. You still need to implement the actual logic.
  3. If you are compiling our code with the BMIDE you can implement the function here. If you are compiling elsewhere, such as in Visual Studio, you’ll want to move the source files and include them in your project definition there.

Expanding the function arguments

The signature of your custom operation will look like

int YourOperationName( METHOD_message_t *msg, va_list args );

From the msg argument you can get the tag of the object being accessed and the name of the particular property. From the va_list you can get the new value.

Expanding the va_list argument

In order to expand the va_list you need to know what message was passed. The possible messages are defined in <property/prop_msg.h>. They take the form of PROP_[ask or set]_value_[typename]_msg. In the header file each is documented regarding the contents of the va_list stack.

In my case I’m setting the item_id attribute, so the message is PROP_set_value_string_msg. According to the documentation, the contents of the va_list are the tag of the property and the new value.

#include <RSP4PropertyOperations/RSP4Resynchronize.hxx>
int RSP4Resynchronize( METHOD_message_t *msg, va_list args )
    // the object the property is attached to
    const tag_t object = msg->object_tag; // an Item
    const string prop_name(msg->prop_name); // item_id
    // make a copy of the va_list and operate on the copy
    // (operating directly on va_list can cause problems in some situations)
    va_list largs;
    va_copy( largs, args );
    // I know what args to pull off the va_list based on 
    // the documentation for the PROP_set_value_string_msg
    // message that I'm expecting
    va_arg(largs, tag_t);  // prop_tag (no longer used)
    const char* new_value = va_arg(largs, const char*);
    // Go off and implement cool code _here_
    return 0;

Other potential uses

These are some ideas for how you might be able to use property operations. I haven’t tried these myself yet so I can’t promise they will all work, but I’m optimistic.

SetValue Pre-condition

  • Validate any input. Naming rules and List of Values are great for checking syntax but they can’t check semantics, “this value is valid ONLY IF this, this, and this are all true.”

SetValue Post-action

  • Log any value changes. Who changed what, when?
  • Update related fields. For example, when the item ID is updated automatically update the names of the attached datasets, forms, BOM view and BOM view revisions to match the new item ID.

GetValue pre-condition

  • Block certain users from seeing sensitive data while letting them see other properties

GetValue post-action

  • Log access. Who has looked at this highly sensitive data?

If you have worked with these I’d love to hear about any successes or failures you’ve had. What cool uses have you found for property operations? What limitations have you found? Share your experiences in the comments

  • Lokesh Podigiri

    Really nice post (Keep posting….).

    I have tried the same thing in my local environment, but when I generate the code using “Generate Extension Code” they are generaded in .c and .h formats instead of CPP .cxx and .hxx formates. Do I need to change any project settings here?

    I have used Business Modeler IDE (8.3.0).

  • Trevor Pearson

    I’ve found it useful to create a post action for when responsible party changes on a task. Then I use that to notify the person who has received the task.

    I’ve found it limiting that some attribute properties don’t have operations (TC I want to count the number of times a task has been started/completed without parsing the audit file. But the EPMTask:state_value does not have any operations available.

    Thanks for posting this years ago!

  • Thomas Gainza

    Thanks for such an illustrating post, I found it very inspiring, and dus put me into “troubles”. I decide to use property operations to calculate the value of a property based on linked object’s properties, so far so good. The problem arises when I want to do the operation customizable. I created a custom property constants to set the relation, object type and property to perform the calculation, but I couldn’t find the way to read the property constants. Could some one help me with this issue? (any doc or sample would be much appreciated)

    I’m self trained in both C and Teamcenter develop, so I may (will) have some knowledge lacks.

    Thanks in advance.

    • Sitaramireddy Lankireddy

      Hi Thomas,
      I want to add conditions to the property constants, but I know only how to create condition in extensions and I don’t know how to add it to the property constants. please help me in this context.
      Thanks and regards

  • Sitaramireddy Lankireddy

    I want to disable one property depend on the value of the other property is it possible with this property operations, I tried by creating a condition in extensions and I don’t know how to disable the attribute by using this condition.

  • Sitaramireddy Lankireddy

    I want to know how to add conditions for property constants in bmide.

Optimization WordPress Plugins & Solutions by W3 EDGE