This part adds contact maintenance to the canvas app. A seller can create a new contact or update an existing one while Dataverse enforces required columns, security, and server-side business rules.
1. Configure the Edit form
Add an Edit form named frmContact. Set its DataSource to Contacts and Item to the selected contact. Add first name, last name, job title, email, business phone, and Parent Customer. Use the generated lookup control for the parent customer field.
// New contact
NewForm(frmContact);
Navigate(scrContactEdit, ScreenTransition.Fade)
// Edit selected contact
EditForm(frmContact);
Navigate(scrContactEdit, ScreenTransition.Fade)
// Save
SubmitForm(frmContact)
2. Handle successful save
// frmContact.OnSuccess
Set(varSelectedContact, frmContact.LastSubmit);
Notify("Contact saved.", NotificationType.Success);
ViewForm(frmContact);
Navigate(scrContactProfile, ScreenTransition.Fade)
3. Handle validation failures
// frmContact.OnFailure
Notify(
"Contact could not be saved: " & frmContact.Error,
NotificationType.Error
)
4. Set the parent Account
Configure the Parent Customer data card using a Combo box bound to Accounts if your app only permits Account parents. Its Update property must return the selected Account record in the lookup type expected by Dataverse, not the account name string. Keep the card’s generated default and update logic where possible.
5. Test CRM behavior
- Create a contact linked to a test Account.
- Open the contact in Dynamics 365 and verify the relationship.
- Update an email and phone number.
- Test required-field and duplicate-detection rules.
- Test with a user who has restricted Contact privileges.
