Phone info CRUD and linking¶
clsPhoneInfo is a standalone PHONE row that concatenates its country code, area code, prefix, number, and extension into a single stored value (unless the number is foreign). As with addresses and emails, the owning collection tracks adds/removes and reconciles the COMPANY_PHONE / PERSON_PHONE link rows on save.
| Field | Value |
|---|---|
| Operation ID | OP-CC-07 |
| Trigger | Caller adds/removes a clsPhoneInfo in clsCustomer.Phones or clsContact.Phones, then the parent's Save() cascades into the collection; or mdlCustomerContact.CreatePhone is called directly |
| Inputs | PhoneID, Value/FormattedValue, PhoneCode (phone type), IsPrimary, IsForeign |
| Outputs | Persisted PHONE row; persisted or removed COMPANY_PHONE / PERSON_PHONE link row |
| Primary components | clsPhoneInfo.Create, clsPhoneInfo.SetStoredVersion, clsPhoneInfo.AddBusinessRules, mdlCustomerContact.CreatePhone, clsInfoCollection.Save |
| Entry point | Business\SAIF.Business.CustomerContact\InfoItems\clsPhoneInfo.vb |
Steps¶
- Create a new phone row.
Create()assignsPhoneIDfromGetNextSeqNum("PHONE_SEQ"). - Normalize the stored value.
SetStoredVersion()concatenatesCountryCode,AreaCode,Prefix,Number, andExtensioninto the persisted phone value; this normalization is skipped whenIsForeign = True, leaving the foreign value as entered. - Validate (BR-007).
AddBusinessRulesregistersCommonBusinessRules.NonZeroDecimalRequiredforPhoneIDandCommonBusinessRules.TrimTextRequiredforFormattedValue(with theBusiness_External_Users.ErrMsgPhoneRequiredmessage). - Persist the root
PHONErow. Insert (SQL-016/SQL-017), update (SQL-073/SQL-074), and delete (SQL-090/SQL-091) against PHONE. - Reconcile link rows through
clsInfoCollection.Save(), using the same add/remove-tracking pattern used for addresses and emails (see Address info CRUD and linking): save current phone rows, delete removed link rows (customer: SQL-087 against COMPANY_PHONE; contact: SQL-081 against PERSON_PHONE), then insert added link rows (customer: SQL-013; contact: SQL-007). - Helper factory flow.
mdlCustomerContact.CreatePhone(dpi, contact, phoneNumber, isForeignPhone, isPrimary, phoneType): - Creates
clsPhoneInfo.NewPhone(dpi). - Sets
Value,IsPrimary, andIsForeign. - Resolves
PhoneCodefrommdlCodeMaps.GetPhoneTypes(dpi)(phoneType).Code. - Adds the new phone to
contact.Phonesonly ifphone.IsValid— invalid phones are constructed but not attached to the contact. - Resolve the phone-type description.
PhoneTypeDescriptioncallsGetPhoneCode(dpi)(PhoneCode).Descriptionfrom the sharedSAIF.Businesscode-map module for display purposes only.
Process flow¶
The following diagram visualizes phone normalization and the save/link cycle, including the helper factory's validity gate.
flowchart TD
Start([Caller sets phone fields]) --> Foreign{IsForeign?}
Foreign -->|No| Normalize[SetStoredVersion:<br>concatenate country/area/prefix/number/ext]
Foreign -->|Yes| KeepForeign[Keep foreign value as entered]
Normalize --> Validate{PhoneID and<br>FormattedValue valid?}
KeepForeign --> Validate
Validate -->|No| Blocked([Broken rule added])
Validate -->|Yes| ParentSave([Parent Save cascades to collection])
ParentSave --> SaveRows[Save each current PHONE row]
SaveRows --> DeleteLinks[Delete link rows for RemovedItems]
DeleteLinks --> InsertLinks[Insert link rows for AddedItems]
InsertLinks --> Done([Collection persisted])
Helper([mdlCustomerContact.CreatePhone]) --> Build[Build clsPhoneInfo;<br>resolve PhoneCode from mdlCodeMaps]
Build --> ValidGate{phone.IsValid?}
ValidGate -->|Yes| Attach[Add to contact.Phones]
ValidGate -->|No| Discard([Phone object returned<br>but not attached])
Failure and edge-case behavior¶
- Missing/zero
PhoneIDor a blankFormattedValueblocks the save with a broken rule before thePHONEinsert/update executes (BR-007). mdlCustomerContact.CreatePhoneonly attaches the phone to the contact when it is already valid, so a caller relying on this helper never sees an invalid phone silently added to the collection — unlike the equivalent email helper,CreateEmail, which adds unconditionally.- Removing a phone from a collection deletes only the
COMPANY_PHONE/PERSON_PHONElink row, not the standalonePHONErow.* - Foreign phone numbers bypass the country/area/prefix/extension concatenation entirely, so their stored format depends solely on what the caller supplied in
Value.*
Note: Statements marked with
*were inferred from code structure, naming conventions, or contextual evidence where direct confirmation was not available in source artifacts.
Related documentation¶
Sources¶
Business\SAIF.Business.CustomerContact\InfoItems\clsPhoneInfo.vbBusiness\SAIF.Business.CustomerContact\InfoItems\clsInfoCollection.vbBusiness\SAIF.Business.CustomerContact\Customer\clsCustomerPhoneCollection.vbBusiness\SAIF.Business.CustomerContact\Contact\clsContactPhoneCollection.vbBusiness\SAIF.Business.CustomerContact\mdlCustomerContact.vb