1
1
Data processing Lambdas are used to alter regular save behaviour. Using such lambdas you can:
2
- * compute some value
3
- * add some validation step
4
- * add per-user filters
5
- * hide fields
6
- * everithing else you need
2
+
3
+ - compute some value
4
+ - add some validation step
5
+ - add per-user filters
6
+ - hide fields
7
+ - everithing else you need
7
8
8
9
### Data saving pipeline
10
+
9
11
Data is saved using a save pipeline. Current implemented stages are:
10
12
11
13
1 . Pre-Save
12
14
2 . Post-Save
13
15
14
16
### DataProcessLambda
17
+
15
18
Implementing a DataProcessLambda will let you choose in which phases you want to be triggered. Multiple phases can be binded as in example
16
19
17
20
``` cs
18
- public class AuditLambda : DataProcessLambda
21
+ public class AuditLambda : DataProcessLambda
19
22
{
20
23
public override string Name => " LogLambda" ;
21
24
public override string Description => " Log all" ;
@@ -28,11 +31,12 @@ Implementing a DataProcessLambda will let you choose in which phases you want to
28
31
```
29
32
30
33
### PostSaveLambda, PreaveLambda
34
+
31
35
This class is shortcut to bind presave or postsave event
32
36
33
37
Audit Lambda is a sample. It is triggered on before saving data and it set audit details.
34
38
35
- ``` cs
39
+ ``` cs
36
40
public class AuditLambda : PreSaveLambda
37
41
{
38
42
public override string Name => " AuditLambda" ;
@@ -52,3 +56,27 @@ Audit Lambda is a sample. It is triggered on before saving data and it set audit
52
56
}
53
57
```
54
58
59
+ ### Javascript Lambdas
60
+
61
+ For entities is possible define custom lambdas writed on javascript language on this events:
62
+
63
+ - PreSave
64
+ - PostSave
65
+ - PreDelete
66
+ - PostDelete
67
+
68
+ ![ JS Lambdas] ( assets/jslambdas.png )
69
+
70
+ this is an example of javascript code for calculate preview book using ISBN code
71
+
72
+ ``` js
73
+ var client = new RAWCMSRestClient ();
74
+ var request = new RAWCMSRestClientRequest ();
75
+ var bibkey = " ISBN:" + item .ISBN13 ;
76
+ request .Url = " https://openlibrary.org/api/books?format=JSON&bibkeys=" + bibkey;
77
+ request .Method = " GET" ;
78
+ var response = client .Execute (request);
79
+ var data = JSON .parse (response .Data );
80
+ // set result propoerty
81
+ item .PreviewUrl = data[bibkey].preview_url ;
82
+ ```
0 commit comments