Skip to content

Commit 37b8ad9

Browse files
authored
Merge branch 'main' into mints-norah-ai-field-suggestions
2 parents 5c89752 + ed88728 commit 37b8ad9

File tree

7 files changed

+217
-56
lines changed

7 files changed

+217
-56
lines changed
Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
---
2+
title: "Web API table schema operations sample (PowerShell) (Microsoft Dataverse)| Microsoft Docs"
3+
description: "This sample demonstrates how to perform operations that change the Dataverse data structures using the Web API with PowerShell."
4+
ms.date: 05/14/2024
5+
author: mkannapiran
6+
ms.author: kamanick
7+
ms.reviewer: jdaly
8+
search.audienceType:
9+
- developer
10+
contributors:
11+
- JimDaly
12+
---
13+
14+
# Web API table schema operations sample (PowerShell)
15+
16+
[!INCLUDE[cc-terminology](../../includes/cc-terminology.md)]
17+
18+
This PowerShell sample demonstrates how to perform operations that create and modify table, column, and relationship definitions using the Dataverse Web API.
19+
20+
This sample implements the Dataverse operations and console output detailed in [Web API table schema operations sample](../web-api-metadata-operations-sample.md) and uses the [Dataverse Web API PowerShell Helper functions](https://github.com/microsoft/PowerApps-Samples/blob/master/dataverse/webapi/PS/README.md) to manage authentication and provide reusable functions to perform common operations. These scripts are referenced using [dot sourcing](/powershell/module/microsoft.powershell.core/about/about_scripts#script-scope-and-dot-sourcing) with the following lines:
21+
22+
```powershell
23+
. $PSScriptRoot\..\Core.ps1
24+
. $PSScriptRoot\..\TableOperations.ps1
25+
. $PSScriptRoot\..\CommonFunctions.ps1
26+
. $PSScriptRoot\..\MetadataOperations.ps1
27+
```
28+
29+
> [!NOTE]
30+
> This sample should work with Windows, Linux, and macOS, but has only been tested on Windows.
31+
32+
## Prerequisites
33+
34+
Before running this sample, you should read these articles that explain concepts and patterns used by these samples:
35+
36+
- [Quick Start Web API with PowerShell and Visual Studio Code](../quick-start-ps.md)
37+
- [Use PowerShell and Visual Studio Code with the Dataverse Web API](../use-ps-and-vscode-web-api.md)
38+
39+
These articles have the same prerequisites.
40+
41+
[!INCLUDE [cc-visual-studio-code-powershell-prerequisites](../../includes/cc-visual-studio-code-powershell-prerequisites.md)]
42+
43+
## How to run this sample
44+
45+
1. Clone or download the [PowerApps-Samples](https://github.com/microsoft/PowerApps-Samples) repository.
46+
1. Open the `/dataverse/webapi/PS/MetadataOperations/MetadataOperationsSample.ps1` file using Visual Studio Code
47+
1. Edit this line to use the URL of the environment you want to connect to:
48+
49+
`Connect 'https://yourorg.crm.dynamics.com/' # change this`
50+
51+
1. (Optional) Set the `$deleteCreatedRecords` variable to `$false` if you don't want to delete the records this sample creates.
52+
1. Press <kbd>F5</kbd> to run the sample.
53+
1. The first time you run the sample a browser window opens. In the browser window, enter or select the credentials you want to use to authenticate.
54+
55+
To connect as a different user, run the [Disconnect-AzAccount command](/powershell/module/az.accounts/disconnect-azaccount) and try again.
56+
57+
## Code
58+
59+
The code for this sample is at: [PowerApps-Samples/dataverse/webapi/PS/MetadataOperations/MetadataOperationsSample.ps1](https://github.com/microsoft/PowerApps-Samples/blob/master/dataverse/webapi/PS/MetadataOperations/MetadataOperationsSample.ps1)
60+
61+
## Demonstrates
62+
63+
This sample has 11 regions:
64+
65+
### Section 0: Create Publisher and Solution
66+
67+
Operations: Create a solution record and an associated publisher record.
68+
69+
> [!NOTE]
70+
> All solution components created in this sample will be associated to the solution so that they can be exported. For operations without a named message, this association is created using the `MSCRM.SolutionUniqueName` request header setting the solution unique name set as the value.
71+
> All names of solution components are prefixed using the publisher customization prefix.
72+
73+
### Section 1: Create, Retrieve and Update Table
74+
75+
Operations:
76+
77+
1. Create a new `sample_BankAccount` user-owned table by sending a `POST` request to `/EntityDefinitions`.
78+
1. Retrieve the created table by sending a `GET` request to `/EntityDefinitions(LogicalName='sample_bankaccount')`.
79+
1. Update the table by sending a `PUT` request to `/EntityDefinitions(LogicalName='sample_bankaccount')`.
80+
81+
### Section 2: Create, Retrieve and Update Columns
82+
83+
Operations:
84+
85+
1. Attempt to retrieve a `sample_boolean` boolean column by sending a `GET` request to `/EntityDefinitions(LogicalName='sample_bankaccount')/Attributes(LogicalName='sample_boolean')`.
86+
1. If the column doesn't already exist, create a new `sample_boolean` boolean column for the `sample_BankAccount` table by sending a `POST` request to `/EntityDefinitions(LogicalName='sample_bankaccount')/Attributes`.
87+
1. Update the `sample_boolean` boolean column by sending a `PUT` request to `/EntityDefinitions(LogicalName='sample_bankaccount')/Attributes(LogicalName='sample_boolean')`.
88+
1. Update the option labels for the `sample_boolean` boolean column using the [UpdateOptionValue action](xref:Microsoft.Dynamics.CRM.UpdateOptionValue).
89+
1. Attempt to retrieve a `sample_datetime` datetime column for the `sample_BankAccount` table, and create it if it doesn't exist.
90+
1. Attempt to retrieve a `sample_decimal` decimal column for the `sample_BankAccount` table, and create it if it doesn't exist.
91+
1. Attempt to retrieve a`sample_integer` integer column for the `sample_BankAccount` table, and create it if it doesn't exist.
92+
1. Attempt to retrieve a `sample_memo` memo column for the `sample_BankAccount` table, and create it if it doesn't exist.
93+
1. Attempt to retrieve a `sample_money` money column for the `sample_BankAccount` table, and create it if it doesn't exist.
94+
1. Attempt to retrieve a `sample_choice` choice column for the `sample_BankAccount` table, and create it if it doesn't exist.
95+
1. Add a new option to the `sample_choice` column using the [InsertOptionValue action](xref:Microsoft.Dynamics.CRM.InsertOptionValue).
96+
1. Change the order of the options of the `sample_choice` column using the [OrderOption action](xref:Microsoft.Dynamics.CRM.OrderOption).
97+
1. Delete one of the options of the `sample_choice` column using the [DeleteOptionValue action](xref:Microsoft.Dynamics.CRM.DeleteOptionValue).
98+
1. Attempt to retrieve a `sample_multiselectchoice` multi-select choice column for the `sample_BankAccount` table, and create it if it doesn't exist.
99+
1. Create a new Status option for the `sample_BankAccount` table using the [InsertStatusValue Action](xref:Microsoft.Dynamics.CRM.InsertStatusValue).
100+
101+
### Section 3: Create and use Global OptionSet
102+
103+
Operations:
104+
105+
1. Create a new global choice named `sample_colors` by sending a `POST` request to `/GlobalOptionSetDefinitions`.
106+
1. Retrieve the `sample_colors` global choice by sending a `GET` request to `/GlobalOptionSetDefinitions(<id value>)`.
107+
1. Create a new `sample_colors` choice column for the `sample_BankAccount` table using the `sample_colors` global choice by sending a `POST` request to `/EntityDefinitions(LogicalName='sample_bankaccount')/Attributes` and associating it to the global choice.
108+
109+
### Section 4: Create Customer Relationship
110+
111+
Operations:
112+
113+
1. Create a new `sample_customerid` customer column for the `sample_BankAccount` table using the [CreateCustomerRelationships Action](xref:Microsoft.Dynamics.CRM.CreateCustomerRelationships).
114+
1. Retrieve the `sample_customerid` customer column by sending a `GET` request to `/EntityDefinitions(LogicalName='sample_bankaccount')/Attributes(LogicalName='sample_customerid')`.
115+
1. Retrieve the relationships created for the customer column by sending `GET` requests to `/RelationshipDefinitions(<id>)/Microsoft.Dynamics.CRM.OneToManyRelationshipMetadata`.`.
116+
117+
### Section 5: Create and retrieve a one-to-many relationship
118+
119+
Operations:
120+
121+
1. Verify that the `sample_BankAccount` table is eligible to be referenced in a 1:N relationship using the [CanBeReferenced function](xref:Microsoft.Dynamics.CRM.CanBeReferenced).
122+
1. Verify that the `contact` table is eligible to be reference other tables in a 1:N relationship using the [CanBeReferencing function](xref:Microsoft.Dynamics.CRM.CanBeReferencing).
123+
1. Identify what other tables can reference the `sample_BankAccount` table in a 1:N relationship using the [GetValidReferencingEntities function](xref:Microsoft.Dynamics.CRM.GetValidReferencingEntities).
124+
1. Create a 1:N relationship between `sample_BankAccount` and `contact` tables by sending a `POST` request to `/RelationshipDefinitions`.
125+
1. Retrieve the 1:N relationship by sending `GET` request to `/RelationshipDefinitions(<id>)/Microsoft.Dynamics.CRM.OneToManyRelationshipMetadata`.
126+
127+
### Section 6: Create and retrieve a many-to-one relationship
128+
129+
Operations:
130+
131+
1. Create a N:1 relationship between `sample_BankAccount` and `account` tables by sending `POST` a request to `/RelationshipDefinitions`.
132+
1. Retrieve the N:1 relationship by sending a `GET` request to `/RelationshipDefinitions(<id>)/Microsoft.Dynamics.CRM.OneToManyRelationshipMetadata`.
133+
134+
### Section 7: Create and retrieve a many-to-many relationship
135+
136+
Operations:
137+
138+
1. Verify that the `sample_BankAccount` and `contact` tables are eligible to participate in a N:N relationship using the [CanManyToMany function](xref:Microsoft.Dynamics.CRM.CanManyToMany).
139+
1. Verify that the `sample_BankAccount` and `contact` tables are eligible to participate in a N:N relationship using the [GetValidManyToMany Function](xref:Microsoft.Dynamics.CRM.GetValidManyToMany).
140+
1. Create a N:N relationship between `sample_BankAccount` and `contact` tables by sending a `POST` request to `/RelationshipDefinitions`.
141+
1. Retrieve the N:N relationship by sending `GET` request to `/RelationshipDefinitions(<id>)/Microsoft.Dynamics.CRM.ManyToManyRelationshipMetadata`.
142+
143+
### Section 8: Export managed solution
144+
145+
Operations: Export the solution created in [Section 0: Create Publisher and Solution](#section-0-create-publisher-and-solution) containing the items created in this sample using the [ExportSolution Action](xref:Microsoft.Dynamics.CRM.ExportSolution).
146+
147+
### Section 9: Delete sample records
148+
149+
Operations: A reference to each record created in this sample was added to a list as it was created. In this sample the records are deleted in the reverse order in which they were created.
150+
151+
### Section 10: Import and Delete managed solution
152+
153+
Operations:
154+
155+
1. Import the solution exported in [Section 8](#section-8-export-managed-solution) using the [ImportSolution action](xref:Microsoft.Dynamics.CRM.ImportSolution).
156+
1. Query the solution table to get the `solutionid` of the imported solution.
157+
1. Delete the imported solution using the `solutionid`.
158+
159+
## Clean up
160+
161+
By default this sample will delete all the records created in it. If you want to view created records after the sample is completed, change the `deleteCreatedRecords` variable to `false` and you will be prompted to decide if you want to delete the records.
162+
163+
### See also
164+
165+
[Use the Dataverse Web API](../overview.md)<br />
166+
[Use the Web API with table definitions](../use-web-api-metadata.md)<br />
167+
[Web API Samples](../web-api-samples.md)<br />
168+
[Web API Basic Operations Sample (PowerShell)](basic-operations-powershell.md)
169+
170+
[!INCLUDE[footer-include](../../../../includes/footer-banner.md)]

powerapps-docs/developer/data-platform/webapi/samples/toc.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ items:
4949
href: ../web-api-samples-powershell.md
5050
- name: Basic Operations
5151
href: basic-operations-powershell.md
52+
- name: Metadata Operations
53+
href: metadata-operations-powershell.md
5254
- name: (JavaScript) samples
5355
items:
5456
- name: About the client-side samples

powerapps-docs/developer/data-platform/webapi/web-api-samples-powershell.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: "Web API Data operations Samples PowerShell"
33
description: "This article provides a description of Web API samples that are implemented using PowerShell"
4-
ms.date: 01/20/2024
4+
ms.date: 05/14/2024
55
author: divkamath
66
ms.author: dikamath
77
ms.reviewer: jdaly
@@ -25,7 +25,7 @@ The following samples use the patterns described here:
2525
|Not available yet| [Web API Query Data Sample](web-api-query-data-sample.md)| Demonstrates how to use OData v4 query syntax and functions and Dataverse query functions. Includes examples of working with predefined queries and using FetchXML to perform queries. |
2626
|Not available yet| [Web API Conditional Operations Sample](web-api-conditional-operations-sample.md) | Demonstrates how to perform conditional operations you specify with ETag criteria.|
2727
|Not available yet|[Web API Functions and Actions Sample](web-api-functions-actions-sample.md)| Demonstrates how to use bound and unbound functions and actions, including custom actions.|
28-
|Not available yet|[Web API table schema operations sample](web-api-metadata-operations-sample.md)|Demonstrates how to perform selected operations that modify the Dataverse schema, or metadata.|
28+
|[Web API table schema operations sample (PowerShell)](samples/metadata-operations-powershell.md)|[Web API table schema operations sample](web-api-metadata-operations-sample.md)|Demonstrates how to perform selected operations that modify the Dataverse schema, or metadata.|
2929

3030

3131
## Prerequisites

powerapps-docs/developer/model-driven-apps/clientapi/reference/executioncontext/getEventSource.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: "getEventSource (Client API reference) in model-driven apps| MicrosoftDoc
33
description: "Learn about the getEventSource method that returns a reference to the object that the event occurred on."
44
author: adrianorth
55
ms.author: aorth
6-
ms.date: 03/12/2022
6+
ms.date: 05/15/2024
77
ms.reviewer: jdaly
88
ms.topic: reference
99
applies_to: "Dynamics 365 (online)"
@@ -24,7 +24,7 @@ Returns a reference to the object that the event occurred on.
2424

2525
**Type**: Object
2626

27-
**Description**: Returns the object from the **Xrm** object model that is the source of the event, not an HTML DOM object. For example, in an [OnChange](../events/attribute-onchange.md) event, this method returns the **formContext.data.entity** object that represents the changed column.
27+
**Description**: Returns the object from the **Xrm** object model that is the source of the event, not an HTML DOM object. For example, in an [OnChange](../events/attribute-onchange.md) event, this method returns an item from the **formContext.data.entity.attributes** collection that represents the changed column.
2828

2929
[!INCLUDE[cc-terminology](../../../../data-platform/includes/cc-terminology.md)]
3030

19 KB
Loading
Lines changed: 19 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
---
22
title: "Monitor and manage real-time workflow processes with Power Apps | MicrosoftDocs"
3-
description: "Learn how to manage real-time workflow processes with Power Apps"
3+
description: "Learn how to manage real-time workflow processes with Power Apps."
44
ms.custom: ""
5-
ms.date: 09/03/2020
6-
ms.reviewer: ""
7-
5+
ms.date: 05/14/2024
6+
ms.reviewer: "matp"
87
ms.suite: ""
98
ms.tgt_pltfrm: ""
109
ms.topic: "article"
@@ -23,17 +22,15 @@ search.audienceType:
2322
---
2423
# Monitor and manage real-time workflow processes
2524

26-
27-
2825
To monitor and manage processes, you must locate the process, evaluate the status, and perform any actions necessary to address problems.
2926

3027
<a name="BKMK_MonitorSyncWorkflows"></a>
3128
## Monitoring real-time workflows and actions
32-
Real-time workflows and actions do not use System Job rows because they occur immediately. Any errors that occur will be displayed to the user in the application with the heading **Business Process Error**.
29+
Real-time workflows and actions don't use System Job rows because are displayed to the user in the application with the heading **Business Process Error**.
3330

34-
There is no log for successful operations. You can enable logging for errors by checking the **Keep Logs for workflow jobs that encountered errors** option in the **Workflow Log Retention** area at the bottom of the **Administration** tab for the process.
31+
There's no log for successful operations. You can enable logging for errors by checking the **Keep Logs for workflow jobs that encountered errors** option in the **Workflow Log Retention** area at the bottom of the **Administration** tab for the process.
3532

36-
To view the log of errors for a specific process, open the real-time workflow or action definition and go to the **Process Session** tab. This will only show any errors logged for this process.
33+
To view the log of errors for a specific process, open the real-time workflow or action definition and go to the **Process Session** tab. This log only shows errors logged for this process.
3734

3835
If you want a view of all the errors for any process, go to **Advanced Find** and create a view showing errors on the process session table.
3936

@@ -52,17 +49,14 @@ When you view a list of real-time workflow processes, any individual process can
5249

5350
If your organization uses background workflows or business process flows that run frequently, the amount of process log rows can become large enough to cause performance issues as well as consume significant amounts of storage. To delete process log rows not removed sufficiently by one of the standard bulk row deletion jobs, you can use the bulk delete system jobs feature to create a custom bulk row deletion job.
5451

55-
1. Go to **Settings** > **Data Management** > **Bulk Row Deletion**.
56-
57-
2. From the **Bulk Row Deletion** area, select **New**.
58-
59-
3. On the **Bulk Deletion Wizard** start page, select **Next**.
52+
1. Go to the [Power Platform admin center](https://admin.powerplatform.microsoft.com/), and open the environment you want.
53+
1. Go to **Settings** > **Data Management** > **Bulk deletion**.
54+
1. From the **Bulk Record Deletion** area, select **New**.
55+
1. On the **Bulk Deletion Wizard** start page, select **Next**.
56+
1. In the **Look for** list, select **System Jobs**.
57+
1. The following conditions are used to create a bulk row deletion job to delete process log rows:
6058

61-
4. In the **Look for** list, select **System Jobs**.
62-
63-
5. The following conditions are used to create a bulk row deletion job to delete process log rows:
64-
65-
- **System Job Type Equals Workflow**: This targets real-time workflow rows.
59+
- **System Job Type Equals Workflow**: This targets real-time workflow rows.
6660

6761
- **Status Equals Completed**: Only completed workflows are valid to run the job against.
6862

@@ -72,26 +66,19 @@ If your organization uses background workflows or business process flows that ru
7266

7367
![View of a page for custom bulk row deletions.](media/custom-bulk-record-deletion.png)
7468

75-
6. Select **Next**.
69+
7. Select **Next**.
7670

77-
7. Set the frequency that your bulk delete job will run. You can schedule your job to run at set intervals or create a one-time bulk deletion job [using the Immediately option](#using-the-immediately-option). In this example, a recurring job is set to run on May 21, 2018, and every 30 days thereafter.
71+
8. Set the frequency that your bulk delete job runs. In this example, a recurring job is set to run on May 14, 2024, and every 30 days thereafter.
7872

7973
![Bulk row deletion options.](media/custom-bulk-record-delete-options.png)
74+
> [!NOTE]
75+
> Performing an immediate synchronous bulk delete of the rows by selecting the **Immediately** option is deprecated and no longer available for use.
8076
81-
### Using the Immediately option
82-
83-
Notice that you have the option of performing an immediate synchronous bulk delete of the rows by selecting the **Immediately** option. This delete is performed with direct SQL Server execution rather than passing each row through the delete event pipeline, which can reduce the impact to system performance. This is a good option if you want to quickly clean up the extra real-time workflow rows instead of the bulk delete job waiting in the asynchronous queue for processing.
77+
9. Select **Next**, and then select **Submit**.
8478

85-
The **Immediately** option is enabled when the following conditions are true:
86-
- Bulk delete job is for the System Jobs table.
87-
- The search criteria has the condition system job type equals workflow.
88-
- The user creating the bulk delete job has global depth for the delete privilege on the AsyncOperation table. The system administrator security role has this privilege.
79+
## Next steps
8980

90-
The synchronous bulk delete will only delete AsyncOperation rows in the completed state. A maximum of 1 million rows are processed for each invocation. You will need to execute the job multiple times if your environment has more than 1 million rows to remove.
91-
92-
## Next steps
9381
[Best practices for real-time workflow processes](best-practices-workflow-processes.md) <br />
9482

9583

96-
9784
[!INCLUDE[footer-include](../../includes/footer-banner.md)]

0 commit comments

Comments
 (0)