Put Method for Scripted Properties

Meta Data Services Programming

Meta Data Services Programming

Put Method for Scripted Properties

A script-based implementation for a property requires the creation of a Put method to validate and set a property value in the repository database.

A Put method that you provide substitutes for the set functionality that is typically provided by the repository engine. A Put method is also the only way to validate a property value prior to saving it in the database. When your script (rather than the repository engine) provides the implementation, you must handle setting and validation of a property value from the repository database.

For a Put method to succeed, the script body must contain a function with the same name as the property, and it must be prefixed with Put. For example, if the property name is ExtendedPrice, your script must include a function named PutExtendedPrice.

When the Put function is executed, the repository engine returns an error if the new value is invalid. If an error is returned, the repository engine does not store the new value in the repository database. If the function returns S_OK, the value passed to the function is stored in the repository database.

In addition to a Put method, you must also define a corresponding Get method within the same script. For more information, see Get Method for Scripted Properties.

Validating Multiple Properties Simultaneously

Sometimes two properties are so intertwined that it does not make sense to validate them separately. Instead, you can validate both properties at the same time by following these steps:

  1. Set the Put method for both properties to return a descriptive error that tells the user the property cannot be set. This step makes the property effectively read-only.

  2. Create a method that accepts the values of both properties as parameters. This method validates the property combination. You can then set each property individually.

See Also

Accessing a Script

Defining Script Objects

Handling Errors

IScriptDef Interface

Method Invocation for Scripted Methods

Predefined Script Variables