|
| 1 | +--- |
| 2 | +title: "Sample: Workflow operations (Common Data Service) | MicrosoftDocs" |
| 3 | +description: "This sample demonstrates how to perform a number of workflow operations such as create, delete, activate, set state , and more." |
| 4 | +ms.custom: "" |
| 5 | +ms.date: 1/14/2020 |
| 6 | +ms.reviewer: "pehecke" |
| 7 | +ms.service: powerapps |
| 8 | +ms.topic: "samples" |
| 9 | +author: "JimDaly" # GitHub ID |
| 10 | +ms.author: "jdaly" # MSFT alias of Microsoft employees only |
| 11 | +manager: "kvivek" # MSFT alias of manager or PM counterpart |
| 12 | +search.audienceType: |
| 13 | + - developer |
| 14 | +search.app: |
| 15 | + - PowerApps |
| 16 | + - D365CE |
| 17 | +--- |
| 18 | +# Sample: Workflow operations |
| 19 | + |
| 20 | +This sample demonstrates how to perform a number of workflow operations such as create, delete, activate, set state , and more. |
| 21 | + |
| 22 | +Download the sample: [Workflow](https://github.com/microsoft/PowerApps-Samples/tree/master/cds/orgsvc/C%23/Workflow) |
| 23 | + |
| 24 | +## How to run this sample |
| 25 | + |
| 26 | +See [How to run samples](https://github.com/microsoft/PowerApps-Samples/blob/master/cds/README.md) for general information about how to run this sample. |
| 27 | + |
| 28 | +Notice that there are five separate samples, each in it's own C# file, in the solution's [project](https://github.com/microsoft/PowerApps-Samples/tree/master/cds/orgsvc/C%23/Workflow/Workflow). To run each sample, set it as the startup object in the project's properties prior to executing the sample. |
| 29 | + |
| 30 | +## What this sample does |
| 31 | + |
| 32 | +The operations demonstrated by these samples are as follows: |
| 33 | + |
| 34 | +- Create a synchronous (real-time) or asynchronous workflow |
| 35 | +- Delete a workflow |
| 36 | +- Execute a workflow |
| 37 | +- Activate or deactivate a workflow |
| 38 | +- Set or get a workflow's status and state |
| 39 | +- Create a workflow from a template |
| 40 | + |
| 41 | +You can view created workflows in **Settings > Processes** (under Process Center) when viewing your organization using a web browser. |
| 42 | + |
| 43 | +## How this sample works |
| 44 | + |
| 45 | +In order to simulate the scenario described in [What this sample does](#what-this-sample-does), the sample will do the following: |
| 46 | + |
| 47 | +### Setup |
| 48 | + |
| 49 | +Each sample creates any required entity instances that the demonstration code requires. This is done in the `CreateRequiredRecords()` method. |
| 50 | + |
| 51 | +### Demonstrate |
| 52 | + |
| 53 | +The main demonstration code for each sample is found in the `Demonstrate` region of the `Main()` method in each class file. |
| 54 | + |
| 55 | +### Clean up |
| 56 | + |
| 57 | +The `DeleteRequiredRecords()` method displays an option in the console window to delete any records created by the sample(s). |
| 58 | + |
| 59 | +The deletion is optional in case you want to examine the entity instances (records) created by the sample(s). Typically, you would not respond to the delete prompt in the console window until after you view the new organization records in your browser. You can manually delete the created records any time after the program terminates to achieve the same result. |
0 commit comments