When to use functions in Chorus:
You can use functions to create commands in Chorus without having to write long code.
How to use functions in Chorus:
When writing functions in Chorus, the curly bracket operator { } signals that the command is starting and ending. This is why you cannot use curly brackets on the client (end user) side of your applications.
When NOT to use curly brackets:
There are a few cases in which you do not need to use the curly bracket operator.
These are outlined below:
|
Only when the following functions are used in a set starting value, they do not require { }: _currentdate _currenttime _currentdatetime |
|
| Whenever you see </>, that means there’s a super secret curly bracket already there. No need for {} this time | |
| Same as above, you can visually see the {} that Chorus is inserting, so you don’t need to type it out yourself |
Some basic functions to get you started:
| Function | Result |
|
_currentuser.email
|
The logged in user’s email. |
|
_currentuser.phone1 |
The registered user’s phone number (includes country code) Finds a specific phone number in an array/list. Example: |
|
_currentuser.name *If a user has added a phone number to their Chorus profile |
Other available shortcuts that correspond to current user data |
|
_rand(x) |
Random number generator returns a random number up to the value provided. E.g. if x = 10, it will give results from 1-9. It will return integers for all provided values above 1. If you set x to be 1, it will return a value less than zero of 16 digits. |
|
_currentdate |
The current date (does not require curly brackets) |
|
_currenttime |
The current time (does not require curly brackets) |
|
_currentdatetime |
The current date AND time together (does not require curly brackets) |
|
_params.urlinsert |
Chorus can pass values from the URL to a response set using this function. The URL syntax is https://$URL/pageID?urlinsert=somevalue
If you navigate to that link, you can build a response set that saves the data in “somevalue”.
For example, if you have the URL https://$URL/pageID?id=123456789 then you’d set your response set up like this to save the user ID “123456789” to the “my.users” variable |
|
_datediff |
Compare two dates.
Syntax:
NOTE: you can technically use “hours” and “seconds” in place of days, but Chorus’s _datediff function only operates in full days. So even if you do this:
Chorus is going to return: 1 |
|
|
|
Comments
0 comments
Please sign in to leave a comment.