Using the Vault 2012 API, I am able to create a new category and property definition. I'd like to then assign this new property definition to my new category.
Maybe another way to say this is that I want to make my new property a behavior of my new category. I've searched the API document and this forum but I can't figure out how to do that.
1.) Is this possible through the API?
2.) If yes which service and method would I use?
Solved! Go to Solution.
Yes, you can assign property definitions to a category through the API. It's not a very intuitive set of functions.
A category is a collection of behaviors. A behavior is just a piece of functionality. Currently a category can have 3 types of behaviors: lifecycle definitions, revision schemes, and property definitions. In your case, it's the property definition behavior that you want to edit.
The function you need to call is UpdateCategoryBehaviorAssignmentTypes in the CategoryService.
Here is what you do for each parameter:
categoryId - The ID of the category you are editing
behaviorClassName - pass in "UserDefinedProperty"
allowNoBehavior - I don't think this parameter applies to the property behavior. Vault Explorer passes in YES so you should do that too.
behaviorIds - pass in an array of all property definition IDs you want associated with this category. Since you are adding a prop def you need to pass in an array of all existing prop definitions with the new prop definition added. (see next section)
behaviorAssignTypes - Again, I don't think this applies to categories. Just pass in an array of DEFAULT since that is what Vault Explorer does.
disableAllThenApply - Pass in TRUE here.
Finding the existing property definitions on a category:
GetCategoryConfigurationById should give you what you want. Pass in the category ID and tell it you want the UserDefinedProperty behavior.
It will give you back a CatCfg object which has the information you need. The BhvCfgArray.BhvArray property will be an array of all the existing property definition IDs for that category.
Thanks for your help and the additional write up (with code) on your blog page. For anyone else interested its located here: