Tech Tip: Using placeholders for Dataclasss.query() arguments
PRODUCT: 4D | VERSION: 20 | PLATFORM: Mac & Win
Published On: January 6, 2025
Placeholders are a parameter that is inserted into query strings that is replaced by another value when the query string is evaluated. 4D allows the usage of placeholders for attributePath, formula, and value within the queryString parameter.
The two types of placeholders are indexed placeholders and named placeholders. Indexed placeholders are inserted as indexes and their corresponding values are provided by value parameters. You can use up to 128 value parameters. Named placeholders have their corresponding vlaues provided within the attributes and/or paramteters objects.
Using placeholders in your queries is recommended for the following reasons:
- 1. It prevents malicious code insertion, especially in the case of user-filled variables
2. It prevents worryiung about formatting or character issues when dealing with aprameters that contain non-alphanumeric characters
3. It allows the use of variables or expressions in query arguments