website logo
👥 Community🎯 Samples on GitHub🚦System Status
💡 Guides
🚀 Examples
🍕 Developer Reference
⚡️ Changelog
🎥 Video Library
Navigate through spaces
⌘K
Examples Overview
Setting up your solution
Jig Types
Components
Datasource
Actions
Preview
Widgets
Expressions
Aggregation
Boolean
Comparison Operators
Date & Time
Path Operators
Functional Programming
Jigx Variables
Predicate Queries
String
Docs powered by
Archbee
Expressions

Boolean

6min

Within JSONata there are two types of Boolean expressions used to find out whether the result is true or false, namely:

  1. Boolean operators that include and, or Boolean functions that include:
    • $boolean()
    • $not()
    • $exists()

Configuration

Result

Expression

(And) Does the array of data contain both a name and an image?

=$boolean(@ctx.datasources.employees.name and @ctx.datasources.employees.img)

(Or) Does the array of data contain a phone number or email?

=$boolean(@ctx.datasources.employees.phoneNumber or @ctx.datasources.employees.email)

(If value =) If the name of the employee is "Mary Gomez", set true

=@ctx.datasources.employee.name = "Mary Gomez" ? true :false

(If value <) If the age of an employee is smaller than 20 set true.

=@ctx.datasources.employee.age < 20 ? true :false

(If array >) Does the array of data contain more than two objects?

=$count(@ctx.datasources.employees) > 2 ? true :false

Be careful when using complex expressions, such as expressions that iterate one datasource across another, as your solution performance could become slower. To avoid this, try to use the datasource queries to get the desired result rather than an expression.



Examples and code snippets 

Evaluating fields

Boolean expression
Boolean expression


This example evaluates static data in a component.enity to show the results in the entity field as a boolean.

See the full code sample in GitHub.

boolean.jigx
|
children:
  - type: component.entity
    options:
      children:
        - type: component.entity-field
          options:
            label: Does the array of data contain both a name and an image? (And)
            value: =$boolean(@ctx.datasources.employees.name and @ctx.datasources.employees.img)
        - type: component.entity-field
          options:
            label: Does the array of data contain a phone number or email? (Or)
            value: =$boolean(@ctx.datasources.employees.phoneNumber or @ctx.datasources.employees.email)
        - type: component.entity-field
          options:
            label: If name of employee is "Mary Gomez", set true. (If value =)
            value: =@ctx.datasources.employee.name = "Mary Gomez" ? true :false
        - type: component.entity-field
          options:
            label: If age of employee is smaller than 20 set true. (If value <)
            value: =@ctx.datasources.employee.age < 20 ? true :false
        - type: component.entity-field
          options:
            label: Does the array of data contain more than two objects? (If array >)
            value: =$count(@ctx.datasources.employees) > 2 ? true :false 


Placeholder

Example of writing a condition for a placeholder. If the number of objects in the array is greater than zero, the placeholder is not displayed. If it isn't and the field is empty, a placeholder will appear with the icon and the specified text.

See the full code sample in GitHub.

See tips and tricks when using placeholders for additional information.

placeholder.jigx
|
placeholders:
  - when: =$count(@ctx.datasources.employees-dynamic) > 0 ? false :true 
    title: There is no data
    icon: missing-data
    

Placeholder
Placeholder




Updated 31 Jul 2023
Did this page help you?
PREVIOUS
Aggregation
NEXT
Comparison Operators
Docs powered by
Archbee
TABLE OF CONTENTS
Configuration
Examples and code snippets
Evaluating fields
Placeholder
Docs powered by
Archbee
Copyright © 2023 Jigx, Inc. All rights reserved. Terms of Service