Count # of related items in calculation field

Comments

14 comments

  • Hamid

    Hi Eelko,
    Test the _lenght parameter with any field of your items in client app like this :

    @all of any_field_in_client_app.length

    /Hamid

    2
    Comment actions Permalink
  • Eelko Huizing

    Hi Hamid,

    Many thanks for your response. The 'client' is incoming, so the relationship is set at the client-side, not the company side. It therefore seems that the field is not available in the @all.... any thoughts?

    0
    Comment actions Permalink
  • Hamid

    Add it in the app and then go to the seconde app and add a new calculation field pointing into the field in the first app !!!

    0
    Comment actions Permalink
  • Rainer Grabowski (FVM)

    Hi Eelko,

    when you type @all of ... fields of related apps are available, regardless of outgoing or incoming. But if the list is to long not all fields are shown, so type @all of fieldnameOFincomingApp. Then you should see it.

    1
    Comment actions Permalink
  • Eelko Huizing

    Great, that worked, many thanks!

    0
    Comment actions Permalink
  • Joshua Hay

    The .length method seems to have stopped working?

    0
    Comment actions Permalink
  • Rainer Grabowski

    No,works for me.

    0
    Comment actions Permalink
  • Joshua Hay

    I've tried three different ways and all return "0". I have an App called Campaign and an App called Leads - each lead is related to a campaign. The Leads App is in a different workspace than the Campaign App. This is on a campaign item that shows 151 leads as related items. Lead Name is a text field.

    Method 1;

    @All of Lead Name.length;

    Method 2;

    var leads = @All of Lead Name;
    leads.length;

    Method 3;

    var leads = @All of Lead Name.join();
    leads.length;

    0
    Comment actions Permalink
  • Rainer Grabowski

    Hi Joshua,

    is it possible that you have one relation from Campaign to Leads (= OUTGOING if you are in the Campaign App) and another relation from Leads to Campaign (=INCOMING)?

    If so, you've selected the wrong token (variable) from the list which opens after entering @ . Try this: Enter only @Name (or @all of lead name) and look if there are 2 tokens "All of Lead Name".
    Btw: Method 3 would count the number of the length of the string (number of characters) which was created by .join()

    Rainer

    0
    Comment actions Permalink
  • Joshua Hay

    Hi Rainer,

    Your response has helped me identify what the problem is. There isn't an outgoing connection, however there are 5 possible @All of Lead Name selections because the Leads App is part of an App Package that I've created to use in a separate workspace for each Campaign (and used 5 times in 5 separate workspaces so far). The Campaigns App is like the mother ship pulling in stats from the Leads Apps in the workspaces for each campaign.

    Does this mean... I have to redo the calc field individually for each new campaign item to connect it to the correct corresponding "spawn" of the Leads App?
    And if so, I'll have to figure out how the heck to identify the right one to connect to.

    0
    Comment actions Permalink
  • Rainer Grabowski

    Hi Joshua,

    for figuring out the right "Lead" you can temporarily rename the Lead-fields (Lead Name 1, Lead Name 2 ... ). Then in the calculation fields write after
    @all of lead name 1 // from App Leads in Workspace X
    Everthing behind // doesn't influence the calculation , it's used for comments/notes.

    After you've done that you can rename the field to it's original name.

    If one campaign is referenced only by one of the five Lead-Apps, there's no need for 5 calculation fields. It depends on what you want to display in this calculation field how the code has to look like to show only the result from the right app.

    If you can describe some more details, maybe I have a tip.

    Rainer

    1
    Comment actions Permalink
  • Diana Ricken

    I am desperate and hope somebody can help me...

    I simply want a calculation for a calendar event that displays the number of attending people.

    The recommendation I received from the Podio Support is to use

    var items = @Item
    @Item.length

    This works of course, but it's displaying anybody (total number of) who got invited to an event. Having read the posts in this topic I was hoping to be able to use something like

    var items = @ItemOFaccepted
    @Item.length

    But this returns a script reference error "field_tokenOFaccepted is not defined"

    Can I make this work at all? How?

    0
    Comment actions Permalink
  • Rainer Grabowski

    Hi Diana,

    it's not possible to get the number of "Accepted" in the calculation field.
    Btw. The error notification you get, cause the there's no variable token "itemOFAccepted" in the popup list. 

    Rainer

    0
    Comment actions Permalink
  • Benedict Stalder

    --SOLVED--

    I found this https://help.podio.com/hc/en-us/community/posts/201849698-Counting-number-of-related-apps and understood the "any field in the relation" and the  ".length" elements.

    my calculation now is "@All of Region Specific - Unique ID.length"

    -------------------

    Hi,

    Is there a simple way to fill a field with the number of related items ?

    Thank you. 


    0
    Comment actions Permalink

Please sign in to leave a comment.

Powered by Zendesk