[✅ Solution] Get Mobile Number from an Item's Phone Field

I’m not sure if this is a bug or not (probably not), but if it isn’t, I guess I’m asking what is the best way to handle this situation.

I am trying to get an item’s mobile number using the “iterable” token which contains all of the phone numbers. I’m successfully using .find() to search through the objects to get the one where “type” = “mobile” and then use .value to get the value.

I can get it to work, but I have to check “Continue on error” in the brick configuration in order for it to work. Otherwise it gives an error of undefined as shown in this screenshot here: https://paste.pics/PW9PC

Is the need to check “Continue on error” necessary? Or is it a bug? Is there a better way for me to do what I’m trying to do? Thanks!

Hi @andrew.cranston

does this do what you need:

var var_mobile = collected_contact_field_phone_iterable
  .filter(obj => obj.type === 'mobile')
  .map(obj => obj.value)[0] || '';

modification of:


This worked beautifully!! Thank you so much for your help! Coming from Globiflow and primarily a PHP environment, I’m still finding my way through the right Javascript to do certain jobs so thank you for your insight!


Pleased it worked :slight_smile: especially as I now see an extra var that somehow crept in.


I just wanted to leave another note here for the annals of history. Of course the above works just fine, but as another possibility, here’s how you could find the value using JSONata.


This just seems like a more elegant solution, using less code and making it more readable. I’m LOVING JSONata and trying to learn more about it every day!