api:check
Version 23.4.8843
api:check
Version 23.4.8843
The api:check keyword can be used with or without a value parameter. Without a value parameter, it is used to ensure that an attribute is present in an item and that it is not a null string before the body of the api:check is executed.
If a value parameter is specified, the api:check body executes only if the expression evaluates to true. Other values are considered false. The evaluation is case insensitive.
Like other simple conditionals in APIScript, it can be paired with an api:else keyword. Note that, unlike api:equals, api:check does not throw an exception if the attribute does not exist in the item.
Parameters
- item: The item in which to check the attribute. Specifying an item is not required. If no item is specified, the default output item is used instead.
- attr: The name of the attribute to check. This parameter is required.
- value: An expression that evaluates to true or false. For example, the result of a formatter that returns true or false.
- action: The action to execute if the expression evaluates to true. Allowed values: break, continue.
Control Attributes
None
Examples
Check whether an attribute was set before using it:
<api:check attr="_input.In_Stock">
...
</api:check>
See Also
- api:exists: Check if an attribute exists.
- api:equals: Check for equality.
- api:notequals: Check for inequality.