Dealing with multiple email addresses and phone numbers for and iOS Shortcuts

Since working with Shortcuts, I’ve had a quandary over what to do if people have multiple phone numbers or multiple email addresses in my Contacts database.

For example, I was trying to make a shortcut today to send a group text reminding people of a meeting, but for some of the people I have a work number in addition to a mobile number, and at least one still has a home landline.

Previously I have made a shortcut that fetches people’s email addresses, but some people have more than one email. Some might be a “work” email vs a “personal” email.

Shortcuts does not (yet?) let you specify that you want “home” email addresses or “mobile” phone numbers, and I’m not sure it will any time soon.

My strategy for dealing with this before has always been to move the email or phone down to the “notes” section of the contact, but that was unsatisfying. For one thing, it’s no longer ‘clickable’ if I do want to contact them at that phone number or email address.

The solution seems obvious now.

Instead of using the usual fields for phone numbers or email addresses, I’ve moved them to URL fields.

Email addresses just go after mailto:

Phone numbers go after tel://

You can change the label on the URL to say if it is “home” or “work” (or customize it), so when you are looking at the contact information, it’s easy to tell “Oh that must be her work number” or “That must be his work email.”

I left the primary email and primary phone numbers in the usual fields, and moved the secondary/backup Information to URLs.

You can still click/tap them and they will do what you’d want, but when you use “Get Details of Contact” you will get the “primary” information instead.

One Weird Thing…

When I copied the phone numbers into a tel:// URL on my Mac, the showed just the phone number, but on my iOS devices, there was some extra “cruft” around the number (looked like percent-encoding). Editing the contact info on the iOS devices got rid of the cruft, but I’m not sure what caused it to be there in the first place. I even tried pasting the number into a plain-text document and then copy/pasting from there to Contacts, and it still happened. So, just something to be aware of.


As an alternative. If you take the Shortcut example I posted in this thread as the basis, it is possible to create one or more sub-routine-esque Shortcuts to retrieve specific fields types.

Whilst perhaps slightly more effort to use for retrieval, it does remove the need for maintaining what is in effect duplicate data in every contact record, which could be a time saving in the long run and avoids situations where the additional duplication & transformation step may not have been carried out.

I’m not keeping duplicate data anywhere. I’m putting the less-often-used information in the URL field instead of putting them in their usual fields.

Ah okay - you’re ditching the standard entries for those data items and creating custom entries. As long as you don’t have need to share the contacts with others who aren’t using the same system, then I guess there’s no issues with the transition.

The url schemes are standard, so they should work fine for anyone.

Still, it’s a bit kludgy for me, though it’s probably the only real solution unless this has improved in iOS 13?

Yes, but to clarify my point, if you are not already using those custom contact fields and someone who is using them shared a contact with you, you would then have two potential locations within your contacts ‘database’ for various data items.

Also I’m pretty sure the alternative I suggested would count as “real” in terms of options :wink:

Does the linked number approach “play well” with the phone app? I assume it will show just fine as a field in the contact listing as normal, but if someone calls you, is the phone app smart enough to associate the number in the call log with the number in the link in the contacts additional field? Likewise for the messages app and received messages.

That’s a good question.

For caller ID… considering that Siri will recommend caller ID suggestions based on email, I would hope it would work, but I don’t know for sure.

In each case, the number that I moved to the URL scheme was a work or home number, and I kept the mobile number in the regular part of the Contacts database, so it will definitely work with Messages.

I stumbled on these post while researching a project to work with Shortcuts and Contacts. It helped me a lot to define what the obstacles were and also made it a challenge for myself as I cannot see the mailto: and tel:// solutions as usable even though they are nice things to know.
I like the labels for every entry in a contact. It is useful to categorise phone numbers as iPhone, mobile, home, work… Same with email addresses or addresses. Unfortunately, as mentioned, the action Get Details of Contacts is very limited in what it can provide. At the moment, it certainly does not return labels.
Solutions exist though.

You can iterate (action Repeat with Each) through the result of Get Details of Contacts to at least retrieve all phone numbers or all email addresses for example. You have lost the label information but you get all phone numbers. In the case of phone numbers, you also loose the country code if the number was stored as +xx AND it is a local phone number. This weird behaviour is seen at least on my phone.

There is a better solution with vCard format as suggested by sylumer. It is simple to generate the vCard as text (Base64 Encode to encode a given contact then Base64 Encode again but this time with decode option and finally converting the result to text with Set Name and choosing a name like “temp.txt”; no need to even output the result to file). But then it is a long process to extract what you want from the vCard text record.
Using the vCard, you can extract phone numbers, email addresses and addresses along with their labels.
For example, below is a partial vCard record inspired from my contact.
You can see that standard labels (to vCard 3.0 format) are there (type=WORK, type=HOME, type=CELL) and that non-standard ones are recorded on 2 itemN lines with ABLabel. Addresses are all non-standard. And the preferred (first in the list in Contacts) phone number, email address or address are tagged with type=pref.


EMAIL;type=INTERNET;type=WORK;type=pref:someone at something dot com
EMAIL;type=INTERNET;type=HOME:someone at somehome dot com
item1.EMAIL;type=INTERNET:someone at gmail dot com

TEL;type=IPHONE;type=CELL;type=VOICE;type=pref:+NN nnn nnnnnn
item2.TEL:+MM mmm mmmmmm
item2.X-ABLabel:mobile Moon
TEL;type=WORK;type=VOICE:00 pp p ppppppp

item3.ADR;type=WORK;type=pref:;;Street 1;State;;11111;Country
item4.ADR;type=HOME:;;Street 2;State;;22222;Country


After that, you just need tons of Match Text, Split Text, Text, Combine Text, Replace Text to rebuild phone numbers, email addresses and addresses. The good thing about it as well is that contrary to the previous half solution I gave, phone numbers do keep their +xx country codes.


1 Like

Another solution could be to create a fictitious contact in the address book, and edit/update it with the required data of phone numbers or e-mails.