Question: "JavaScript to count contacts in app"

Comments

6 comments

  • James Hayward

    Don't know if this helps but this little calc has helped me out heaps. basically places a count meter in the items. which we can then sum up in reports..

    var foo = Teams; 1;
    // only needed because otherwise Podio will not let us save the template

    -1
    Comment actions Permalink
  • OP

    Hi James, I appreciate it.

    I'm not yet able to find the way to make it work, but I'll keep trying.

    Ideally I would be able to put a calculation field beneath the contact field in the item, which would just give a value of x. I have found some info on how to get some counts (below is for space members) if I would go through their API, but at the moment its out of my depth in programming.

    @see https://developers.podio.com/doc/contacts/get-space-contacts-22414 */ public static function get_for_space($space_id, $attributes = array()) { return self::listing(Podio::get("/contact/space/{$space_id}/", $attributes));

    So I'm guessing the information is there somewhere but getting to it my problem. :(

    best,
    Oli

    0
    Comment actions Permalink
  • Michael Kagan

    Hey OP, did you ever solve this issue?

    0
    Comment actions Permalink
  • Morten Siebuhr

    Hi OP,

    If you want to count the number of related items, pick any of the "[ ] All of X" for the desired relation. (That will return a list of X for all the related items). Type ".length" after that to get the length of the list.

    The entire script should end up like "@All of Title.length" and return a number.

    For contact-fields, picking the field returns a list of the contact's names and adding ".length" will usually return the desired result. So something like "@Contacts.length" in the end.

    3
    Comment actions Permalink
  • Steve Weeks

    Really useful tip, thank you.

    I'm sure I've done this too. but @All of Field.length keeps returning zero for me. 

    Frustrated.

    I wonder what I'm doing wrong. Also tried @All of Field.length + 0 

    etc. 

    0
    Comment actions Permalink
  • Rainer Grabowski

    Hi Steve,

    2 possible reasons for the 0:
    1. There's no item related :)
    2. Check if there are an incoming AND an outgoing relation to the same app. And then check if you've selected the right field token.

    Rainer

     

    0
    Comment actions Permalink

Please sign in to leave a comment.

Powered by Zendesk