Tech Tip: .query() querySettings parameter options
PRODUCT: 4D | VERSION: 20 | PLATFORM: Mac & Win
Published On: January 20, 2025
Within the querySettings parameter of the Dataclass.query() command, you can pass an object containing the the following supported properties: parameters, attributes, args, allowFormulas, context, queryPlan, and queryPath. Notably, you can used placeholders to provide values for these properties. A placeholder is a parameter inserted in query strings that is replaced by another value when the query string is evaluated. Indexed or named placeholders can be used.
An example of this is below of a query using indexed placeholders and named placeholders for value.
var $querySettings : Object var $managedCustomers : cs.CustomerSelection $querySettings.parameters := New object("userId";1234) $managedCustomers := ds.Customer.query("salesperson.userId = :userId and name=:1"; "Smith"; $querySettings) //salesperson is a related entity |
While 4D has moved towards having the property be mostly used for objects, older supported types, such as collections, are still supported as to keep older code from breaking.