Post

5 followers Follow
0
Avatar

Script returned "unsupported data type" when calling @All of xxx

Hello
I'm trying to do a calculation that references a text field from a related app using @All of xxx, I get the message "Script returned unsupported data type" - what am I doing wrong? I have successfully retrieved related data with @All of xxx in other apps.

Mike Adams

Please sign in to leave a comment.

11 comments

0
Avatar

Hi Mike,
- Have you tried to delete your calculation filed and add a new one then call the text_field
- Have you test your template on an existing item (open item, on front left click on modify template)

Hamid 0 votes
Comment actions Permalink
0
Avatar

Hi Mike,

if you could post your script it would be much easier to help. Without it, we will just be guessing to what's going wrong.

When posting your code, please use triple back-ticks to mark them as code-blocks. That way it does not get mangled into unreadability. See Zendesk's help page on formatting code blocks

Best,
Stefan

dieKollaborateure.com - Podio Training+Consulting+Developmentauch auf Deutsch

Stefan Ukena 0 votes
Comment actions Permalink
0
Avatar

Hi Hamid - tried both those things without success

Hi Stefan - Here is my script:
@All of Account Name

(Complicated eh?)
The error message is "The script returned an unsupported result type"
I'm in a Contacts App that has a relationship app called Accounts. Account Name is a text field in Accounts.
I've tried:
- deleting the calculation field
- doing a simple calculation with a local text field to make sure that the field is a text type
- modifying template from an item that definitely has data

The weird thing is that I've done this calculation lots of times in other apps without problem

Mike Adams 0 votes
Comment actions Permalink
0
Avatar

Hi Mike,
the trick with this is to add "" at the end like this :


@All of Account Name + ""


Hamid 0 votes
Comment actions Permalink
0
Avatar

Hi Hamid
I tried adding + " " after @All of Account Name and still o result, the calculation refuses to retrieve data from the related app {BTW I dont see why adding + " " would work but I'm willing to tnry anything]

Mike Adams 0 votes
Comment actions Permalink
2
Avatar

Hi Mike,

the @All of xxx in Podio are of the JavaScript type Array. However, Podio is not able to handle an array as the result of a calculation, thus your error message. You need to convert the array to something that Podio can handle, like a String. One way to do this is to use the .join() method like so:

@All of xxx.join()

This will concatenate all elements of the array using a comma. If there's only one element in the array, it will simply output that as a String.

Best,
Stefan

P.S.: Adding +"" at the end will initiate JavaScript's implicit type conversion, in this case to a string. That sometimes actually does help.

Stefan Ukena 2 votes
Comment actions Permalink
0
Avatar

Hi Mike, do you still get the same error notification ""Script returned unsupported data type"?

@All of Account name.join()

should work. Check, if there can items be found with

@All of Account name[0]

If not, delete your calculation field, delete the relationship field, close the template and make a page refresh. Than create a new relationship, save, create a new calculation field and try again.

Rainer

Rainer Grabowski 0 votes
Comment actions Permalink
0
Avatar

Hi Rainer,
Your suggestion works - but not in all cases and I'm not sure why

My calculation is: @All of Account Name.join() + " - " + @First Name + " " + @Last Name

Adding the .join() solved the problem partially. In some cases it retrieves the Account Name and in other cases it retrieves blank and I can't see why.

My App is called customer contacts and in all cases there is a related Account item (an Account App item).

What I notice is that all items have a relationship field Account set but for the items that correctly display the Account Name in the calculation, if I scroll to the bottom of the item it also shows the Account item as a related item in the information section. But for the items that return blank for Account Name, if I scroll to the bottom there is no related item shown for Account (even though it does show correctly in the Account field.

Not sure if I'm making sense. I could send some screenshots but I don't know how to do that in this chat format

Mike Adams 0 votes
Comment actions Permalink
0
Avatar

Hi Mike, you've found the solution yourselt: If an account item isn't related to the item where the calculation should run, the account name can't be displayed.

Or do you have a relationship field from Custom Contacts to Account and a second relationship field in Accounts to Customer? Then you would have in customers outgoing relations and incoming relations. And for each relation you have different tokens in the list when you type @all of ... first the incoming are listed, then the outgoing. YOu have to take care to get the right token.

Rainer

Rainer Grabowski 0 votes
Comment actions Permalink
0
Avatar

Hi Rainer,

Indeed, I did have a customer contacts relationship field in Accounts and an Accounts relationship field in Customer Contacts. The calculation was only picking up the cases where I had assigned contacts to Accounts n the Accounts App, whereas every contact has an Account. So there was both incoming and outgoing relationships for the calculation to find.

I've deleted the Customer Contacts in Accounts relationship so that the account relation can only be set within customer contacts. Podio still shows the related contacts when you open an account item.

Is there a situation where double referencing (ingoing and outgoing) is useful or desirable?

Regards

Mike

Mike Adams 0 votes
Comment actions Permalink
0
Avatar

Hi Mike,

I always try to avoid double referencing for several reasons. One is, that you have to consider incoming and outgoing relations for the the same calculation. For some use cases it could be necessary to relate an app to itself, than there is a double referencing. In which app you set the relation to another app really depends on your workflow.

What do you mean by this:

Podio still shows the related contacts when you open an account item.

In which place are the realted contacts shown? What exactly did you delete in Accounts?

Rainer

Rainer Grabowski (FVM) 0 votes
Comment actions Permalink