Sample: Work with activity party records

This sample code shows how to work with activity party records. Learn how to create a letter activity addressed to multiple contacts.

Related article: Activity tables

About the sample code

Sample Description Build target
ActivityParty Demonstrates creating a letter activity. .NET 9

The code sample demonstrates how to create a letter activity. Specifically, the samples demonstrate how to:

  1. Connect to Dataverse using a connection string that defines required connection information
  2. Create a letter activity to send to multiple contacts
  3. Use the Dataverse organization service context to process the data changes
  4. Use early-bound entity types

The code being demonstrated can be found in the Program.CreateLetter() method invoked by Program.Run().

The early-bound entity files in the DataModel project were generated using the following PAC CLI command: pac modelbuilder build. More information: pac modelbuilder

More general information can be found in README-code-design file.

How to build and run the code sample

  1. Clone the PowerApps-Samples repository.
  2. Locate the sample folder.
  3. Open the solution file (*.sln) in Visual Studio.
  4. Edit the project's appsettings.json file and set the Urlvalue as appropriate for your Dataverse test environment.
  5. Build and run the project [F5].
  6. You are prompted in a browser window for account sign-in credentials to the target environment.

Expected program output

For a successful run, the program's console output should look similar to the following example. Otherwise, any errors or exceptions are displayed.

CreateLetter(): letter activity created with ID < >
Press any key to undo environment data changes.