Skip to content

Commit b7f5a70

Browse files
committed
changed decomposition and added expression editor section
1 parent a992827 commit b7f5a70

File tree

8 files changed

+192
-72
lines changed

8 files changed

+192
-72
lines changed

content/en/blog/releases/2024.X/2024.9.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -679,6 +679,7 @@ Releases are currently forecast to be made available on:
679679

680680
[Gateway]: {{< url path="Cortex.Guides.Gateway.MainDoc" version="2024.9" >}}
681681
[Expression Editor]: {{< url path="Cortex.Reference.Concepts.Fundamentals.Blocks.BlockProperties.PropertyEditors.ExpressionEditor.MainDoc" version="2024.9" >}}
682+
[decomposition syntax]: {{< url path="Cortex.Reference.Concepts.Fundamentals.Blocks.BlockProperties.WhatIsABlockProperty.DecomposingOutputProperties" version="2024.9" >}}
682683

683684
[.NET 8]: {{< url path="Cortex.Reference.Glossary.A-E.DotNet" >}}
684685
[API]: {{< url path="Cortex.Reference.Glossary.A-E.API" >}}

content/en/docs/2024.9/Reference/Concepts/fundamentals/blocks/block-properties/property-editors/expression-editor.md

Lines changed: 180 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,7 @@ Types of expressions:
264264
- [Enums][Enum expressions]
265265
- [Casting][Casting expressions]
266266
- [Indexes][Index expressions]
267+
- [Decomposition][Decomposition expressions] ([output property][] only)
267268

268269
### Arithmetic expressions
269270

@@ -556,6 +557,184 @@ In the examples below assume:
556557
| `($)Structure["SecondKey"][0]` | `1` | The first item within the item with key `"SecondKey"` is returned |
557558
| `($)String[0]` | `'S'` | The first character in the string is returned |
558559

560+
### Decomposition expressions
561+
562+
{{< figure src="/images/set-variable/set-variable-expression-decomposition.PNG" >}}
563+
564+
Decomposition expressions are used to extract the properties of an [Output property][Output properties] and store them in [variables][Variables Concept].
565+
566+
{{% alert title="Note" %}}
567+
This is currently only supported by output properties.
568+
{{% /alert %}}
569+
570+
[Output properties][] can be decomposed using the decomposition syntax which includes the following syntaxes:
571+
572+
- [Property expression][Property expressions]
573+
- [Index expression][Index expressions]
574+
575+
The decomposition syntax follows a very similar pattern to a `JSON` object:
576+
577+
- each `key` is the property path expression, where `$` is the root of the output value.
578+
- each `value` is the variable name, prefixed with `($)`.
579+
580+
```json
581+
{
582+
"$.property.firstPath": ($)FirstVariable,
583+
"$.property.secondPath": ($)SecondVariable
584+
}
585+
```
586+
587+
The examples below assumes that the output value contains the following JSON object:
588+
589+
``` json
590+
{
591+
"company": {
592+
"name": "Company Name",
593+
"department": [
594+
{
595+
"name": "HR",
596+
"employees": [
597+
{
598+
"name": "Joe Blogs",
599+
"id": "101"
600+
},
601+
{
602+
"name": "Jane Doe",
603+
"id": "102"
604+
}
605+
]
606+
},
607+
{
608+
"name": "Admin",
609+
"employees": [
610+
{
611+
"name": "Jane Blogs",
612+
"id": "103"
613+
},
614+
{
615+
"name": "Joe Doe",
616+
"id": "104"
617+
}
618+
]
619+
}
620+
]
621+
}
622+
}
623+
```
624+
625+
### Decomposing an object property
626+
627+
To decompose this structure and store the departments, the syntax would be:
628+
629+
```json
630+
{
631+
"$.company.department": ($)ListOfDepartment
632+
}
633+
```
634+
635+
In this example, the variable `($)ListOfDepartment` will be set to the following value:
636+
637+
```json
638+
[
639+
{
640+
"name": "HR",
641+
"employees": [
642+
{
643+
"name": "Joe Blogs",
644+
"id": "101"
645+
},
646+
{
647+
"name": "Jane Doe",
648+
"id": "102"
649+
}
650+
]
651+
},
652+
{
653+
"name": "Admin",
654+
"employees": [
655+
{
656+
"name": "Jane Blogs",
657+
"id": "103"
658+
},
659+
{
660+
"name": "Joe Doe",
661+
"id": "104"
662+
}
663+
]
664+
}
665+
]
666+
```
667+
668+
### Decomposing a list item
669+
670+
To decompose this structure and store the first `department`, the syntax would be:
671+
672+
```json
673+
{
674+
"$.company.department[0]": ($)FirstDepartment
675+
}
676+
```
677+
678+
In this example, the variable `($)FirstDepartment` will be set to the following value:
679+
680+
```json
681+
{
682+
"name": "HR",
683+
"employees": [
684+
{
685+
"name": "Joe Blogs",
686+
"id": "101"
687+
},
688+
{
689+
"name": "Jane Doe",
690+
"id": "102"
691+
}
692+
]
693+
}
694+
```
695+
696+
### Decomposing the last list item
697+
698+
To decompose this structure and store the last `employee` of the first `department`, the syntax would be:
699+
700+
```json
701+
{
702+
"$.company.department[0].employees[-1]": ($)LastEmployeeOfFirstDepartment
703+
}
704+
```
705+
706+
In this example, the variable `($)LastEmployeeOfFirstDepartment` will be set to the following value:
707+
708+
```json
709+
{
710+
"name": "Jane Doe",
711+
"id": "102"
712+
}
713+
```
714+
715+
### Decomposing multiple properties at the same time
716+
717+
To decompose this structure and store the `id` and `name` of the first `employee` of the first `department`, the syntax would be:
718+
719+
```json
720+
{
721+
"$.company.department[0].employees[0].id": ($)FirstEmployeeId,
722+
"$.company.department[0].employees[0].name": ($)FirstEmployeeName
723+
}
724+
```
725+
726+
In this example, the variable `($)FirstEmployeeId` will be set to the following value:
727+
728+
```json
729+
"101"
730+
```
731+
732+
And the variable `($)FirstEmployeeName` will be set to the following value:
733+
734+
```json
735+
"Joe Blogs"
736+
```
737+
559738
## Remarks
560739

561740
### Known Limitations
@@ -643,8 +822,6 @@ This may change in future to allow developers to specifically select which of th
643822
[Dictionary literal]: {{< ref "#dictionary-literal" >}}
644823
[Structure literal]: {{< ref "#structure-literal" >}}
645824
[List literal]: {{< ref "#list-literal" >}}
646-
[Conc]: {{< ref "#list-literal" >}}
647-
[List literal]: {{< ref "#list-literal" >}}
648825
[Concatenated Strings]: {{< ref "#concatenated-strings" >}}
649826
[Interpolated Strings]: {{< ref "#interpolated-strings" >}}
650827
[Verbatim Strings]: {{< ref "#verbatim-strings" >}}
@@ -662,6 +839,7 @@ This may change in future to allow developers to specifically select which of th
662839
[Enum expressions]: {{< ref "#enum-expressions" >}}
663840
[Casting expressions]: {{< ref "#casting-expressions" >}}
664841
[Index expressions]: {{< ref "#index-expressions" >}}
842+
[Decomposition expressions]: {{< ref "#output-property-decomposition-expressions" >}}
665843

666844
[Data Type]: {{< url path="Cortex.Reference.Concepts.Fundamentals.DataTypes.MainDoc" >}}
667845

@@ -687,19 +865,16 @@ This may change in future to allow developers to specifically select which of th
687865
[Double]: {{< url path="Cortex.Reference.DataTypes.Numbers.Double.MainDoc" >}}
688866
[List]: {{< url path="Cortex.Reference.DataTypes.Collections.List.MainDoc" >}}
689867
[Create a List]: {{< url path="Cortex.Reference.DataTypes.Collections.List.CreateNew" >}}
690-
[Object]: {{< url path="Cortex.Reference.DataTypes.All.Object.MainDoc" >}}
691868
[Single]: {{< url path="Cortex.Reference.DataTypes.Numbers.Single.MainDoc" >}}
692869
[Single.MaxValue]: {{< url path="MSDocs.DotNet.Api.System.Single.MaxValue" >}}
693870
[Single.MinValue]: {{< url path="MSDocs.DotNet.Api.System.Single.MinValue" >}}
694871
[String]: {{< url path="Cortex.Reference.DataTypes.Text.String.MainDoc" >}}
695-
[Char]: {{< url path="Cortex.Reference.DataTypes.Text.Char.MainDoc" >}}
696872
[Collection]: {{< url path="Cortex.Reference.DataTypes.Collections.MainDoc" >}}
697873
[Structure]: {{< url path="Cortex.Reference.DataTypes.Collections.Structure.MainDoc" >}}
698874
[Create a Structure]: {{< url path="Cortex.Reference.DataTypes.Collections.Structure.CreateNew" >}}
699875

700876
[Workspaces]: {{< url path="Cortex.Reference.Concepts.Fundamentals.Workspaces.MainDoc" >}}
701877
[workspace]: {{< url path="Cortex.Reference.Concepts.Fundamentals.Workspaces.WhatIsAWorkspace.MainDoc" >}}
702-
[Workspace Scope]: {{< url path="Cortex.Reference.Concepts.Fundamentals.Variables.VariableScopes.MainDoc" >}}
703878

704879
[Variables Concept]: {{< url path="Cortex.Reference.Concepts.Fundamentals.Variables.MainDoc" >}}
705880
[Variables: What Is a Variable]: {{< url path="Cortex.Reference.Concepts.Fundamentals.Variables.WhatIsAVariable.MainDoc" >}}
@@ -712,7 +887,6 @@ This may change in future to allow developers to specifically select which of th
712887
[implicitly cast]: {{< url path="Cortex.Reference.Concepts.WorkingWith.Objects.ObjectCasting.ImplicitCast" >}}
713888

714889
[Blocks]: {{< url path="Cortex.Reference.Blocks.MainDoc" >}}
715-
[Set Variable]: {{< url path="Cortex.Reference.Blocks.Variables.SetVariable.SetVariable.MainDoc" >}}
716890

717891
[Expression Editor]: {{< url path="Cortex.Guides.Studio.ExpressionEditor.MainDoc" >}}
718892

content/en/docs/2024.9/Reference/Concepts/fundamentals/blocks/block-properties/what-is-a-block-property.md

Lines changed: 9 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,9 @@ Input properties can be configured using the following editors:
3333

3434
{{< figure src="/images/editable/editor-types.png" >}}
3535

36-
The icons used for Input properties are dark blue to distinguish them from [Output Properties][] or [InputOutput Properties][].
37-
3836
### Output Properties
3937

40-
Output properties are used to save values from a [block][]. These properties can be saved to a variable or decomposed to be saved into multiple variables during the block's execution.
38+
Output properties are used to save values from a [block][]. These properties can be saved to a variable or [decomposed][Decomposing Output Properties] to be saved into multiple variables during the block's execution.
4139

4240
Values from Output properties can be [discarded][Discarding Outputs], this means they will not be saved to any variable.
4341

@@ -49,72 +47,15 @@ Output properties can be configured using the following editors:
4947

5048
{{< figure src="/images/editable/variable-editor.png" >}}
5149

52-
The icon used for Output properties are light blue to distinguish them from [Input Properties][].
50+
- [Expression Editor][] using [decomposition][Decomposing Output Properties]
51+
52+
{{< figure src="/images/editable/expression-editor.png" >}}
5353

5454
#### Decomposing Output Properties
5555

56-
Output values can be decomposed to allow the saving of different parts of the value to different variables.
57-
58-
To decompose an output value, the output property will need to be set to an expression. As an example, an output value value contains a Json object, e.g:
59-
60-
``` json
61-
{
62-
"company": {
63-
"name": "Company Name",
64-
"department": [
65-
{
66-
"name": "HR",
67-
"employees": [
68-
{
69-
"name": "Joe Blogs",
70-
"id": "101"
71-
},
72-
{
73-
"name": "Jane Doe",
74-
"id": "102"
75-
}
76-
]
77-
}
78-
]
79-
}
80-
}
81-
```
82-
83-
To decompose this structure and store a part of the value to a variable, e.g. to get the employees for the first department, the syntax would be:
84-
85-
```text
86-
{"$.company.department[0].employees": ($)VariableNameToStore}
87-
```
88-
89-
In this example, this would set the variable to be:
90-
91-
```json
92-
{
93-
{
94-
"name": "Joe Blogs",
95-
"id": "101"
96-
},
97-
{
98-
"name": "Jane Doe",
99-
"id": "102"
100-
}
101-
}
102-
```
103-
104-
To set the variable to the last value `-1` should be used for the index:
105-
106-
```text
107-
{"$.company.department[0].employees[-1]": ($)VariableNameToStore}
108-
```
109-
110-
In this example, this would set the variable to be:
111-
112-
```json
113-
{
114-
"name": "Jane Doe",
115-
"id": "102"
116-
}
117-
```
56+
Output values can be [decomposed][Decomposition expressions] to allow the saving of different parts of the value to different variables.
57+
58+
To [decompose][Decomposition expressions] an output value, the output property will need to be set to an expression.
11859

11960
#### Discarding Outputs
12061

@@ -181,6 +122,7 @@ None
181122
[Input Properties]: {{< ref "#input-properties" >}}
182123
[Output Properties]: {{< ref "#output-properties" >}}
183124
[InputOutput Properties]: {{< ref "#inputoutput-properties" >}}
125+
[Decomposing Output Properties]: {{< ref "#decomposing-output-properties" >}}
184126
[Discarding Outputs]: {{< ref "#discarding-outputs" >}}
185127

186128
[All Blocks]: {{< url path="Cortex.Reference.Blocks.MainDoc" >}}
@@ -193,6 +135,7 @@ None
193135
[Literal Editor]: {{< url path="Cortex.Reference.Concepts.Fundamentals.Blocks.BlockProperties.PropertyEditors.LiteralEditor.MainDoc" >}}
194136
[Variable Editor]: {{< url path="Cortex.Reference.Concepts.Fundamentals.Blocks.BlockProperties.PropertyEditors.VariableEditor.MainDoc" >}}
195137
[Expression Editor]: {{< url path="Cortex.Reference.Concepts.Fundamentals.Blocks.BlockProperties.PropertyEditors.ExpressionEditor.MainDoc" >}}
138+
[Decomposition expressions]: {{< url path="Cortex.Reference.Concepts.Fundamentals.Blocks.BlockProperties.PropertyEditors.ExpressionEditor.DecompositionExpressions" >}}
196139

197140
[Fundamentals Data Types]: {{< url path="Cortex.Reference.Concepts.Fundamentals.DataTypes.MainDoc" >}}
198141

3.28 KB
Loading
8.26 KB
Loading
-1.39 KB
Loading
14.6 KB
Loading

data/urls.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1320,6 +1320,7 @@
13201320
Output = "/docs/reference/concepts/fundamentals/blocks/block-properties/what-is-a-block-property/#output-properties"
13211321
DiscardingOutputs = "/docs/reference/concepts/fundamentals/blocks/block-properties/what-is-a-block-property/#discarding-outputs"
13221322
InputOutput = "/docs/reference/concepts/fundamentals/blocks/block-properties/what-is-a-block-property/#inputoutput-properties"
1323+
DecomposingOutputProperties = "/docs/reference/concepts/fundamentals/blocks/block-properties/what-is-a-block-property/#decomposing-output-properties"
13231324
[Cortex.Reference.Concepts.Fundamentals.Blocks.BlockProperties.AdvancedProperties]
13241325
MainDoc = "/docs/reference/concepts/fundamentals/blocks/block-properties/advanced-properties/"
13251326
[Cortex.Reference.Concepts.Fundamentals.Blocks.BlockProperties.CommonProperties]
@@ -1336,6 +1337,7 @@
13361337
MethodExpressions = "/docs/reference/concepts/fundamentals/blocks/block-properties/property-editors/expression-editor/#method-expressions"
13371338
PropertyExpressions = "/docs/reference/concepts/fundamentals/blocks/block-properties/property-editors/expression-editor/#property-expressions"
13381339
IndexExpressions = "/docs/reference/concepts/fundamentals/blocks/block-properties/property-editors/expression-editor/#index-expressions"
1340+
DecompositionExpressions = "/docs/reference/concepts/fundamentals/blocks/block-properties/property-editors/expression-editor/#decomposition-expressions"
13391341
LiteralValues = "/docs/reference/concepts/fundamentals/blocks/block-properties/property-editors/expression-editor/#literal-values"
13401342
DictionaryLiteral = "/docs/reference/concepts/fundamentals/blocks/block-properties/property-editors/expression-editor/#dictionary-literal"
13411343
ListLiteral = "/docs/reference/concepts/fundamentals/blocks/block-properties/property-editors/expression-editor/#list-literal"

0 commit comments

Comments
 (0)