You will often like to arrange that the catalog list only list BOs matching the search criteria. Such functionality is provided by the setFilter method and the condition is set in reference to the BOFields of the business objects. The way the search criteria will perform greatly depends upon whether you are working with a default or a user-customized catalog (see Catalog Customizer). If you apply the search criteria to the default catalog, it will apply to all catalogs that are based on it, whereas if you do the same with a user- customized catalog in a folder, the criteria will apply solely to this one particular instance of a catalog. The new criteria you set is saved when you commit the transaction you used to create the catalog. ApiCatalog.setFilter(Condition) Having set this filter, Catalog will list only business object matching the criteria set in the condition string. To learn how to create the condition string, see Search Criteria. Note: in order to access setFilter from a default catalog, you have to be authorized to run Catalog Customizer. To return an existing condition used for filtering the catalog: ApiCatalog.getCondition() Returns the current condition used for filtering of the catalog. Example - Setting filters We assume that you have run Valuemation and logged in correctly before starting this code. oVM variable now holds Application object. See Login Syntax for the section of the opening code. ‘creates transaction Set oTransaction = oVM.createTransaction 'gets Catalog Set oCatalog = oVM.getCatalogs.find(otransaction,"Person") ‘sets a condition string CondStr=”departmentID=3” oCatalog.setFilter(CondStr) 'lists all Bos in Catalog matching the criteria. for I=0 to oCatalog.length-1 ‘and writes last names of all persons to a string strTmp=strTmp & " ;" & i & " " &oCatalog.item(i).getBOFields.find("lastname").getValue next ‘writes the string to users’s screen Wscript.echo strTmp Comment: First, we get the application object and create a transaction. A “Person” catalog that should display people in the company is found and its criteria is defined using a condition string. This criteria says that the ID of the person’s department (which is represented by a BOField) must be 3. After setting the criteria using setFilter passing our string as a parameter, the catalog will only list business objects matching the criteria, employees (persons) from department with ID number 3. This is demonstrated in the following cycle that goes through all objects contained in the catalog and lists their “lastname” attributes to a string that is displayed on screen at the end. | |||||