/

Create a Dynamics 365 Customer Service Case from Power Apps: Series 4

Power Apps gallery field configuration screenshot

Agents or intake teams may need a lightweight screen to register a customer issue. This part creates a Case in Dataverse and validates the minimum information before saving.

1. Prepare the form

Add inputs for subject, description, customer, origin, and priority. Use a Dataverse lookup control for Customer so the selected Account or Contact remains a real lookup record rather than plain text.

2. Validate required values

If(
    IsBlank(Trim(txtSubject.Text)),
    Notify("Enter a case subject.", NotificationType.Warning),
    If(
        IsBlank(cmbCustomer.Selected),
        Notify("Select an account or contact.", NotificationType.Warning),
        Set(varCanCreateCase, true)
    )
)

3. Create the record

IfError(
    Set(
        varNewCase,
        Patch(
            Cases,
            Defaults(Cases),
            {
                Title: Trim(txtSubject.Text),
                Description: txtDescription.Text,
                Customer: cmbCustomer.Selected
            }
        )
    ),
    Notify("Case could not be created: " & FirstError.Message, NotificationType.Error),
    Notify("Case created successfully.", NotificationType.Success);
    Navigate(scrCaseDetails)
)

Column names shown are illustrative display names. Add required fields configured in your organization, and confirm that the selected Customer record matches the polymorphic lookup’s accepted Account or Contact type.

4. Production considerations

  • Do not set system-managed fields such as ticket number or created on.
  • Use Dataverse security roles to control create privileges.
  • Prevent duplicate submissions by disabling the save button while the request is running.
  • Log actionable errors without exposing sensitive customer data in notifications.