Skip to content

Commit fa6a57c

Browse files
authored
Live publish
2 parents 8d5f5f3 + 5ee4ee2 commit fa6a57c

32 files changed

+415
-20
lines changed

powerapps-docs/developer/model-driven-apps/clientapi/navigate-to-custom-page-examples.md

Lines changed: 68 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
---
22
title: "Navigating to and from a custom page in your model-driven app using client API (preview)"
3-
description: "This article provides examples of navigating from a model-driven app page using the Client API to a custom page."
4-
ms.custom: ""
5-
ms.date: 07/21/2021
3+
description: "This article provides examples of navigating from a model-driven app page using the client API to a custom page."
4+
ms.date: 08/17/2021
65
ms.reviewer: ""
76
ms.service: powerapps
87
ms.subservice: mda-developer
@@ -24,7 +23,7 @@ search.app:
2423

2524
This article provides examples of navigating from a model-driven app page to a custom page using [Client API](../client-scripting.md). This article also includes examples of navigating from a custom page to other custom pages and also from custom page to model-driven app form.
2625

27-
This article outlines the steps to use Client API to open a custom page as a full-page, dialog, or pane. It provides examples of **custom** as a `pageType` value in [navigateTo (Client API reference)](reference/xrm-navigation/navigateto.md).
26+
This article outlines the steps to use client API to open a custom page as a full-page, dialog, or pane. It provides examples of **custom** as a `pageType` value in [navigateTo (Client API reference)](reference/xrm-navigation/navigateto.md).
2827

2928
> [!IMPORTANT]
3029
> - This is a preview feature, and isn't available in all regions.
@@ -35,13 +34,13 @@ This article outlines the steps to use Client API to open a custom page as a ful
3534

3635
### Finding the logical name
3736

38-
Each of the following Client API examples takes the logical name of the custom page as the required parameter. The logical name is the **Name** value of the page in the solution explorer.
37+
Each of the following client API examples takes the logical name of the custom page as the required parameter. The logical name is the **Name** value of the page in the solution explorer.
3938

4039
:::image type="content" source="../../../maker/model-driven-apps/media/navigate-page-examples/find-page-logical-name.png" alt-text="Find page logical name." lightbox="../../../maker/model-driven-apps/media/navigate-page-examples/find-page-logical-name.png":::
4140

4241
### Open as an inline full page without context
4342

44-
Within a model-driven app Client API event handler, call the following code and update the **name** parameter to be the logical name of the page.
43+
Within a model-driven app client API event handler, call the following code and update the **name** parameter to be the logical name of the page.
4544

4645
```javascript
4746
// Inline Page
@@ -93,7 +92,7 @@ Xrm.Navigation.navigateTo(pageInput, navigationOptions)
9392

9493
### Open as a centered dialog
9594

96-
Within a model-driven app Client API event handler, call the following code and update the **name** parameter to be the logical name of the custom page. This mode supports the sizing parameters similar to the [Main form dialogs](../../../developer/model-driven-apps/customize-entity-forms.md#open-main-form-in-a-dialog-using-client-api).
95+
Within a model-driven app client API event handler, call the following code and update the **name** parameter to be the logical name of the custom page. This mode supports the sizing parameters similar to the [Main form dialogs](../../../developer/model-driven-apps/customize-entity-forms.md#open-main-form-in-a-dialog-using-client-api).
9796

9897
```javascript
9998
// Centered Dialog
@@ -121,7 +120,7 @@ Xrm.Navigation.navigateTo(pageInput, navigationOptions)
121120

122121
### Open as a side dialog
123122

124-
Within a model-driven app Client API event handler, call the following code and update the **name** parameter to be the logical name of the custom page.
123+
Within a model-driven app client API event handler, call the following code and update the **name** parameter to be the logical name of the custom page.
125124

126125
```javascript
127126
// Side Dialog
@@ -201,7 +200,66 @@ This example uses the `recordId` parameter within the [navigateTo](reference/Xrm
201200
```
202201

203202
> [!NOTE]
204-
> After changing the `OnStart` property, you'll need to run `OnStart` from the App context menu. This function runs only once within a session.
203+
> After changing the `OnStart` property, you'll need to run `OnStart` from the App context menu. This function performs only once within a session.
204+
205+
1. Then, the custom page can use the **RecordItem** parameter as a record. Below is an example on how to use it in an [EditForm](../../../maker/canvas-apps/functions/function-form.md).
206+
207+
```powerappsfl
208+
EditForm.Datasource=<datasource name>
209+
EditForm.Item=RecordItem
210+
```
211+
212+
### Open from a selected record in editable grid as a centered dialog with record ID
213+
214+
Editable grid can be used to trigger [OnRecordSelect](reference/events/grid-onrecordselect.md) event for scenarios where you want to perform an action when a particular record is selected in a view. This example uses the `recordId` parameter within the [navigateTo](reference/Xrm-Navigation/navigateTo.md) function to provide the custom page with the record to use. The record ID is retrieved using the `getId` method in [GridEntity](reference/grids/gridentity.md) object. The `Param` function within the custom page retrieves the value and uses the lookup function to retrieve the record.
215+
216+
1. [Enable editable grid](../../../developer/model-driven-apps/use-editable-grids.md) control in the table.
217+
218+
1. Create a web resource of type **JScript** and update the **name** parameter to be the logical page name. Add the following code to the web resource.
219+
220+
```javascript
221+
function RunOnSelected(executionContext) {
222+
// Retrieves the record selected in the editable grid
223+
var selectedRecord = executionContext.getFormContext().data.entity;
224+
var Id = selectedRecord.getId().replace(/[{}]/g, "");
225+
226+
// Centered Dialog
227+
var pageInput = {
228+
pageType: "custom",
229+
name: "<logical page name>",
230+
recordId: Id,
231+
};
232+
var navigationOptions = {
233+
target: 2,
234+
position: 1,
235+
width: { value: 50, unit: "%" },
236+
title: "<dialog title>"
237+
};
238+
Xrm.Navigation.navigateTo(pageInput, navigationOptions)
239+
.then(
240+
function () {
241+
// Called when the dialog closes
242+
}
243+
).catch(
244+
function (error) {
245+
// Handle error
246+
}
247+
);
248+
}
249+
```
250+
251+
1. In the custom page, override the **App**'s **OnStart** property to use the `Param` function to get the `recordId` and lookup record.
252+
253+
```powerappsfl
254+
App.OnStart=Set(RecordItem,
255+
If(IsBlank(Param("recordId")),
256+
First(<entity>),
257+
LookUp(<entity>, <entityIdField> = GUID(Param("recordId"))))
258+
)
259+
```
260+
261+
> [!NOTE]
262+
> After changing the `OnStart` property, you'll need to run `OnStart` from the App context menu. This function performs only once within a session.
205263

206264
1. Then, the custom page can use the **RecordItem** parameter as a record. Below is how to use it in an [EditForm](../../../maker/canvas-apps/functions/function-form.md).
207265

@@ -225,5 +283,5 @@ This example uses the `recordId` parameter within the [navigateTo](reference/Xrm
225283

226284
[Add a custom page to your model-driven app](../../../maker/model-driven-apps/add-page-to-model-app.md)
227285

228-
[navigateTo (Client API reference)](reference/xrm-navigation/navigateto.md)
286+
[navigateTo (client API reference)](reference/xrm-navigation/navigateto.md)
229287

powerapps-docs/maker/TOC.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2261,6 +2261,8 @@
22612261
href: ../teams/when-create-teams-apps.md
22622262
- name: Add notifications to make your apps collaborative
22632263
href: ../teams/add-app-notifications.md
2264+
- name: Enable consistent experience across sessions
2265+
href: ../teams/consistent-experience-across-sessions.md
22642266
- name: Manage your apps
22652267
href: ../teams/manage-your-apps.md
22662268
- name: Set permission and share your app

powerapps-docs/maker/canvas-apps/create-component.md

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ author: hemantgaur
55
ms.service: powerapps
66
ms.subservice: canvas-developer
77
ms.topic: article
8-
ms.date: 07/01/2021
8+
ms.date: 08/18/2021
99
ms.author: hemantg
1010
ms.reviewer: tapanm
1111
search.audienceType:
@@ -15,6 +15,7 @@ search.app:
1515
contributors:
1616
- hemantgaur
1717
- tapanm-msft
18+
- gregli-msft
1819
---
1920

2021
# Create a component for canvas apps
@@ -45,13 +46,6 @@ Components available inside the app are listed under the **Custom** category in
4546
> [!NOTE]
4647
> Components discussed in this article are different from the Power Apps component framework that enables developers and makers to create code components for model-driven and canvas apps. For more information, go to [Power Apps component framework overview](../../developer/component-framework/overview.md).
4748
48-
## Scope
49-
50-
Think of a component as an encapsulated black box with properties as the interface. You can't access controls in the component from outside of the component. And you can't refer to anything outside of the component from inside the component. The exception is data sources shared between an app and its components. Scope restrictions keep the data contract of a component simple and cohesive, and it helps enable component-definition updates, especially across apps with component libraries. You can update the data contract of the component by creating one or more custom properties.
51-
52-
> [!NOTE]
53-
> You can insert instances of components into a screen within a component library, and preview that screen for testing purposes. Also, note that the component library does not display when using [Power Apps Mobile](https://powerapps.microsoft.com/downloads/).
54-
5549
## Custom properties
5650

5751
A component can receive input values and emit data if you create one or more custom properties. These scenarios are advanced and require you to understand [formulas](formula-reference.md) and binding contracts.
@@ -187,6 +181,31 @@ So far, you've created a component and added it to an app. Next, you'll create a
187181
188182
The **Label** control reflects the menu item that you selected most recently.
189183
184+
## Scope
185+
186+
Input and output properties clearly define the interface between a component and its host app. By default, the component is encapsulated so that it's easier to reuse the component across apps, requiring the use of the properties to pass the information in and out of the component. Scope restrictions keep the data contract of a component simple and cohesive, and it helps enable component-definition updates&mdash;especially across apps with component libraries.
187+
188+
But there are times when a component may want to share a data source or a variable with its host. Especially when the component is only intended for use in one particular app. For these cases, you can directly access app level information by turning on the **Access app scope** switch in the component's property pane:
189+
190+
![Access app scope switch in component property pane](media/create-component/access-app-scope.png)
191+
192+
When **Access app scope** is turned on, the following are accessible from within a component:
193+
194+
- Global variables
195+
- Collections
196+
- Controls and components on screens, such as a TextInput control
197+
- Tabular data sources, such as Dataverse tables
198+
199+
When this setting is turned Off, none of the above are available to the component. [**Set**](functions/function-set.md) and [**Collect**](functions/function-clear-collect-clearcollect.md) functions are still available but the resulting variables and collections are scoped to the component instance and not shared with the app.
200+
201+
Non-tabular data sources, such as Azure Blob Storage or a custom connector, are available whether this setting is turned on or off. Think of these data sources more like referencing an environment resource rather than an app resource. When a component is brought into an app from a component library, these data sources from the environment are also brought in.
202+
203+
Components in a component library can never have access to app scope, as there's no single app scope to refer to. So, this setting isn't available in this context, and is effectively off. Once imported into an app, and if customization was allowed by the component maker, the switch can be enabled, and the component can be modified to use the app scope.
204+
205+
> [!NOTE]
206+
> - You can insert instances of components into a screen within a component library, and preview that screen for testing purposes.
207+
> - Component library doesn't display when using [Power Apps Mobile](https://powerapps.microsoft.com/downloads/).
208+
190209
## Import and export components
191210
192211
> [!NOTE]
@@ -249,7 +268,7 @@ Once you save the app, you can reuse the components of this app using the same m
249268
## Known limitations
250269
251270
- You can't save data sources, forms, and data tables with components.
252-
- Collections in components are not supported.
271+
- Collections in components aren't supported.
253272
- You can't insert a component into a gallery or a form.
254273
- A master instance of a component is a local master and scoped to the app. If you change a master instance, only copies of the component within the app will reflect the change. Copies in other apps will remain the same unless you import the component library again. All master instances in those apps will be automatically detected and updated.
255274
- You can't package media files when you import a component.
Loading

powerapps-docs/teams/add-app-notifications.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ Sending an email from Power Apps directly is faster for experienced makers, but
9191

9292
- [Boards (Preview) sample app](boards.md)
9393
- [Bulletins sample app](bulletins.md)
94-
- [Employee ideas sample app](employee-ideas.md)
94+
- [Employee ideas sample app](employee-ideas.md)
95+
- [Get connected (Preview)](get-connected.md)
9596
- [Inspection sample apps](inspection.md)
9697
- [Issue reporting sample apps](issue-reporting.md)
9798
- [Milestones sample app](milestones.md)

0 commit comments

Comments
 (0)