The advantages of a using a Process Business Language method to populate a list of valid values are that you can use data from any source, and that you read this data when it is needed, so it is always current. You can also write a method that generates values with an algorithm and does not obtain data from an external source.
To define a dynamic method valid values list:
The following Process Business Language method loads a list from SQL table suppliers into the valid values list of an integer attribute. This table was previously introspected into the project catalog as an SQL component. In this table, supplierId is an Int, and supplierName is a String.
In this case the valid values list has descriptions, so an associative array in the form String[Int] must be returned:
listValues as String[Int]
for each record in
SELECT supplierId, supplierName
FROM suppliers
do
listValues[record.supplierId] = record.supplierName
end
return listValues
The following loads the first 11 numbers of the Fibonacci sequence into a valid values list with no description, so it returns an indexed array:
fNumber as Int[] fNumber[0] = 1 fNumber[1] = 1 for n in 2..10 do fNumber[n] = fNumber[n - 1] + fNumber[n - 2] end return fNumber