Skip to content

Emergency Contact CRUD: Country-based state filtering, simplified delete flow, and complete add/update/delete support#498

Merged
srideshpande merged 5 commits into
mainfrom
user/srdeshpande/Workday-Update-EmergencyContact
Apr 29, 2026
Merged

Emergency Contact CRUD: Country-based state filtering, simplified delete flow, and complete add/update/delete support#498
srideshpande merged 5 commits into
mainfrom
user/srdeshpande/Workday-Update-EmergencyContact

Conversation

@srideshpande
Copy link
Copy Markdown
Contributor

Emergency Contact CRUD: Country-based state filtering, simplified delete flow, and complete add/update/delete support

Summary

Complete overhaul of the WorkdayManageEmergencyContact topic to support all four emergency contact operations (View, Create, Update, Delete) with country-aware state filtering, correct Workday region codes, and an optimized delete flow.

Issues Fixed

  • State/Province dropdown showed all states from all countries regardless of the selected country
  • Country Region IDs for India (IND-TGIN-TS), Australia (AUS-NSWAU-NSW), and Canada (CAN-ABCA-AB) did not match Workday's Country_Region_ID format, causing Invalid ID value errors on submit
  • Phone country code defaulted to USA (+1) even when address country was changed to India/Australia/etc., causing Invalid number: 1 is not a valid country code for AUS errors
  • Country field was an editable Input.Text on the form, allowing users to type a display name (e.g., "United States") which overwrote the ISO code (USA), causing Text length of 13 exceeds 3 for ISO 3166-1 Alpha-3 Code errors
  • Delete required 4 clicks (Select contact → Country selection → Edit form → Delete button → Confirm), making it unnecessarily cumbersome
  • Create flow was initially removed when only Update was requested, then had to be re-added — now both coexist cleanly
  • Static state/province table (~95 records) was rebuilt on every topic invocation, impacting card rendering performance

What Was Solved

  • Country-filtered state dropdown: Split form into 2 steps — country selection card first, then the main form with states filtered to that country only
  • Correct Workday Country_Region_IDs: Updated India (14 → 37 states, IND-XXIN-XX), Australia (AUS-XXAU-XX), Canada (CAN-XXCA-XX, added 3 missing territories)
  • Smart phone country code defaulting: In update mode, preserves existing phone code; in add mode, defaults to the address country's dial code
  • Read-only country display: Country shown as TextBlock (not editable input) on the main form to prevent ISO code corruption
  • 2-click delete flow: "Delete contact" button added directly to the contact selection card, jumping straight to confirmation — bypasses country selection and edit form entirely
  • Intent-aware selection card: When user says "delete"/"remove", the card shows only Delete + Cancel buttons (no Continue/Add clutter)
  • Global state table initialization: Global.StateProvinceChoices initialized once per session (like other reference data), not rebuilt on every topic run
  • "Is there anything else?" footer: Added after successful update/add/delete operations
  • Full CRUD support: View, Create, Update, Delete all functional with clean separation

Main Pain Points Addressed

  1. Data integrity: Wrong region codes and country codes caused Workday API rejections — users couldn't update contacts with non-US addresses
  2. UX friction: Delete took 4 steps when it should take 2
  3. Confusing UI: All states from all countries in one dropdown; editable country field misleading users
  4. Performance: Large static table rebuilt on every invocation

How to Test

Option A: Test in SD_ESSTest_Environment

  1. Navigate to the ESS agent in SD_ESSTest_Environment
  2. Test each scenario below

Option B: Set up in your own environment

  1. Import the updated topic.yaml into your Copilot Studio environment
  2. Ensure msdyn_HRWorkdayHCMEmployeeGetEmergencyContactInfo, msdyn_UpdateEmergencyContact, msdyn_HRWorkdayHCMEmployeeAddEmergencyContact, and msdyn_DeleteEmergencyContact API scenarios are configured
  3. Verify GetReferenceData dialog returns Country_Phone_Code_ID and Related_Person_Relationship_ID reference data

Test Scenarios

# Scenario Prompt Expected
1 View "Show my emergency contacts" Displays contact table in Adaptive Card, no edit options
2 Create (direct) "Add emergency contact" Skips contact list → Country selection → Empty form → Submit to Workday
3 Create (from list) "Manage emergency contacts" → click "Add an emergency contact" Same add form flow
4 Update (USA) "Update emergency contact" → select contact → USA → edit fields → Submit Only US states shown, update succeeds
5 Update (India) Same flow → select India as country Only Indian states shown with IN-XX codes, submit succeeds
6 Update (Australia) Same flow → select Australia Only AU states shown with AU-XX codes
7 Delete (direct) "Delete emergency contact" → select contact → Delete → Confirm Only Delete + Cancel buttons shown, 2-click flow
8 Delete (from manage) "Manage emergency contacts" → select contact → Delete contact All 3 buttons shown, delete jumps to confirmation
9 Delete primary blocked Try to delete primary contact Shows "cannot delete primary" message
10 Cancel flows Cancel at any step Shows cancellation message, ends dialog
11 Phone code default Add contact with India selected Phone defaults to India (+91), not USA (+1)
12 Country read-only Open update/add form Country shown as non-editable text label

Before and After Screenshots

TODO: Add screenshots for:

  • Before: State dropdown showing all countries mixed together
Em Contact - states and country dropdown issue
  • After: State dropdown filtered to selected country only
Fixed Em Contact - states and country dropdown
  • Before: Delete requiring 4 clicks through edit form
Delete requiring 4 clicks through edit form
  • After: Delete from selection card in 2 clicks
Delete emergency contact
  • Before: Editable country text field
Editable country text field
  • After: Read-only country display
Read-only country display
  • Add contact success card
  • Update contact success card
Em Contact Updated
  • Delete contact confirmation + success cards
Delete success

@srideshpande srideshpande requested a review from a team as a code owner April 24, 2026 18:26
@srideshpande srideshpande self-assigned this Apr 28, 2026
@srideshpande srideshpande merged commit d7c0611 into main Apr 29, 2026
7 checks passed
@srideshpande srideshpande deleted the user/srdeshpande/Workday-Update-EmergencyContact branch April 29, 2026 20:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants