Skip to content

Commit 5a6a42e

Browse files
authored
Merge pull request MicrosoftDocs#3141 from MicrosoftDocs/gregli-as
Canvas app - Adding ThisRecord, As, and Sequence - 1939110
2 parents e4319f8 + 5b03027 commit 5a6a42e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+454
-174
lines changed
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
Fields of the record currently being processed are available within the formula. You simply reference them by name as you would any other value. You can also reference control properties and other values from throughout your app. For more details, see the examples below and [working with record scope](../maker/canvas-apps/working-with-tables.md#record-scope).
2-
1+
Fields of the record currently being processed are available within the formula. Use the [**ThisRecord** operator](../maker/canvas-apps/functions/operators.md#thisitem-thisrecord-and-as-operators) or simply reference fields by name as you would any other value. The [**As** operator](../maker/canvas-apps/functions/operators.md#thisitem-thisrecord-and-as-operators) can also be used to name the record being processed which can help make your formula easier to understand and make nested records accessible. For more information, see the examples below and [working with record scope](../maker/canvas-apps/working-with-tables.md#record-scope).

powerapps-docs/maker/TOC.yml

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,8 @@
485485
href: ./canvas-apps/functions/function-logicals.md
486486
- name: App
487487
href: ./canvas-apps/functions/object-app.md
488+
- name: As
489+
href: ./canvas-apps/functions/operators.md#thisitem-thisrecord-and-as-operators
488490
- name: Asin
489491
href: ./canvas-apps/functions/function-trig.md
490492
- name: Assert
@@ -577,12 +579,14 @@
577579
href: ./canvas-apps/functions/function-form.md
578580
- name: Enable
579581
href: ./canvas-apps/functions/function-enable-disable.md
582+
- name: EncodeUrl
583+
href: ./canvas-apps/functions/function-encode-decode.md
580584
- name: EndsWith
581585
href: ./canvas-apps/functions/function-startswith.md
582586
- name: Errors
583587
href: ./canvas-apps/functions/function-errors.md
584-
- name: EncodeUrl
585-
href: ./canvas-apps/functions/function-encode-decode.md
588+
- name: exactin
589+
href: ./canvas-apps/functions/operators.md#in-and-exactin-operators
586590
- name: Exit
587591
href: ./canvas-apps/functions/function-exit.md
588592
- name: Exp
@@ -611,6 +615,8 @@
611615
href: ./canvas-apps/functions/function-if.md
612616
- name: IfError
613617
href: ./canvas-apps/functions/function-iferror.md
618+
- name: in
619+
href: ./canvas-apps/functions/operators.md#in-and-exactin-operators
614620
- name: IsBlank
615621
href: ./canvas-apps/functions/function-isblank-isempty.md
616622
- name: IsEmpty
@@ -681,6 +687,8 @@
681687
href: ./canvas-apps/functions/function-logicals.md
682688
- name: Param
683689
href: ./canvas-apps/functions/function-param.md
690+
- name: Parent
691+
href: ./canvas-apps/functions/operators.md#self-and-parent-operators
684692
- name: Patch
685693
href: ./canvas-apps/functions/function-patch.md
686694
- name: Pi
@@ -731,12 +739,16 @@
731739
href: ./canvas-apps/functions/function-datetime-parts.md
732740
- name: Select
733741
href: ./canvas-apps/functions/function-select.md
742+
- name: Self
743+
href: ./canvas-apps/functions/operators.md#self-and-parent-operators
734744
- name: Set
735745
href: ./canvas-apps/functions/function-set.md
736746
- name: SetFocus
737747
href: ./canvas-apps/functions/function-setfocus.md
738748
- name: SetProperty
739749
href: ./canvas-apps/functions/function-setproperty.md
750+
- name: Sequence
751+
href: ./canvas-apps/functions/function-sequence.md
740752
- name: ShowColumns
741753
href: ./canvas-apps/functions/function-table-shaping.md
742754
- name: Shuffle
@@ -769,6 +781,10 @@
769781
href: ./canvas-apps/functions/function-trig.md
770782
- name: Text
771783
href: ./canvas-apps/functions/function-text.md
784+
- name: ThisItem
785+
href: ./canvas-apps/functions/operators.md#thisitem-thisrecord-and-as-operators
786+
- name: ThisRecord
787+
href: ./canvas-apps/functions/operators.md#thisitem-thisrecord-and-as-operators
772788
- name: Time
773789
href: ./canvas-apps/functions/function-date-time.md
774790
- name: TimeValue

powerapps-docs/maker/canvas-apps/formula-reference.md

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ ms.service: powerapps
77
ms.topic: reference
88
ms.custom: canvas
99
ms.reviewer: tapanm
10-
ms.date: 05/20/2020
10+
ms.date: 07/17/2020
1111
ms.author: gregli
1212
search.audienceType:
1313
- maker
@@ -20,7 +20,7 @@ Formulas combine many elements. Listed below are:
2020
* **Functions** take parameters, perform an operation, and return a value. For example, **Sqrt(25)** returns **5**. Functions are modeled after Microsoft Excel functions. Some functions have side effects, such as **SubmitForm**, which are appropriate only in a [behavior formula](working-with-formulas-in-depth.md) such as **Button.OnSelect**.
2121
* **Signals** return information about the environment. For example, **[Location](functions/signals.md)** returns the device's current GPS coordinates. Signals don't take parameters or have side effects.
2222
* **Enumerations** return a pre-defined constant value. For example, **[Color](functions/function-colors.md)** is an enumeration that has pre-defined values for **Color.Red**, **Color.Blue**, and so forth. Common enumerations are included here; function-specific enumerations are described with the function.
23-
* **Named operators**, such as **[ThisItem](functions/operators.md#thisitem-operator)** and **[Self](functions/operators.md#self-and-parent-operators)**, provide access to information from within a container.
23+
* **Named operators**, such as **[ThisItem](functions/operators.md#thisitem-thisrecord-and-as-operators)** and **[Self](functions/operators.md#self-and-parent-operators)**, provide access to information from within a container.
2424

2525
Other elements include:
2626

@@ -47,6 +47,8 @@ Other elements include:
4747

4848
**[Assert](functions/function-assert.md)** – Evaluates to true or false in a test.
4949

50+
**[As](functions/operators.md#thisitem-thisrecord-and-as-operators)** – Names the current record in gallery, form, and record scope functions such as **ForAll**, **With**, and **Sum**.
51+
5052
**[AsType](functions/function-astype-istype.md)** – Treats a record reference as a specific entity type.
5153

5254
**[Atan](functions/function-trig.md)** – Returns the arctangent of a number, in radians.
@@ -137,11 +139,13 @@ Other elements include:
137139

138140
**[Enable](functions/function-enable-disable.md)** – Enables a signal, such as **[Location](functions/signals.md)** for reading the GPS.
139141

142+
**[EncodeUrl](functions/function-encode-decode.md)** – Encodes special characters using URL encoding.
143+
140144
**[EndsWith](functions/function-startswith.md)** – Checks whether a text string ends with another text string.
141145

142146
**[Errors](functions/function-errors.md)** – Provides error information for previous changes to a data source.
143147

144-
**[EncodeUrl](functions/function-encode-decode.md)**Encodes special characters using URL encoding.
148+
**[exactin](functions/operators.md#in-and-exactin-operators)**Checks if a text string is contained within another text string or table, case dependent. Also used to check if a record is in a table.
145149

146150
**[Exit](functions/function-exit.md)** – Exits the currently running app and optionally signs out the current user.
147151

@@ -173,6 +177,8 @@ Other elements include:
173177

174178
**[IfError](functions/function-iferror.md)** - Detects errors and provides an alternative value or takes action.
175179

180+
**[in](functions/operators.md#in-and-exactin-operators)** – Checks if a text string is contained within another text string or table, case independent. Also used to check if a record is in a table.
181+
176182
**[IsBlank](functions/function-isblank-isempty.md)** – Checks for a [blank](functions/function-isblank-isempty.md) value.
177183

178184
**[IsEmpty](functions/function-isblank-isempty.md)** – Checks for an empty table.
@@ -303,6 +309,8 @@ Other elements include:
303309

304310
**[Self](functions/operators.md#self-and-parent-operators)** – Provides access to the properties of the current control.
305311

312+
**[Sequence](functions/function-sequence.md)** – Generate a table of sequential numbers, useful when iterating with **ForAll**.
313+
306314
**[Set](functions/function-set.md)** – Sets the value of a global variable.
307315

308316
**[SetFocus](functions/function-setfocus.md)** – Moves input focus to a specific control.
@@ -342,7 +350,9 @@ Other elements include:
342350

343351
**[Text](functions/function-text.md)** – Converts any value and formats a number or date/time value to a string of text.
344352

345-
**[ThisItem](functions/operators.md#thisitem-operator)** – When in a gallery or form, returns the data for the current item from the container.
353+
**[ThisItem](functions/operators.md#thisitem-thisrecord-and-as-operators)** – Returns the record for the current item in a gallery or form control.
354+
355+
**[ThisRecord](functions/operators.md#thisitem-thisrecord-and-as-operators)** – Returns the record for the current item in a record scope function, such as **ForAll**, **With**, and **Sum**.
346356

347357
**[Time](functions/function-date-time.md)** – Returns a date/time value, based on **Hour**, **Minute**, and **Second** values.
348358

powerapps-docs/maker/canvas-apps/functions/function-astype-istype.md

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ ms.service: powerapps
77
ms.topic: reference
88
ms.custom: canvas
99
ms.reviewer: tapanm
10-
ms.date: 05/17/2019
10+
ms.date: 07/19/2020
1111
ms.author: gregli
1212
search.audienceType:
1313
- maker
@@ -33,13 +33,11 @@ Common Data Service also supports polymorphic lookup fields, which can refer to
3333
| **Customer** | **Accounts** or **Contacts** |
3434
| **Regarding** | **Accounts**, **Contacts**, **Knowledge Articles**, etc. |
3535

36-
<!--note from editor: Change "Knowledge Articles" to "Knowledge Base articles" if that is what is being referenced. -->
37-
38-
In canvas-app formulas, you can use record references to work with polymorphic lookups. Because a record reference can refer to different entities, you don't know which fields will be available when you write a formula. The *.Field* notation isn't available. Those formulas must adapt to the records that the app encounters when it runs.
36+
In canvas-app formulas, use record references to work with polymorphic lookups. Because a record reference can refer to different entities, you don't know which fields will be available when you write a formula. The *Record.Field* notation isn't available. Those formulas must adapt to the records that the app encounters when it runs.
3937

4038
The **IsType** function tests whether a record reference refers to a specific entity type. The function returns a Boolean TRUE or FALSE.
4139

42-
The **AsType** function treats a record reference as a specific entity type, sometimes referred to as *casting*. You can use the result as if it were a record of the entity and, again, use the *.Field* notation to access all of the fields of that record. An error occurs if the reference isn't of the specific type.
40+
The **AsType** function treats a record reference as a specific entity type, sometimes referred to as *casting*. You can use the result as if it were a record of the entity and again use the *Record.Field* notation to access all of the fields of that record. An error occurs if the reference isn't of the specific type.
4341

4442
Use these functions together to first test the entity type of a record and then treat it as a record of that type so that the fields are available:
4543

@@ -65,9 +63,9 @@ Patch( Accounts, First( Accounts ), { Owner: First( Teams ) } )
6563
If used in a record context, such as within a [**Gallery**](../controls/control-gallery.md) or [**Edit form**](../controls/control-form-detail.md) control, you might need to use the [global disambiguation operator](operators.md#disambiguation-operator) to reference the entity type. For example, this formula would be effective for a gallery that's displaying a list of contacts where **Company Name** is a **Customer** lookup:
6664

6765
```powerapps-dot
68-
If( IsType( ThisItem.'Company Name', [@Accounts] ),
69-
AsType( ThisItem.'Company Name', [@Accounts] ).'Account Name',
70-
AsType( ThisItem.'Company Name', [@Contacts] ).'Full Name'
66+
If( IsType( ThisItem.'Company Name', Accounts ),
67+
AsType( ThisItem.'Company Name', Accounts ).'Account Name',
68+
AsType( ThisItem.'Company Name', Contacts ).'Full Name'
7169
)
7270
```
7371

@@ -129,9 +127,9 @@ If the record reference is *blank*, **IsType** returns FALSE, and **AsType** ret
129127

130128
```powerapps-dot
131129
If( IsBlank( ThisItem.'Company Name' ), "--",
132-
IsType( ThisItem.'Company Name', [@Accounts] ),
133-
"Account: " & AsType( ThisItem.'Company Name', [@Accounts] ).'Account Name',
134-
"Contact: " & AsType( ThisItem.'Company Name', [@Contacts] ).'Full Name'
130+
IsType( ThisItem.'Company Name', Accounts ),
131+
"Account: " & AsType( ThisItem.'Company Name', Accounts ).'Account Name',
132+
"Contact: " & AsType( ThisItem.'Company Name', Contacts ).'Full Name'
135133
)
136134
```
137135
Lines changed: 100 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -1,82 +1,100 @@
1-
---
2-
title: Char function | Microsoft Docs
3-
description: Reference information for the Char function in Power Apps, including syntax and examples
4-
author: gregli-msft
5-
manager: kvivek
6-
ms.service: powerapps
7-
ms.topic: reference
8-
ms.custom: canvas
9-
ms.reviewer: tapanm
10-
ms.date: 03/01/2019
11-
ms.author: gregli
12-
search.audienceType:
13-
- maker
14-
search.app:
15-
- PowerApps
16-
---
17-
# Char function in Power Apps
18-
19-
Translates a character code into a string.
20-
21-
## Description
22-
23-
The **Char** function translates a number into a string with the corresponding ASCII character.
24-
25-
## Syntax
26-
27-
**Char**( *CharacterCode* )
28-
29-
- *CharacterCode* - Required. ASCII character code to translate.
30-
31-
## Examples
32-
33-
| Formula | Description | Result |
34-
| --- | --- | --- |
35-
| **Char( 65 )** |Returns the character that corresponds to ASCII code 65. |"A" |
36-
| **Char( 105 )** |Returns the character that corresponds to ASCII code 105. |"i" |
37-
| **Char( 35 )** |Returns the character that corresponds to ASCII code 35. |"#" |
38-
39-
### Display a character map
40-
41-
1. On an empty screen in a tablet app, add a [**Gallery**](../controls/control-gallery.md) control with a **Blank Horizontal** layout, and then set these properties:
42-
43-
- **Items**: `[0,1,2,3,4,5,6,7]`
44-
- **Width**: 800
45-
- **Height**: 500
46-
- **TemplateSize**: 100
47-
- **TemplatePadding**: 0
48-
49-
1. Inside that gallery, add a **Gallery** control with a **Blank Vertical** layout, and then set these properties:
50-
51-
- **Items**: `ForAll( [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15], Value + ThisItem.Value * 16 )`
52-
- **Width**: 100
53-
- **Height**: 500
54-
- **TemplateSize**: 30
55-
- **TemplatePadding**: 0
56-
57-
The value of the **Items** property multiplies 16 by the column number provided by the Value column of the **Items** property from the first gallery (0-7 in `ThisItem.Value`). The formula then adds the result to one of the row numbers from the second gallery (0-15 in the record scope that the [**ForAll**](function-forall.md) function provides).
58-
59-
1. Inside the second (vertical) gallery, add a **Label** control, and set these properties:
60-
61-
- **Text**: `ThisItem.Value`
62-
- **Width**: 50
63-
64-
1. Inside the second (vertical) gallery, add another **Label** control, and set these properties:
65-
66-
- **Text**: `Char( ThisItem.Value )`
67-
- **Width**: 50
68-
- **X**: 50
69-
70-
You've created a chart of the first 128 ASCII characters. Characters that appear as a small square can't be printed.
71-
72-
![First 128 ASCII characters](media/function-char/chart-lower.png)
73-
74-
To show the extended ASCII characters, set the **Items** property of the second gallery to this formula, which adds 128 to each character value:
75-
76-
`ForAll( [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15], Value + ThisItem.Value * 16 + 128)`
77-
78-
![Extended ASCII characters](media/function-char/chart-higher.png)
79-
80-
To show the characters in a different font, set the **Font** property of the second label to a value such as **'Dancing Script'**.
81-
82-
![Dancing Script](media/function-char/chart-higher-dancing-script.png)
1+
---
2+
title: Char function | Microsoft Docs
3+
description: Reference information for the Char function in Power Apps, including syntax and examples
4+
author: gregli-msft
5+
manager: kvivek
6+
ms.service: powerapps
7+
ms.topic: reference
8+
ms.custom: canvas
9+
ms.reviewer: tapanm
10+
ms.date: 07/17/2020
11+
ms.author: gregli
12+
search.audienceType:
13+
- maker
14+
search.app:
15+
- PowerApps
16+
---
17+
# Char function in Power Apps
18+
19+
Translates a character code into a string.
20+
21+
## Description
22+
23+
The **Char** function translates a number into a string with the corresponding ASCII character.
24+
25+
## Syntax
26+
27+
**Char**( *CharacterCode* )
28+
29+
- *CharacterCode* - Required. ASCII character code to translate.
30+
31+
## Examples
32+
33+
| Formula | Description | Result |
34+
| --- | --- | --- |
35+
| **Char( 65 )** |Returns the character that corresponds to ASCII code 65. |"A" |
36+
| **Char( 105 )** |Returns the character that corresponds to ASCII code 105. |"i" |
37+
| **Char( 35 )** |Returns the character that corresponds to ASCII code 35. |"#" |
38+
39+
### Display a character map
40+
41+
1. On an empty screen in a tablet app, add a [**Gallery**](../controls/control-gallery.md) control with a **Blank Horizontal** layout, and then set these properties:
42+
43+
- **Items**: `Sequence( 8, 0, 16 ) As HighNibble`
44+
- **Width**: `Parent.Width`
45+
- **Height**: `Parent.Height`
46+
- **TemplateSize**: `Parent.Width / 8`
47+
- **TemplatePadding**: 0
48+
- **X**: 0
49+
- **Y**: 0
50+
51+
1. Inside that gallery, add a **Gallery** control with a **Blank Vertical** layout, and then set these properties:
52+
53+
- **Items**: `Sequence( 16, HighNibble.Value ) As FullCode`
54+
- **Width**: `Parent.Width / 8`
55+
- **Height**: `Parent.Height`
56+
- **TemplateSize**: `Parent.Height / 16`
57+
- **TemplatePadding**: 0
58+
- **X**: 0
59+
- **Y**: 0
60+
61+
1. Inside the second (vertical) gallery, add a **Label** control, and set these properties:
62+
63+
- **Text**: `FullCode.Value`
64+
- **Width**: `Parent.Width / 2`
65+
- **X**: 0
66+
- **Y**: 0
67+
- **Align**: `Center`
68+
- **FontWeight**: `Bold`
69+
- **Size**: 24
70+
71+
1. Inside the second (vertical) gallery, add another **Label** control, and set these properties:
72+
73+
- **Text**: `Char( FullCode.Value )`
74+
- **Width**: `Parent.Width / 2`
75+
- **X**: `Parent.Width / 2`
76+
- **Y**: 0
77+
- **FontWeight**: `Bold`
78+
- **Size**: 24
79+
80+
You've created a chart of the first 128 ASCII characters. Characters that appear as a small square can't be printed.
81+
82+
![First 128 ASCII characters](media/function-char/chart-lower.png)
83+
84+
If you want to see how **FullCode.Value** gets its values. Let's begin with the outer horizontal gallery. Its **Items** property uses the **Sequence** function to create 8 columns, starting with 0 with increments of 16:
85+
86+
![Outer gallery illustrated](media/function-char/chart-lower-outer.png)
87+
88+
Nested within this gallery is another vertical gallery. Its **Items** property fills in the gap left by the increment of 16 from the outer gallery:
89+
90+
![Inner gallery illustrated](media/function-char/chart-lower-inner.png)
91+
92+
To show the extended ASCII characters, it is a simple matter of changing the starting point for the chart, set in the Sequence function for the outer gallery:
93+
94+
`Sequence( 8, 128, 16 ) As HighNibble`
95+
96+
![Extended ASCII characters](media/function-char/chart-higher.png)
97+
98+
Finally, to show the characters in a different font, set the **Font** property of the second label to a value such as **'Dancing Script'**.
99+
100+
![Dancing Script](media/function-char/chart-higher-dancing-script.png)

0 commit comments

Comments
 (0)