Post

3 followers Follow
0
Avatar

Using calculation field to show title of related item on same form.

The end goal is to run a report to show all the people that are listed as "owner" at a company, so that I can then send an email to all the company owners. 

We have a "Companies" app and a "People" app. On the companies, there is a relationship field titled "Owner" that pulls in from the "people" app. All pretty simple so far!

As far as I'm aware (having spoken to Podio tec support) it is not possible to run the report mentioned above. But if I can reproduce the owners name (displayed in the relationship field) in a calculation field (so that just below the relationship field with the owner it shows the owners name again) on the company item, then I will be able to create the needed report.

This seems a little convoluted but would solve the problem. I just can't work out how to show that name??? It seems very simple to reference a non-relationship field in a calculation field, surley this could be done for a relationship field?

Tim Miller

Please sign in to leave a comment.

11 comments

1
Avatar

Hi Tim,

You should be able to use a calculation field to @All of Field Name[0] to get the result you want. 

If you have any questions feel free to reach out to me at podio@dvi360.com, and we can set up a conference call to do a screenshare.

All the best!

Aaron Jake Biehl 1 vote
Comment actions Permalink
1
Avatar

Hello Tim,

It's: 
@all of name.toString()
where "name" is the label of the People App's field where the owner's name is in. Simply replace the word "name" in my code by the label of that field. 

Rainer

Rainer Grabowski 1 vote
Comment actions Permalink
1
Avatar

Rainer, 

That will cause problems if there are multiple items in the relationship field he's trying to pull from, and that will cause them to pull all of the names in with no spaces between them. This is why I typically recommend calling the first index of the array at [0] rather than the .tostring() or .join() 

Jake

Aaron Jake Biehl 1 vote
Comment actions Permalink
1
Avatar

Hey Jake,

First: apologize that I jumped in. But when I wrote my comment yours wasn't visible for me (happens sometimes here in the forum that comments are published days later). 
Second: In this case Tim wants exactly what's in the relationship field. So if there are 2 related items he needs both (maybe .join(", ") would return a better readable result than .toString() ). If there's always one related it doesn't matter if it's [0] or .toString()

Have a great weekend!

Rainer 

Rainer Grabowski 1 vote
Comment actions Permalink
0
Avatar

So... 

Do you have a solution for showing the persons email address in the same way? (as I have know realised that this is needed too). 

When I used the .toString() and .join(", ") it just brings up [object Object), and when I try @All of Field Name[0] it says The script returned and unsupported result type. 

Sorry to make it more complicated, but your help again would be much apricated. 

Many thanks, 

Tim Miller 0 votes
Comment actions Permalink
1
Avatar

Thank you Rainer, 

This isn't quite working. It brings up an error saying 

Invalid value "email@address.co.uk" (string): must be a number

In this instance, the dummy email address there is the actual email address that I'm wanting to show. So it is clearly finding the correct email address, but then not showing it due to this error. 

Do you know how I could remove this error and show the email?

Tim Miller 1 vote
Comment actions Permalink
1
Avatar

@Tim, calculation fields can be one of 3 "types" that get assigned when you first create the field. Those types are Number, Date, and Text. Given that your field was already assigned Number, you cannot put an email or any other text into that field. The solution is pretty simple, delete that calculation field and make a new one. 

Hope that helps!

Aaron Jake Biehl 1 vote
Comment actions Permalink
1
Avatar

Sometimes calculation fields can be  a bit "sensible".
Normally you can ignore that kind of error message, the result should be displayed in the item. But it seems your field wasn't saved before as a text type calc field (details about the types see here: https://help.podio.com/hc/en-us/articles/201019358-Calculations, paragraph above the video). 

Either enter under your calculation as last line in the field simply "X" (with quotation marks) and try to save it. When it saves, open the template and remove "X". If that doesn't work create a new field, enter @unique ID, save, come back, remove @unique ID and enter that calculation again (if the preview shows the error again, ignore it):

var email = @All of email;
email.map(function (obj) { return obj.value}).join()
Rainer Grabowski 1 vote
Comment actions Permalink
0
Avatar

Fantastic, thank you guys!!

Somehow this was happening every time, even when I put in a new calculation field. The trick with the "X" worked. 

Cheers, 

 

Tim Miller 0 votes
Comment actions Permalink