Managing Contact Information with the Flow DesignerLast Updated: 07/15/2016 Introduced in Verision: 2.0
The Contact Info Entity is a folder entity which collects addresses, phone numbers, email addresses and other contact details into a single entity. These contact details can be updated and deleted in a flow by using the ID of the Contact Info Owner with the appropriate steps, such as those under the Phone Service or Email Address Service.
In our example flow, we will use a form to display a Customer’s existing emails and define a new preferred email address for a customer, making sure to update every other email address to non-preferred status. This example assumes that the form Add Email Address Form has already been designed.
We will first navigate to the actions folder of our Customer folder extension type at: System > Common Data Elements > Folder Behavior Actions > UserType.CustomerFolderBehavior. To create our action, we will click the Create Flow button.
In the resulting New Flow pop-up, we will call our action “Add New Primary Email Address” and click OK to open it in the Flow Designer.
First, we will want to retrieve the ID of the Contact Info Owner (or Contact Info Entity). We will find the Get Contact Info Owner Id For Folder component in the Flow Designer start-up window, under the category Integrations > All Integrations > Internal Services > ContactInfoService.
In the Mapping Editor, we map FolderId to folderId. We will also rename the output to “ContactInfoOwnerId”.
Next, we will retrieve all of the existing emails belonging to the Contact Info Owner. We will find the Get All Email For Owner component in the Toolbox tab, under the category Integration > Internal Services > EmailAddressService.
In the Mapping Editor, we will map ContactInfoOwnerId to ownerId, and rename its output to “All Emails”.
Next we will place the form in which the user will see the Customer’s existing emails, and define the new preferred email address. We will find the Add Email Address Form component in the Toolbox tab, under the category Forms [Interaction] > [Root Folder] > Designer Entities.
In the Mapping Editor, we will map AllEmails.All Address to EmailAddresses. We will leave the other fields’ mapping types set to “Ignore”.
Next, we will add the email address defined in our form. We will find the Add Email Address component in the Toolbox tab, under the category Integration > Internal Services > EmailAddressService.
In the Mapping Editor, we will map ContactInfoOwnerId to both ContactInfoID and ownerId. We will also map NewEmailAddress to Email Address and set Preferred Email Address to True.
Next, we will iterate through the Customer’s other emails and set their Preferred Email Address status to False. We will find the ForEach Step component in the Toolbox tab, under the category Flow Management.
Under the Collection section, we will use the Type selector to choose a collection type of EmailAddress.
In the Mapping Editor, we will map All Emails to Collection, and rename the Item output to “ForEachEmail”.
For each email address in our collection, we would like to update its Preferred Email Address status to be unchanged. We will find the Update Email Address component in the Toolbox tab, under the category Integration > Internal Services > EmailAddressService.
In the Mapping Editor, we will set Preferred Email Address to False, and map all other properties of the Email Address item directly to the inputs of the Update Email Address component. We will also map ContactInfoOwnerId to ownerId.
Finally, we will connect our remaining unconnected outcomes.
This completes our flow, so we will save it and close the Flow Designer.
For our new flow to be registered as an action, we must restart the Service Host Manager service.
Back in the portal, we will navigate to a Customer folder. We will see that this customer has two email addresses: “email@example.com” (Preferred) and “firstname.lastname@example.org”.
To test our example flow, we will select the Customer folder and, in its Action menu, we will select Add New Primary Email Address.
In the resulting pop-up, we will see the Add Email Address Form, showing us this customer’s existing email addresses and a textbox for entering a new email address that will be designated as the preferred one. We will enter “email@example.com” in the New Email Address field and click Save.
Back in the Customer folder, we will see that our new email address has been added and designated as the preferred address, while the previous preferred address no longer has that status.