Post

17 followers Follow
1
Avatar

New email and phone fields

Has anyone managed to do a calculation with the new email and phone fields?
@Email or @Phone return unsupported result type
@Email.join() just gives [object Object],[object Object]

I've been using @All of Phone to display contact phone numbers in other related apps

Mike Adams

Please sign in to leave a comment.

37 comments

5
Avatar

Hi Mike,

var a = @E-MailField; 
a.map(function (obj) { return obj.value}).join() // shows all E-Mails in this field

If you want to get e.g. only the work E-Mail:

var a = @E-MailField; 
var b = a.filter(function (obj) { return obj.type === 'work'}); 
b.map(function (obj) { return obj.value}).join()

you could do is also in one line:

 @E-MailField.filter(function (obj) { return obj.type === 'work'}).map(function (obj) { return obj.value}).join()

If there are several work-addresses and you want only the first one: [0] instead of .join()

E-Mail-types are: "other|home|work" , Phone types are: "mobile|work|home|main|work_fax|private|fax|other" ( for available types s. -> Modify App -> Developer, and there under " Sample JSON value")

Rainer
rg@delos-consulting.com

Rainer Grabowski 5 votes
0
Avatar

I'm trying to get this to work for mine, but it is still displaying [object object] :(

Couldn't they make something simple? I'm not a Javascript guru and neither is anyone else in this nonforprofit org :(

@First Name + " " + @Last Name + " - " + @Phone + " - " + @Role + @Phone.filter(function (obj) { return obj.value}).join()

Brock Taffe 0 votes
0
Avatar

Thanks, Rainer, for the fantastic calculations.

When I replaced .join() with [0], I get "Syntax script error: Unexpected token ["
var a = @Email;
a.map(function (obj) { return obj.value}).[0]

What am I doing wrong?

Heather Fox 0 votes
0
Avatar

Hi Heather,

remove the dot in front of [

a.map(function (obj) { return obj.value})[0]
Rainer Grabowski 0 votes
0
Avatar

Hi Brock,

your code is not correct.Instead of
@Phone.filter(function (obj) { return obj.value}).join()
it has to be
@Phone.map(function (obj) { return obj.value}).join()

Rainer

Rainer Grabowski 0 votes
0
Avatar

Hi
I'm now trying to retrieve email addresses from a related app using code like this:

var a = @All of Email;
a.map(function (obj) { return obj.value}).join()

The error message I get is "Preview: Invalid Value "name@emailaddress.com" (string): must be a number

I have configured the calculation field to be a string by first doing @Textfield and saving. So why is it expecting a number?

Mike Adams 0 votes
1
Avatar

Hi Mike,

If you can't save, maybe you can try to outwit Podio, to "persuade" it to accept the calculation:

a.map(function (obj) { return obj.value}).join() || 0

if that doesn't work try

a.map(function (obj) { return obj.value}).join() || "A"

Rainer

Rainer Grabowski 1 vote
0
Avatar

How about if I get it from a multiple relationship field? I tried the code and it worked but I am having problem with who owns the which email.

i.e. I have John Doe with 2 emails and Jane Smith with just 1 email. How can I group each email by owner as I can't seem to use the index?

Tikboy 0 votes
1
Avatar

Hi Michael,

easiest way: Create in the app where the items with Name/E-Mail-Addresses are (e.g. "Contacts") an additional calculation field (call it e.g. "Name/Mail"):

@name + ": \n" + @E-mail-field.map(function (obj) { return obj.value}).join("\n")

Result for John Doe would be:
John Doe:
john@email1.com
doe@email2. com

for Jane Smith:
Jane Smith:
jane@smith.com

In the other app where you want to collect them:

@all of Name/Mail.join("\n\n")

Result would be:
John Doe:
john@email1.com
doe@email2. com

Jane Smith:
jane@smith.com

Rainer

Rainer Grabowski 1 vote
0
Avatar

What about if you wanted to show the mobile phone, if available, but if field mobile = "" then show the work phone, then show other if necessary?

The idea is to only show one phone number in the calculation field. Mobile would be most desirable, but if that's not available, then work, then other as 3rd option.

James Bowie 0 votes
2
Avatar

Hi James,

This will show you the first available number.

var a = @Phone Number.map(function (obj) { return obj.value}).join();
a[0];

If you want more control in which order the number types should be checked:

var a = @Phone Number; 

var mobile = a.filter(function (obj) { return obj.type === 'mobile'}); 
var mobile = mobile.map(function (obj) { return obj.value}).join();

var work = a.filter(function (obj) { return obj.type === 'work'}); 
var work = work.map(function (obj) { return obj.value}).join();

var home = a.filter(function (obj) { return obj.type === 'home'}); 
var home = home.map(function (obj) { return obj.value}).join();

var anyNumber = a.map(function (obj) { return obj.value});

mobile != "" ? "Mobile: " + mobile : work != "" ? "Work: " + work : home != "" ? "Home: " + home : anyNumber != "" ? "Other: " + anyNumber[0] : "No Phone Number"

Rainer
rg@delos-consulting.com

Rainer Grabowski 2 votes
0
Avatar

Thank you, Rainer. The first solution is fine as I'm just trying to grab one number / email address for the calculation.

For some reason when I input the code below, it only returns the first digit of the first number, instead of the whole first number. Did I possibly copy it wrong? I double checked it by creating a new calculation and copying the code directly and referencing the variable.

var a = @Phone Number.map(function (obj) { return obj.value}).join();
a[0];

James Bowie 0 votes
1
Avatar

Sorry, my mistake, have copied the wrong line.
Just delete .join(). This is the correct code:

var a = @Phone Number.map(function (obj) { return obj.value});
a[0];

Rainer

Rainer Grabowski 1 vote
0
Avatar

Hi everyone,

Within an app I want to have a calculation field displaying : @text-field1 + " - " + @text-field2 + " - " + @Phone.map(function(obj){return obj.value}).join()
But if there is no phone number written in the Phone-Field, the calcuation fields show nothing in stead of : @text-field1 + " - " + @text-field2 + " - " + null.
Does anyone knows how I can resolve this?

Regards,

Nicolas

Nicolas Roegiers 0 votes
1
Avatar

Hi Nicolas,

you've to "tell" the calcultion what should happen if the phone field is empty by defining an IF-Condition:

 var phone = @Phone
 var phone1 = phone != null ? phone.map(function(obj){return obj.value}).join() : "";
 var phoneTXT = phone1 != "" ? " - " +  phone1 : ""; 
 @text-field1 + " - " + @text-field2 + phoneTXT

Rainer

Rainer Grabowski 1 vote
0
Avatar

Thanks Rainer for directing me to this highly useful response. I have not yet got my head around every aspect of the alternatives for managing contacts, but I think one of the benefits of the "discrete app" option will be for me that I can import from Excel when I want to refresh the names and addresses from another database which is the primary source.

These javascript mini-solutions are a really essential part of the Podio. Your support is part of bridging the gap between bespoke web databases and programmers who are competent - in the wrong languages :-)

Steve Weeks 0 votes
0
Avatar

I'm hitting a new problem. My Item represents an event with 16 different duties. So I have 16 Relationship fields, all pointing to my "Contacts Database" - which is an "App" called "People". In a calculation field I have started writing the javascript to return a list of the email addresses of these 16 selected people. Of course Podio does not allow me to type in the data names, they must be selected from the pull-down list triggered by typing "@". 

Here's the problem, the pull down-list only goes as far as the first seven "<Relationship Name> (Outgoing)" and then stops. the other half of the email fields are not presented for selection. 

Can anyone suggest a brilliant way around this limitation?  I won't be offended if I'm told to get Globiflow. Because I'm helping charities with no money, I do just try the free option first.

Thanks :-)

Steve Weeks 0 votes
0
Avatar

Hi Steve,

I agree - 8 available tokens are too less. But there's a workaround, a bit cumbersome but it works.

You can create the reference youself. Just for explanation: The hidden reference address behind a token looks like this 
out_102260730_121373937

  • "out" = outgoing relation ("in" would be for an incoming)
  • first number is the field-id of the referenced field (in your case: the E-Mail-field)
  • second number is the field-id of the relationship field (each of your 16 relationship fields have different field-ids)

Btw: You make the hidden address visible be entering any character directly behind a (blue) token: enter @all of example, select the token and enter X (so that it looks like @all of exampleX) - that would show the address in an error notification. 

In your case, the field-id of the referenced E-Mail-field is always the same. To get the numbers of the relationship fields open the App view of your app, click the wrench and select "Developer". There you see all your fields and also their field-ids. Copy the whole table and paste it into a spreadsheet (not necessary but helpful). 

Now you can create your direct reference addresses:
@[](out_referenced field-id_relationship field-id) 
like
@[All of example field](out_102260730_121373937).join()

In the square brackets you can enter what you like,but this is shown as the name of the token. F.ex. you can enter: 
All of E-Mail-field name (then it would look like a "normal" token for this reference) or
All of E-Mail-field name for relationship field name (so you see for which relationship field the reference is).

I would recommend to pick the references (tokens) for the visible relationship fields from the pull-down list and add the other references manually. Enter one time
 @[All of E-Mail field](out_referenced field-id_relationship field-id).join() 
Copy it and just change the relationship field-id (copy it from the spreadsheet). 

This is also a great help if you have to create many calculation fields in one app and need always the same @token in it. Instead of always typing @field name you can create once this address and copy it.

Hope it helps,
Rainer
rg@delos-consulting.com

 

 

Rainer Grabowski 0 votes
0
Avatar

Rainer, that is fantastic. The great mountain of corporate gratefulness is another metre higher.
I now foresee a happy day or two of copying and pasting field_IDs, and a working app ..soon.
Thank you again.

Steve Weeks 0 votes
0
Avatar

This Is Excellent, ..being an old Excel programmer, I was able to copy and paste the developer info tabulation into Excel and generate the many lines of javascript using Excel formulae. I'm so delighted with your assistance, I'm generating working code in a language I don't really know.. Thank you especially for taking the time and making the effort to describe and lay out your solution in accurate English. So often programmers know the answer but cannot communicate it. Well done again, Rainer.

Steve Weeks 0 votes
1
Avatar

Hi Steve, 

"So often programmers know the answer but cannot communicate it. Well done again, Rainer." :-) Thanks.

May it's cause I'm not a programmer, but a consultant (and former journalist), who knows Podio very well (using it for 4 years, Authorized Podio Partner since 1.5 years)

Rainer

Rainer Grabowski 1 vote
0
Avatar

Hello everybody,

My question might need to be posted elsewhere but I have hopes with you guys after reading all your helpful comments on this post.

Are there any updates on custom labels (types) for the phone field? For example, when researching telephone numbers, it would be great to have phone labels (types) such as verified, unverified, and invalid. 
Maybe, is it possible to change the description of "Mobile" to something like "Verified"?

 

Basically, I can't find an answer to Dan Farrow's question in 2015  "Custom label for phone field
Being able to choose custom labels for phone fields would be pretty good here. Work, home, mobile etc. are great, but we're finding we need to be able to customise them more. i.e. HQ, Nottingham Branch, and other such things."

Thanks guys

 

Jarrett Anderson Smith 0 votes
0
Avatar

Just me getting: "Syntax error Unexpected identifier" using @Rainer's simple solution?

var a = @Mobilnummer Number.map(function (obj) { return obj.value});
a[0];

Thinking the Object structure might have changed...

Edit:
Oh, and "@Mobilnummer" is my Phone field.

Stefan Falkboman 0 votes
0
Avatar

Hi Stefan,

I assume the field name is "Mobilnummer" , not "Mobilnummer Number". So it must be 

var a = @Mobilnummer.map(function (obj) { return obj.value});
a[0];

or

var a = @Mobilnummer;
a != null a.map(function (obj) { return obj.value})[0] : "";

If it doesn't work please share a screenshot of your calculation field.

Rainer

Rainer Grabowski 0 votes
0
Avatar

🤪 That was it! 😅
I though your "Number" was a JSON-selector or something in the array.

BIG thanks Rainer!

My full code below. The last row (off topic) is to generate a QR-version of the number so we don't have to dial each number we call manually (iPhone Camera natively supports QR so its swipe-scan-call). Love Podio.

var a = @Mobilnummer.map(function (obj) { return obj.value});
number = a[0];
"![](https://chart.googleapis.com/chart?cht=qr&chl=tel:"+number+"&chs=180x180&choe=UTF-8)"

 

Stefan Falkboman 0 votes
0
Avatar

Does this calculation still work? I have tried Rainer's solution:

var a = @All of email;

a.map(function (obj) { return obj.value}.join()

But it returns "Preview: 0" also after I save the calculation and do a refresh.

What am I doing wrong?

Thanks for any help!

Robin

Robin Bertus 0 votes