|
|
Line 38: |
Line 38: |
| |<code>IsNotEmpty(Contact.LastName)</code><br /><code>Plural("word")</code><br /><code>If(Count(Contact) < 3, "friends", "acquaintances")</code> | | |<code>IsNotEmpty(Contact.LastName)</code><br /><code>Plural("word")</code><br /><code>If(Count(Contact) < 3, "friends", "acquaintances")</code> |
| |<code>Yes</code><br /><code>"words"</code><br /><code>"acquaintances"</code> | | |<code>Yes</code><br /><code>"words"</code><br /><code>"acquaintances"</code> |
| |Functions compute a result based on their arguments (inputs). Function calls can be nested within each other. | | |[[Function|Functions]] compute a result based on their arguments (inputs). Function calls can be nested within each other. |
| |- | | |- |
| |'''Constant''' | | |'''Constant''' |
Line 155: |
Line 155: |
| |} | | |} |
| Note: The <code>+</code> operator can be used for both addition and concatenation; if at least one value is a number then it will perform addition. Use the <code>&</code> operator to avoid ambiguity. | | Note: The <code>+</code> operator can be used for both addition and concatenation; if at least one value is a number then it will perform addition. Use the <code>&</code> operator to avoid ambiguity. |
|
| |
| == Function Reference ==
| |
| This section documents each of the functions that can be used in expressions. The documentation is also available within the [[Desktop App]].
| |
|
| |
| === Text Functions ===
| |
| These functions operate on text.
| |
| '''An'''(''word'')
| |
| Produces 'a' or 'an' according to grammar rules for a particular word.
| |
|
| |
| * ''<code>word</code>'' - Word.
| |
| '''Filter'''(''text'', [''allowed'', ...])
| |
| Filters text to allow only specific values.
| |
|
| |
| * ''<code>text</code>'' - Text.
| |
| * ''<code>allowed</code>'' - Allowed values.
| |
| '''IsAre'''(''value'')
| |
| When there are two or more values, produces 'are'. Otherwise, produces 'is'.
| |
|
| |
| * ''<code>value</code>'' - Number or set of values.
| |
| '''Lower'''(''text'')
| |
| Converts text to 'lowercase'.
| |
|
| |
| * ''<code>text</code>'' - Text.
| |
| '''Optional'''([''values'', ...])
| |
| Joins consecutive values together. If any value is empty, the result is also empty.
| |
|
| |
| * ''<code>values</code>'' - Any value.
| |
| '''Plural'''(''word'')
| |
| Converts a word to its plural.
| |
|
| |
| * ''<code>word</code>'' - Singular form of the word.
| |
| '''PluralOf'''(''value'', ''word'')
| |
| Converts a word to its plural when there are two or more values.
| |
|
| |
| * ''<code>value</code>'' - Number or set of values.
| |
| * ''<code>word</code>'' - Singular form of the word.
| |
| '''Possessive'''(''word'')
| |
| Adds a possessive apostrophe to a word according to grammar rules.
| |
|
| |
| * ''<code>word</code>'' - Word.
| |
| '''Replace'''(''text'', ''find'', ''replace'')
| |
| Replaces all occurrences of a particular word/phrase in the text.
| |
|
| |
| * ''<code>text</code>'' - Subject text.
| |
| * ''<code>find</code>'' - Word/phrase to find. Can be a [[wikipedia:Regular_expression|regular expression]].
| |
| * ''<code>replace</code>'' - Replacement text. Can include capture groups.
| |
| '''ReplaceWith'''(''text'', ''find'', ''replace'')
| |
| Replaces the entire value if it contains a particular word/phrase.
| |
|
| |
| * ''<code>text</code>'' - Subject text.
| |
| * ''<code>find</code>'' - Word/phrase to find. Can be a [[wikipedia:Regular_expression|regular expression]].
| |
| * ''<code>replace</code>'' - Replacement text. Can include capture groups.
| |
| '''Sentence'''(''text'')
| |
| Converts text to 'Sentence case'.
| |
|
| |
| * ''<code>text</code>'' - Text.
| |
| '''Title'''(''text'')
| |
| Converts text to 'Title Case'.
| |
|
| |
| * ''<code>text</code>'' - Text.
| |
| '''Upper'''(''text'')
| |
| Converts text to 'UPPERCASE'.
| |
|
| |
| * ''<code>text</code>'' - Text.
| |
|
| |
| === Number Functions ===
| |
| These functions operate on numbers.
| |
| '''Number'''(''number'', [''thousands'' = Yes])
| |
| Formats a whole number as text.
| |
|
| |
| * ''<code>number</code>'' - Number.
| |
| * ''<code>thousands</code>'' - Use thousands separator (Yes/No).
| |
| '''Decimal'''(''number'', [''decimals'' = 2], [''thousands'' = Yes])
| |
| Formats a decimal number as text.
| |
|
| |
| * ''<code>number</code>'' - Number.
| |
| * ''<code>decimals</code>'' - Decimal places.
| |
| * ''<code>thousands</code>'' - Use thousands separator (Yes/No).
| |
| '''Currency'''(''number'', [''decimals'' = 2], [''thousands'' = Yes])
| |
| Formats a currency value as text.
| |
|
| |
| * ''<code>number</code>'' - Number.
| |
| * ''<code>decimals</code>'' - Decimal places.
| |
| * ''<code>thousands</code>'' - Use thousands separator (Yes/No).
| |
| '''Min'''(''set'')
| |
| Calculates the smallest value in a set.
| |
|
| |
| * ''<code>set</code>'' - A set of values.
| |
| '''Max'''(''set'')
| |
| Calculates the largest value in a set.
| |
|
| |
| * ''<code>set</code>'' - A set of values.
| |
| '''Sum'''(''set'')
| |
| Calculates the sum of the values in a set.
| |
|
| |
| * ''<code>set</code>'' - A set of values.
| |
| '''Avg'''(''set'')
| |
| Calculates the average of a set.
| |
|
| |
| * ''<code>set</code>'' - A set of values.
| |
| '''NumberInWords'''(''number'')
| |
| Converts a number to words.
| |
|
| |
| * ''<code>number</code>'' - Number.
| |
| '''CurrencyInWords'''(''number'')
| |
| Converts currency to an amount in words.
| |
|
| |
| * ''<code>number</code>'' - Number.
| |
| '''WordsToNumber'''(''text'')
| |
| Converts words to a number.
| |
|
| |
| * ''<code>text</code>'' - Text.
| |
| '''WordsToCurrency'''(''text'')
| |
| Converts an amount in words to currency.
| |
|
| |
| * ''<code>text</code>'' - Text.
| |
| '''Ordinal'''(''number'')
| |
| Adds the ordinal suffix (st/nd/rd/th) to a number.
| |
|
| |
| * ''<code>number</code>'' - Number.
| |
|
| |
| === Conditional Functions ===
| |
| These functions are used to make decisions.
| |
| '''If'''(''condition'', ''yes'', [''no''])
| |
| Tests a condition and gives a different value depending on the result.
| |
|
| |
| * ''<code>condition</code>'' - Yes/no.
| |
| * ''<code>yes</code>'' - Value if true.
| |
| * ''<code>no</code>'' - Value if false.
| |
| '''IsEmpty'''(''value'')
| |
| Tests whether a set or value is empty (yes/no).
| |
|
| |
| * ''<code>value</code>'' - Any value.
| |
| '''IsNotEmpty'''(''value'')
| |
| Tests whether a set or value is not empty (yes/no).
| |
|
| |
| * ''<code>value</code>'' - Any value.
| |
| '''AllEmpty'''(''set'')
| |
| Tests whether all of the values in a set are empty (yes/no).
| |
|
| |
| * ''<code>set</code>'' - A set of values.
| |
| '''AllNotEmpty'''(''set'')
| |
| Tests whether all of the values in a set are not empty (yes/no).
| |
|
| |
| * ''<code>set</code>'' - A set of values.
| |
| '''DefaultIfEmpty'''(''value'', [''default'', ...])
| |
| Provides a default for when a value is empty. Short-hand for: <code>If(IsEmpty(value), default, value)</code>
| |
|
| |
| * ''<code>value</code>'' - Any value.
| |
| * ''<code>default</code>'' - Value if empty.
| |
| '''DefaultIfMultiple'''(''value'', ''default'')
| |
| Provides a default for when there are two or more values. Short-hand for: <code>If(Count(value) > 1, default, value)</code>
| |
|
| |
| * ''<code>value</code>'' - Any value.
| |
| * ''<code>default</code>'' - Value if multiple.
| |
| '''Not'''(''condition'')
| |
| Reverses the result of a condition (yes/no).
| |
|
| |
| * ''<code>condition</code>'' - Yes/no.
| |
| '''Contains'''(''set'', ''value'')
| |
| Tests whether a set contains a particular item (yes/no).
| |
|
| |
| * ''<code>set</code>'' - A set of values.
| |
| * ''<code>value</code>'' - Any value.
| |
| '''Intersects'''(''set1'', ''set2'')
| |
| Tests whether two sets have any items in common (yes/no).
| |
|
| |
| * ''<code>set1</code>'' - A set of values.
| |
| * ''<code>set2</code>'' - A set of values.
| |
| '''Case'''(''value'', [''cases'', ...])
| |
| Matches a value against a set of cases. See also: <code>When</code> and <code>Else</code>
| |
|
| |
| * ''<code>value</code>'' - Value to test.
| |
| * ''<code>cases</code>'' - Cases to match.
| |
| '''When'''(''value'', ''result'')
| |
| Specifies a result for a particular value in a <code>Case</code> function.
| |
|
| |
| * ''<code>value</code>'' - Value to match.
| |
|
| |
| * ''<code>result</code>'' - Result if matched.
| |
| '''Else'''(''result'')
| |
| Specifies a result for when nothing matches the value in a <code>Case</code> function.
| |
|
| |
| * ''<code>result</code>'' - Value if no match.
| |
|
| |
| === Date and Time Functions ===
| |
| These functions operate on date and time values.
| |
| '''Date'''(''date'', ''format'')
| |
| Formats a date as text.
| |
|
| |
| * ''<code>date</code>'' - Date/time.
| |
| * ''<code>format</code>'' - Date/time format. Can be pre-defined (e.g. <code>DateStyle1</code>) or a custom format
| |
| '''AddMinutes'''(''date'', ''minutes'')
| |
| Adds a number of minutes to a date/time value.
| |
|
| |
| * ''<code>date</code>'' - Date/time.
| |
| * ''<code>minutes</code>'' - Number of minutes. Use negative numbers to subtract.
| |
| '''AddHours'''(''date'', ''hours'')
| |
| Adds a number of hours to a date/time value.
| |
|
| |
| * ''<code>date</code>'' - Date/time.
| |
| * ''<code>hours</code>'' - Number of hours. Use negative numbers to subtract.
| |
| '''AddDays'''(''date'', ''days'')
| |
| Adds a number of days to a date/time value.
| |
|
| |
| * ''<code>date</code>'' - Date/time.
| |
| * ''<code>days</code>'' - Number of days. Use negative numbers to subtract.
| |
| '''AddWeekDays'''(''date'', ''days'')
| |
| Adds a number of weekdays (skipping over weekends) to a date/time value.
| |
|
| |
| * ''<code>date</code>'' - Date/time.
| |
| * ''<code>days</code>'' - Number of weekdays. Use negative numbers to subtract.
| |
| '''AddMonths'''(''date'', ''months'')
| |
| Adds a number of months to a date/time value.
| |
|
| |
| * ''<code>date</code>'' - Date/time.
| |
| * ''<code>months</code>'' - Number of months. Use negative numbers to subtract.
| |
| '''AddYears'''(''date'', ''years'')
| |
| Adds a number of years to a date/time value.
| |
|
| |
| * ''<code>date</code>'' - Date/time.
| |
| * ''<code>years</code>'' - Number of years. Use negative numbers to subtract.
| |
| '''SetTime'''(''date'', [''hour''], [''minute''])
| |
| Sets the time component of a date/time value.
| |
|
| |
| * ''<code>date</code>'' - Date/time.
| |
| * ''<code>hour</code>'' - Hour (0-23).
| |
| * ''<code>minute</code>'' - Minute (0-59).
| |
| '''SetTimeZone'''(''date'', ''tz'')
| |
| Changes the time zone of a date/time value.
| |
|
| |
| * ''<code>date</code>'' - Date/time.
| |
| * ''<code>tz</code>'' - Offset (-14 to 14).
| |
| '''Day'''(''date'')
| |
| Gets the day component of a date/time value.
| |
|
| |
| * ''<code>date</code>'' - Date/time.
| |
| '''Month'''(''date'')
| |
| Gets the month component of a date/time value.
| |
|
| |
| * ''<code>date</code>'' - Date/time.
| |
| '''Year'''(''date'')
| |
| Gets the year component of a date/time value.
| |
|
| |
| * ''<code>date</code>'' - Date/time.
| |
| '''Hour'''(''date'')
| |
| Gets the hour component (0-23) of a date/time value.
| |
|
| |
| * ''<code>date</code>'' - Date/time.
| |
| '''Minute'''(''date'')
| |
| Gets the minute component (0-59) of a date/time value.
| |
|
| |
| * ''<code>date</code>'' - Date/time.
| |
| '''Today'''()
| |
| Today's date.
| |
|
| |
| '''Now'''()
| |
| Today's date, including the current time.
| |
|
| |
| '''Days'''(''date1'', ''date2'')
| |
| Gets the number of days between two date/time values.
| |
|
| |
| * ''<code>date1</code>'' - Date/time.
| |
| * ''<code>date2</code>'' - Date/time.
| |
| '''Minutes'''(''date1'', ''date2'')
| |
| Gets the number of minutes between two date/time values.
| |
|
| |
| * ''<code>date1</code>'' - Date/time.
| |
| * ''<code>date2</code>'' - Date/time.
| |
| '''Years'''(''date1'', ''date2'')
| |
| Gets the number of years between two date/time values, rounded down.
| |
|
| |
| * ''<code>date1</code>'' - Date/time.
| |
| * ''<code>date2</code>'' - Date/time.
| |
| '''Age'''(''date'')
| |
| Gets the number of years that have elapsed since a particular date, rounded down.
| |
|
| |
| * ''<code>date</code>'' - Date/time.
| |
| '''MakeDate'''(''year'', [''month''], [''day''])
| |
| Constructs a date value from its year, month and day components.
| |
|
| |
| * ''<code>year</code>'' - Year number.
| |
| * ''<code>month</code>'' - Month number (1-12).
| |
| * ''<code>day</code>'' - Day number (1-31).
| |
| '''HoursAndMinutes'''(''minutes'')
| |
| Expresses a quantity of minutes in hours and minutes.
| |
|
| |
| * ''<code>minutes</code>'' - Number of minutes.
| |
|
| |
| === Set Functions ===
| |
| These functions operate on sets of values.
| |
| '''Set'''([''values'', ...])
| |
| Creates a set from one or more values.
| |
|
| |
| * ''<code>values</code>'' - Values.
| |
| '''Range'''(''set'', [''start'' = 1], [''count''])
| |
| Creates a subset of a set.
| |
|
| |
| * ''<code>set</code>'' - A set of values or assets.
| |
| * ''<code>position</code>'' - Starting position.
| |
| * ''<code>count</code>'' - Number of items (maximum) to include.
| |
| '''Union'''(''set1'', ''set2'')
| |
| Gets the union of two sets.
| |
|
| |
| * ''<code>set1</code>'' - A set of values or assets.
| |
| * ''<code>set2</code>'' - A set of values or assets.
| |
| '''Except'''(''set'', ''excluded'')
| |
| Gets the items in a set which do not appear in some other set.
| |
|
| |
| * ''<code>set</code>'' - A set of values or assets.
| |
| * ''<code>excluded</code>'' - Values/assets to exclude.
| |
| '''Intersection'''(''set1'', ''set2'')
| |
| Gets the intersection of two sets.
| |
|
| |
| * ''<code>set1</code>'' - A set of values or assets.
| |
| * ''<code>set2</code>'' - A set of values or assets.
| |
| '''Sort'''(''set'', [''smart'' = Yes])
| |
| Sorts the items in a set.
| |
|
| |
| * ''<code>set</code>'' - A set of values or assets.
| |
| * ''<code>smart</code>'' - Whether to use natural language sorting rules.
| |
| '''RSort'''(''set'', [''smart'' = Yes])
| |
| Sorts the items in a set in reverse order.
| |
|
| |
| * ''<code>set</code>'' - A set of values or assets.
| |
| * ''<code>smart</code>'' - Whether to use natural language sorting rules.
| |
| '''NotEmpty'''(''set'')
| |
| Filters a set by excluding empty values.
| |
|
| |
| * ''<code>set</code>'' - A set of values or assets.
| |
| '''Unique'''(''set'')
| |
| Filters a set by excluding duplicate values.
| |
|
| |
| * ''<code>set</code>'' - A set of values or assets.
| |
| '''Each'''(''set'', ''expression'')
| |
| Evaluates an expression for each item in a set.
| |
|
| |
| * ''<code>set</code>'' - A set of values or assets.
| |
| * ''<code>expression</code>'' - Any expression.
| |
| '''First'''(''set'')
| |
| Takes the first item in a set.
| |
|
| |
| * ''<code>set</code>'' - A set of values or assets.
| |
| '''Last'''(''set'')
| |
| Takes the last item in a set.
| |
|
| |
| * ''<code>set</code>'' - A set of values or assets.
| |
| '''Item'''(''set'', ''position'')
| |
| Takes the n-th item in a set.
| |
|
| |
| * ''<code>set</code>'' - A set of values or assets.
| |
| * ''<code>position</code>'' - Position of the desired item.
| |
| '''List'''(''set'', [''conjunction'' = "and"])
| |
| Joins a set of values together using commas and a conjunction between the last two items.
| |
|
| |
| * ''<code>set</code>'' - A set of values.
| |
| * ''<code>conjunction</code>'' - The word that is inserted between the last two items.
| |
| '''Join'''(''set'', [''separator'' = ", "])
| |
| Joins a set of values together with a separator between each item.
| |
|
| |
| * ''<code>set</code>'' - A set of values.
| |
| * ''<code>separator</code>'' - Separator between each item.
| |
| '''Lines'''(''set'')
| |
| Joins a set of values together with each item on a separate line.
| |
|
| |
| * ''<code>set</code>'' - A set of values.
| |
| '''Paragraphs'''(''set'')
| |
| Joins a set of values together with each item in a separate paragraph.
| |
|
| |
| * ''<code>set</code>'' - A set of values.
| |
| '''Count'''(''set'')
| |
| Counts the number of items (including empty values) in a set.
| |
|
| |
| * ''<code>set</code>'' - A set of values or assets.
| |
| '''CountNotEmpty'''(''set'')
| |
| Counts the number of non-empty values in a set.
| |
|
| |
| * ''<code>set</code>'' - A set of values or assets.
| |
|
| |
| === Contact Functions ===
| |
| These functions operate on contact assets.
| |
| '''SubjectivePronoun'''(''contact'')
| |
| Gets the subjective pronoun (he/she/they) for one or more contacts.
| |
|
| |
| * ''<code>contact</code>'' - Contact.
| |
| '''ObjectivePronoun'''(''contact'')
| |
| Gets the objective pronoun (him/her/them) for one or more contacts.
| |
|
| |
| * ''<code>contact</code>'' - Contact.
| |
| '''PossessivePronoun'''(''contact'')
| |
| Gets the subjective pronoun (his/her/their) for one or more contacts.
| |
|
| |
| * ''<code>contact</code>'' - Contact.
| |
|
| |
| === Telephone Functions ===
| |
| These functions operate on telephone/fax numbers.
| |
| '''Telephone'''(''phone'', [''format''])
| |
| Formats a telephone number.
| |
|
| |
| * ''<code>phone</code>'' - Telephone number.
| |
| * ''<code>format</code>'' - Format (<code>Extension</code>, <code>Local</code>, <code>Domestic</code> or <code>International</code>).
| |
|
| |
| === Tag Functions ===
| |
| These functions operate on tags.
| |
| '''HasTag'''(''item'', ''tag'')
| |
| Determines whether an item has a particular tag (yes/no).
| |
|
| |
| * ''<code>item</code>'' - A taggable item (e.g. contact).
| |
| * ''<code>tag</code>'' - Name of the tag.
| |
|
| |
| === Special Purpose Functions ===
| |
| '''Resource'''(''type'', ''id'')
| |
| Creates a reference to a subscriber-specific resource in ContactsLaw.
| |
|
| |
| * ''<code>type</code>'' - Resource type.
| |
| * ''<code>id</code>'' - Resource identifier.
| |
| [[Category:Key Terms]] | | [[Category:Key Terms]] |