|
6 | 6 | description: Functions overview. |
7 | 7 | --- |
8 | 8 |
|
| 9 | +## Data |
| 10 | + |
| 11 | +### LET |
| 12 | + |
| 13 | +Allows you to define custom variables that can be used in the expression. |
| 14 | +Accepts 2 arguments: a map of variables to define and the expression to evaluate. |
| 15 | +The map keys should be the variable names prefixed with `$`. |
| 16 | + |
| 17 | +``` |
| 18 | +LET({ "$a": 1, "$b": 2 }, $a + $b) // 3 |
| 19 | +``` |
| 20 | + |
| 21 | +### PARSEJSON |
| 22 | + |
| 23 | +Parses a JSON string into a usable map/object structure. |
| 24 | +Accepts 1 argument: the JSON string to parse. |
| 25 | + |
| 26 | +``` |
| 27 | +PARSEJSON(Contact.Custom_JSON_Field__c) // Parses JSON from a field |
| 28 | +``` |
| 29 | + |
| 30 | +### PRINT |
| 31 | + |
| 32 | +Allows you to print a value to the playground console. |
| 33 | +Accepts 1 argument: the value to print. |
| 34 | + |
| 35 | +``` |
| 36 | +PRINT("Hello World") |
| 37 | +``` |
| 38 | + |
| 39 | +### RAWQUERY |
| 40 | + |
| 41 | +Allows you to run a raw query against the database. |
| 42 | +Accepts 1 argument: the query to run. |
| 43 | + |
| 44 | +``` |
| 45 | +RAWQUERY("SELECT Id, Name FROM Account LIMIT 10") |
| 46 | +``` |
| 47 | + |
| 48 | +### TRANSFORM |
| 49 | + |
| 50 | +Transforms any input using the provided expression. |
| 51 | +Provides a special variable `$source` in the inner expression that contains the original input. |
| 52 | + |
| 53 | +Accepts 2 arguments: the input to transform and the expression to evaluate. |
| 54 | + |
| 55 | +``` |
| 56 | +TRANSFORM("Hello World", UPPER($source)) // "HELLO WORLD" |
| 57 | +``` |
| 58 | + |
9 | 59 | ## Collection |
10 | 60 |
|
11 | 61 | ### AGGREGATEGROUPS |
@@ -351,58 +401,18 @@ Accepts 2 arguments: List of objects and an expression to evaluate. |
351 | 401 | WHERE([1, 2, 3], $current > 1) |
352 | 402 | ``` |
353 | 403 |
|
354 | | -## Data |
355 | | - |
356 | | -### LET |
357 | | - |
358 | | -Allows you to define custom variables that can be used in the expression. |
359 | | -Accepts 2 arguments: a map of variables to define and the expression to evaluate. |
360 | | -The map keys should be the variable names prefixed with `$`. |
361 | | - |
362 | | -``` |
363 | | -LET({ "$a": 1, "$b": 2 }, $a + $b) // 3 |
364 | | -``` |
365 | | - |
366 | | -### PARSEJSON |
367 | | - |
368 | | -Parses a JSON string into a usable map/object structure. |
369 | | -Accepts 1 argument: the JSON string to parse. |
370 | | - |
371 | | -``` |
372 | | -PARSEJSON(Contact.Custom_JSON_Field__c) // Parses JSON from a field |
373 | | -``` |
374 | | - |
375 | | -### PRINT |
376 | | - |
377 | | -Allows you to print a value to the playground console. |
378 | | -Accepts 1 argument: the value to print. |
379 | | - |
380 | | -``` |
381 | | -PRINT("Hello World") |
382 | | -``` |
383 | | - |
384 | | -### RAWQUERY |
385 | | - |
386 | | -Allows you to run a raw query against the database. |
387 | | -Accepts 1 argument: the query to run. |
388 | | - |
389 | | -``` |
390 | | -RAWQUERY("SELECT Id, Name FROM Account LIMIT 10") |
391 | | -``` |
| 404 | +## Date and Time |
392 | 405 |
|
393 | | -### TRANSFORM |
| 406 | +### ADDDAYS |
394 | 407 |
|
395 | | -Transforms any input using the provided expression. |
396 | | -Provides a special variable `$source` in the inner expression that contains the original input. |
| 408 | +Returns a date that is a specified number of days before or after a given date. |
397 | 409 |
|
398 | | -Accepts 2 arguments: the input to transform and the expression to evaluate. |
| 410 | +Accepts 2 arguments: the date and the number of days to add. |
399 | 411 |
|
400 | 412 | ``` |
401 | | -TRANSFORM("Hello World", UPPER($source)) // "HELLO WORLD" |
| 413 | +ADDDAYS(DATE(2020, 1, 1), 1) // 2020-01-02 |
402 | 414 | ``` |
403 | 415 |
|
404 | | -## Date and Time |
405 | | - |
406 | 416 | ### ADDMONTHS |
407 | 417 |
|
408 | 418 | Returns a date that is a specified number of months before or after a given date. |
@@ -785,103 +795,6 @@ OR(true, false, true) // true |
785 | 795 | OR(false, false, false) // false |
786 | 796 | ``` |
787 | 797 |
|
788 | | -## Math |
789 | | - |
790 | | -### ABS |
791 | | - |
792 | | -Returns the absolute value of a number. |
793 | | - |
794 | | -Accepts 1 argument: the number to evaluate. |
795 | | - |
796 | | -``` |
797 | | -ABS(-1) // 1 |
798 | | -``` |
799 | | - |
800 | | -### CEILING |
801 | | - |
802 | | -Returns the smallest integer greater than or equal to the specified number. |
803 | | - |
804 | | -Accepts 1 argument: the number to evaluate. |
805 | | - |
806 | | -``` |
807 | | -CEILING(1.5) // 2 |
808 | | -``` |
809 | | - |
810 | | -### FLOOR |
811 | | - |
812 | | -Returns the largest integer less than or equal to the specified number. |
813 | | - |
814 | | -Accepts 1 argument: the number to evaluate. |
815 | | - |
816 | | -``` |
817 | | -FLOOR(1.5) // 1 |
818 | | -``` |
819 | | - |
820 | | -### FORMATNUMBER |
821 | | - |
822 | | -Formats a number with comma as thousand separator. |
823 | | - |
824 | | -Accepts 1 or 2 arguments: the number to format and optionally the number of decimal places. |
825 | | - |
826 | | -``` |
827 | | -FORMATNUMBER(20000.53) // "20,000.53" |
828 | | -FORMATNUMBER(20000.53, 1) // "20,000.5" |
829 | | -``` |
830 | | - |
831 | | -### MAX |
832 | | - |
833 | | -Returns the largest value in a list of numbers. |
834 | | - |
835 | | -Accepts either a list of numbers as a single argument, or multiple numerical arguments. |
836 | | - |
837 | | -``` |
838 | | -MAX(1, 2, 3) // 3 |
839 | | -MAX([1, 2, 3]) // 3 |
840 | | -``` |
841 | | - |
842 | | -### MIN |
843 | | - |
844 | | -Returns the smallest value in a list of numbers. |
845 | | - |
846 | | -Accepts either a list of numbers as a single argument, or multiple numerical arguments. |
847 | | - |
848 | | -``` |
849 | | -MIN(1, 2, 3) // 1 |
850 | | -MIN([1, 2, 3]) // 1 |
851 | | -``` |
852 | | - |
853 | | -### MOD |
854 | | - |
855 | | -Returns the remainder of one number divided by another. |
856 | | - |
857 | | -Accepts 2 arguments: the dividend and the divisor. |
858 | | - |
859 | | -``` |
860 | | -MOD(5, 2) // 1 |
861 | | -``` |
862 | | - |
863 | | -### ROUND |
864 | | - |
865 | | -Returns a rounded number. Optionally specify the number of decimal places to round to. |
866 | | - |
867 | | -Accepts 1 or 2 arguments: the number to round and optionally the number of decimal places to round to. |
868 | | - |
869 | | -``` |
870 | | -ROUND(1.234) // 1 |
871 | | -ROUND(1.234, 2) // 1.23 |
872 | | -``` |
873 | | - |
874 | | -### TRUNC |
875 | | - |
876 | | -Returns a truncated number. Optionally specify the number of decimal places to truncate to. |
877 | | - |
878 | | -Accepts 1 or 2 arguments: the number to truncate and optionally the number of decimal places to truncate to. |
879 | | - |
880 | | -``` |
881 | | -TRUNC(1.234) // 1 |
882 | | -TRUNC(1.234, 2) // 1.23 |
883 | | -``` |
884 | | - |
885 | 798 | ## String |
886 | 799 |
|
887 | 800 | ### BEGINS |
@@ -1144,3 +1057,100 @@ Accepts 1 argument: the text to convert. |
1144 | 1057 | VALUE("123") // 123 |
1145 | 1058 | ``` |
1146 | 1059 |
|
| 1060 | +## Math |
| 1061 | + |
| 1062 | +### ABS |
| 1063 | + |
| 1064 | +Returns the absolute value of a number. |
| 1065 | + |
| 1066 | +Accepts 1 argument: the number to evaluate. |
| 1067 | + |
| 1068 | +``` |
| 1069 | +ABS(-1) // 1 |
| 1070 | +``` |
| 1071 | + |
| 1072 | +### CEILING |
| 1073 | + |
| 1074 | +Returns the smallest integer greater than or equal to the specified number. |
| 1075 | + |
| 1076 | +Accepts 1 argument: the number to evaluate. |
| 1077 | + |
| 1078 | +``` |
| 1079 | +CEILING(1.5) // 2 |
| 1080 | +``` |
| 1081 | + |
| 1082 | +### FLOOR |
| 1083 | + |
| 1084 | +Returns the largest integer less than or equal to the specified number. |
| 1085 | + |
| 1086 | +Accepts 1 argument: the number to evaluate. |
| 1087 | + |
| 1088 | +``` |
| 1089 | +FLOOR(1.5) // 1 |
| 1090 | +``` |
| 1091 | + |
| 1092 | +### FORMATNUMBER |
| 1093 | + |
| 1094 | +Formats a number with comma as thousand separator. |
| 1095 | + |
| 1096 | +Accepts 1 or 2 arguments: the number to format and optionally the number of decimal places. |
| 1097 | + |
| 1098 | +``` |
| 1099 | +FORMATNUMBER(20000.53) // "20,000.53" |
| 1100 | +FORMATNUMBER(20000.53, 1) // "20,000.5" |
| 1101 | +``` |
| 1102 | + |
| 1103 | +### MAX |
| 1104 | + |
| 1105 | +Returns the largest value in a list of numbers. |
| 1106 | + |
| 1107 | +Accepts either a list of numbers as a single argument, or multiple numerical arguments. |
| 1108 | + |
| 1109 | +``` |
| 1110 | +MAX(1, 2, 3) // 3 |
| 1111 | +MAX([1, 2, 3]) // 3 |
| 1112 | +``` |
| 1113 | + |
| 1114 | +### MIN |
| 1115 | + |
| 1116 | +Returns the smallest value in a list of numbers. |
| 1117 | + |
| 1118 | +Accepts either a list of numbers as a single argument, or multiple numerical arguments. |
| 1119 | + |
| 1120 | +``` |
| 1121 | +MIN(1, 2, 3) // 1 |
| 1122 | +MIN([1, 2, 3]) // 1 |
| 1123 | +``` |
| 1124 | + |
| 1125 | +### MOD |
| 1126 | + |
| 1127 | +Returns the remainder of one number divided by another. |
| 1128 | + |
| 1129 | +Accepts 2 arguments: the dividend and the divisor. |
| 1130 | + |
| 1131 | +``` |
| 1132 | +MOD(5, 2) // 1 |
| 1133 | +``` |
| 1134 | + |
| 1135 | +### ROUND |
| 1136 | + |
| 1137 | +Returns a rounded number. Optionally specify the number of decimal places to round to. |
| 1138 | + |
| 1139 | +Accepts 1 or 2 arguments: the number to round and optionally the number of decimal places to round to. |
| 1140 | + |
| 1141 | +``` |
| 1142 | +ROUND(1.234) // 1 |
| 1143 | +ROUND(1.234, 2) // 1.23 |
| 1144 | +``` |
| 1145 | + |
| 1146 | +### TRUNC |
| 1147 | + |
| 1148 | +Returns a truncated number. Optionally specify the number of decimal places to truncate to. |
| 1149 | + |
| 1150 | +Accepts 1 or 2 arguments: the number to truncate and optionally the number of decimal places to truncate to. |
| 1151 | + |
| 1152 | +``` |
| 1153 | +TRUNC(1.234) // 1 |
| 1154 | +TRUNC(1.234, 2) // 1.23 |
| 1155 | +``` |
| 1156 | + |
0 commit comments