Website logo
✅ Sign up👥 Community🎯 Samples on GitHub🚦 System Status
💡 Guides
🚀 Examples
🍕 Developer Reference
⚡️ Changelog
🎥 Video Library
Navigate through spaces
⌘K
Welcome to Jigx Documentation
Getting started
Creating an account
Install the Jigx Builder
Use templates to create apps
Create an app from scratch
Use pre-built solutions
Planning your app
Understanding the basics
Jigx Overview
Jigx Concepts
Authentication
Jigx color palette
Jigx icons
Building Apps with Jigx
Jigx Builder Overview
Install
Settings
Editor
Create a new Jigx Solution
Publishing a solution
Debugging
Home Hub Experience
Index settings
Templates
Inputs & Outputs
Forms
Data
Expressions
Advanced Expressions
Expressions - cheatsheet
Notifications
Stories
Localization
Tips, tricks and shortcuts
Administration
Management Overview
Permissions - User Roles
Users
Solutions
Notifications
Organization Settings
Troubleshooting (Organization)
Quick Start
My profile
Docs powered by Archbee
Building Apps with Jigx

Expressions - cheatsheet

32min

 wants to help you build solutions quickly and easily. To help you do this, here is a list of functionality or data results you might want to use in your app with the expression used to achieve it. This is a starting point; you can adapt or add to the expression as needed to get the expected data results when building solutions. Refer to the Expressions section in the Examples tab for working examples and code snippets for various JSONata expressions.



Create Filters on a list (Path Operator expression)

YAML
=$filter(@ctx.datasources.filter-list, function($v){$contains($string($v.status), $string(@ctx.components.filter-list.state.filter != null ? @ctx.components.filter-list.state.filter:'')) })[]


Create Search for a list (Path Operator expression)

YAML
=$filter(@ctx.datasources.dmsrole-nonlife, function($v){ @ctx.datasources.dmsrole-nonlife ? $contains($string($v.DMSRole),$string(@ctx.components.RosterPositionID.state.searchText != null ? @ctx.components.RosterPositionID.state.searchText:'')) :true})[]


Create a placeholder (Boolean expression)

See tips and tricks when using placeholders for additional information.

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


Check if a field's value is Null (Boolean expression)

YAML
=@ctx.solution.state.missionNumber != null ? true: false

YAML
=$type(@ctx.current.item.EngineStop) = 'null' ? true: false

YAML
=$count(@ctx.datasources.data.id) = 0 true:false


Evaluate PathsData (String Function expression)

YAML
=$eval(@ctx.current.item.pathsData)


Use evaluate to change data text to JSON object

YAML
=$eval(@ctx.datasources.weatherData.temperatures_max)


Base64 image (String expression)

YAML
="data:image/png;base64," & @ctx.datasources.mydata.data


String to number (String expression)

YAML
=($number(@ctx.datasources.tmra-graph.Total) >= 5)

YAML
=($number(@ctx.datasources.tmra-graph.Total) < 8) ? true : false


Number to string (String expression)

YAML
=$string(@ctx.current.item.ID)


Combining first and last name (Concatenate)

YAML
=(@ctx.current.item.firstName & ' ' & @ctx.current.item.lastName)


Splitting display name into first and last name (String expression)

YAML
=$substring($substringBefore(@ctx.inputs.info.FromUserDisplayName, ' '), 0, 1)


Two letter placeholder for avatar (String expression)

YAML
=$uppercase($substring($substringBefore(@ctx.current.item.firstName, " "), 0, 1) & $substring($substringAfter(@ctx.current.item.lastName, " ") , 0, 1) )


True or False ? (Boolean expression)

YAML
=$boolean(@ctx.datasources.tmra.TwoPilots) ? true : false


Adding an expression into a string

YAML
('Hello, my name is ' & @ctx.user.displayname)
('Day ' & @ctx.datasource.mydata.date & ' agenda')
"Day one agenda"


Working with Date and Time expressions

Convert UTC to milliseconds

YAML
=$toMillis()


Convert millisecond to UTC

YAML
=$fromMillis()


Transform any date to new format

YAML
=$fromMillis($toMillis(@ctx.inputs.info.EndDate), '[M01]/[D01]/[Y0001]', @ctx.system.timezone.offset)


Add days to date + convert to local timezone + format

YAML
=$fromMillis($toMillis(@ctx.datasources.mission-list-global.CrewNotified) + 86400000,'[Y0001]-[M01]-[D01]T[H01]:[m01]:[s01].[s001]Z',@ctx.system.timezone.offset)


Get currently logged in user (Jigx system expression)

Results can include id, email, name.

YAML
=@ctx.user.displayName


Is the mobile device offline (Jigx system expression)

YAML
=@ctx.system.isOffline = true


Create a unique GUID

YAML
=$uuid()


Formatting Numbers (Numeric functions)

YAML
=$formatNumber(@ctx.inputs.info.TotalSQft, '#,###')


Sorting an array of objects using a lambda (embedded) function

This example with data and the result can be viewed in JSONata exerciser.

YAML
$sort($.{"id": id,"amount":amount,"name":name}, function($l, $r) { $l.amount > $r.amount})


Setting up complex objects with an embedded array

This example with data and the result can be viewed in JSONata exerciser.

YAML
$.{"message": {"subject": subject,"body": {"contentType": "Text","content":
  messageBody},"toRecipients": toAddresses#$i.{"emailAddress":
  {"address":$}}[]}}


Create a basic join on a static datasource to a local datasource  

YAML
=@ctx.datasources.staticdatabase@$p.$merge([$p, @ctx.datasources.localdatabase[id = $p.id]]


Transform longitude and latitude data to show markers on a location component

YAML
markersData: |
        =@ctx.datasources.jobs.{"lng": $number($.lng), "lat": $number($.lat)}


Find the value relative to the current node so all paths are relative to it

YAML
=$.path.to.value


 Find the value relative the root node of the supplied context, no matter what is the current node

 converts @ctx. to $$. when executing expressions in jsonata

YAML
=$$.path.to.value


Use the JSONata built-in index parameter combined with a filter

YAML
=@ctx.datasources.questions#$i.answer[$i=3]






Updated 30 Oct 2023
Did this page help you?
PREVIOUS
Advanced Expressions
NEXT
Notifications
Docs powered by Archbee
TABLE OF CONTENTS
Create Filters on a list (Path Operator expression)
Create Search for a list (Path Operator expression)
Create a placeholder (Boolean expression)
Check if a field's value is Null (Boolean expression)
Evaluate PathsData (String Function expression)
Use evaluate to change data text to JSON object
Base64 image (String expression)
String to number (String expression)
Number to string (String expression)
Combining first and last name (Concatenate)
Splitting display name into first and last name (String expression)
Two letter placeholder for avatar (String expression)
True or False ? (Boolean expression)
Adding an expression into a string
Working with Date and Time expressions
Convert UTC to milliseconds
Convert millisecond to UTC
Transform any date to new format
Add days to date + convert to local timezone + format
Get currently logged in user (Jigx system expression)
Is the mobile device offline (Jigx system expression)
Create a unique GUID
Formatting Numbers (Numeric functions)
Sorting an array of objects using a lambda (embedded) function
Setting up complex objects with an embedded array
Create a basic join on a static datasource to a local datasource  
Transform longitude and latitude data to show markers on a location component
Find the value relative to the current node so all paths are relative to it
 Find the value relative the root node of the supplied context, no matter what is the current node
Use the JSONata built-in index parameter combined with a filter
Docs powered by Archbee
Copyright © 2023 Jigx, Inc. All rights reserved. Terms of Service