Skip to content

Commit cdfaa46

Browse files
Florian KrönertFlorian Krönert
authored andcommitted
2 parents 3a23573 + 3e3c62f commit cdfaa46

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

README.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ A domain specific language for Dynamics CRM allowing for easy text template proc
2424
- [And](#and)
2525
- [Not](#not)
2626
- [IsNull](#isnull)
27+
- [Coalesce](#coalesce)
28+
- [Case](#case)
2729
- [IsEqual](#isequal)
2830
- [IsLess](#isless)
2931
- [IsLessEqual](#islessequal)
@@ -36,6 +38,7 @@ A domain specific language for Dynamics CRM allowing for easy text template proc
3638
- [Last](#last)
3739
- [Union](#union)
3840
- [Map](#map)
41+
- [Filter](#filter)
3942
- [Sort](#sort)
4043
- [RecordTable](#recordtable)
4144
- [PrimaryRecord](#primaryrecord)
@@ -197,6 +200,39 @@ Example:
197200
IsNull( Value ("parentaccountid") )
198201
```
199202

203+
### Coalesce
204+
**Available since: v3.9.6**
205+
206+
Uses the first non-null value of all parameters passed.
207+
208+
Example:
209+
``` JavaScript
210+
Coalesce ( Value ( "parentaccountid" ), Value ( "parentcontactid" ), "None" )
211+
```
212+
213+
If parentaccountid is not null, it will be used.
214+
Otherwise, if parentcontactid is not null, it will be used.
215+
If none of these two are not null, the static "None" will be used.
216+
217+
### Case
218+
**Available since: v3.9.6**
219+
220+
Checks a list of conditions followed by their values and uses the first true condition's value as result.
221+
If none matches, the last value is used as default result.
222+
223+
Because of this, the list of parameters has to be odd ( 2 * n + 1, where n is the number of conditions, where each condition has one check followed by one result plus the last value as default).
224+
225+
Example:
226+
``` JavaScript
227+
Case ( IsLess ( Value ("creditlimit"), 1000 ), "Low", IsLess ( Value ("creditlimit"), 50000 ), "Medium", IsLess ( Value ("credilimit"), 100000 ), "High", "None" )
228+
```
229+
230+
In above example, if credit limit is below 1000, it will return "Low".
231+
Otherwise, if it is less than 50.000, it will return "Medium".
232+
Otherwise, if it is less than 100.000, it will return "High".
233+
234+
If none matches, for example if creditlimit is null, it will return "None".
235+
200236
### IsEqual
201237
Checks if two parameters are equal. If yes, true is returned, otherwise false.
202238
The parameters are required to be of the same type.
@@ -365,6 +401,26 @@ Join(", ", Map(Fetch("<fetch no-lock='true'><entity name='contact'><attribute na
365401
```
366402

367403
will result in something like this: `"2018-10-27 05:39, 2019-04-24 10:24"`
404+
405+
### Filter
406+
**Available since: v3.9.6**
407+
Filters values inside an array by checking every value using the provided function.
408+
If the provided function returns true, the value will be kept, otherwise it will be filtered out.
409+
410+
Example:
411+
``` JavaScript
412+
Join(" ", Filter(["Lord", "of", "the", "Rings"], (e) => Not(IsEqual(IndexOf(e, "o"), -1))))
413+
```
414+
415+
will filter out all words that don't contain the character 'o', resulting in "Lord of".
416+
417+
Your input does not need to be an array of strings, you can even loop over records fetched using Fetch:
418+
419+
``` JavaScript
420+
Join(", ", Map(Filter(Fetch("<fetch no-lock='true'><entity name='contact'><attribute name='ownerid' /><attribute name='createdon' /></entity></fetch>"), (recordInFilter) => Not(IsNull(Value("createdon", { explicitTarget: recordInFilter })))), (record) => DateToString(ConvertDateTime(Value("createdon", { explicitTarget: record }), { userId: Value("ownerid", { explicitTarget: record }) }), { format: "yyyy-MM-dd hh:mm" })))
421+
```
422+
423+
will result in something like this: `"2018-10-27 05:39, 2019-04-24 10:24"`, where `createdon` is not null.
368424

369425
### Sort
370426
Sort array, either native values or by property. Ascending by default, descending by setting the config flag

0 commit comments

Comments
 (0)