Accessing a Script
A script must run within the transaction of the calling program. When scripts encounter an unhandled error or exception, the repository engine reads the error information and populates the repository error queue appropriately. To minimize syntax errors in the script, you can use the ValidateScript method to perform a syntax check prior to script invocation.
To execute the script, the repository engine uses the Microsoft® ActiveX® Scripting Engine (VBScript) by default. If you require a more powerful scripting engine, you must instantiate that service from within your script.
There are three different ways to access a script. The first invokes a method; the other two get or put a property.
Invoking a Method
When a script provides the implementation code for a method definition object, you must access the script through method invocation.
When you invoke the method, the repository engine automatically executes the associated script. If there is no associated script, the repository engine returns the error message E_NOTIMPL.
Getting and Putting Properties
You can create a script that validates a property before inserting the value of that property into the repository database. In this case, your script (rather than the repository engine) validates the value, gets the value, and puts the value. If you are accessing script to validate a property before storing it in a repository database, you must create Get and Put methods that are associated with a property.
When you create scripts to retrieve and assign properties, you must always define both Get and Put operations in the same script.
- When you access any property definition object, the repository engine calls the Get portion of the script. You can use a Get method with a property to present properties in your application differently from the way they are stored in the repository engine. If there is no associated script, the property is returned as it is in the repository database.
- When you assign a value to any property definition object, the repository engine executes the Put portion of the script. The Put portion of the script is used to validate the value. If there is no associated script, the repository engine stores the unvalidated value.
See Also
Get Method for Scripted Properties