Counting related items from another app with a specific date range

Comments

8 comments

  • Rainer Grabowski

    Hello Conor,

    if there is no order in the last 30 days the for loop doesn't create a var dates30 (cause of the IF). Try to call the var dates in the last line. You also should make date[i] a moment() (also there's a superfluous semicolon at the end if the IF line).

    var date = @All of Date Sample Received;
    var dates30 = 0;
    for(var i = 0; i < date.length; i++){
    if(moment(date[i]) >= moment().subtract(30,'d')){
    dates30 += 1;
    }
    };
    dates30

    BUT: Your calculation won't work correctly cause of the "today" value you build wiht moment(). It shows the right result the moment you save it. But if you have e.g. one order which is today exactly 30 days old you get a result = 1 when saving and it should show 0 tomorrow. But it will still show 1. More info about working with a "today" value you find in my comment here https://help.podio.com/hc/en-us/community/posts/115000113951-Trying-return-a-number-on-subtracting-today-s-date-from-a-given-date-in-a-field-?page=1#community_comment_115000105451
    and in this post https://help.podio.com/hc/en-us/community/posts/204569657-Definite-solution-for-today-handling-in-calculated-fields-days-since-days-until-countdown-incl-possible-solution

    Rainer 

    0
    Comment actions Permalink
  • Conor O'Donoghue

    Thanks Rainer for the suggested edits to the code.  When I paste your suggested code in directly, I get an error.  Did you mean to suggest "dates30" in the last line?

     

    I appreciate the links to your threads about the "timer" app.  I have implemented this, but before setting up the daily update in GlobiFlow I wanted to confirm the following:

    Is this going to lead to every single items (in this case hundreds of customers) getting updated daily, and all associated updates getting published to the activity feed, both within an item and the workspace activity feed?  We rely heavily on the activity feed to keep the team well aligned day-to-day, so if these daily updates were to show up it would be very chaotic.  Can you confirm?  Switching off updates to the activity feed completely is not really an option for us, but it would be great to avoid this update showing up everywhere, daily.

     

     

     

    0
    Comment actions Permalink
  • Rainer Grabowski

    Hi Connor,

    sorry, yes, should be "dates30" in the last line.

    Timer app: If you set it up correctly the daily update shouldn't be shown in any activity feed (except in the Timer item cause that's the only item which is updated daily by Globiflow; in that app you should select the first 3 options in app settings/advanced.). Only when the relationship to the Timer app is set the first time automatically by Globiflow an activity is displayed (e.g. in the items in the customer app).

    My setup (which I implemented for all of my about 50 Podio clients): I normally connect two apps to the Timer app (means: They have a relationship field where the timer item is connected): A Team/Members/Employee app and a Contacts app - cause these 2 are normally connected to many other  apps (maybe in your setup a Projects app or whatever is a central app). In both apps I've a hidden calculation field "Today's date" which pulls the date from the Timer app with @max of date field in timer app. Then all other connected apps have access to the current date - and also also all other apps which aren't connected directly to Team or Contact but to an app which is connected to them. Only if needed (means: if an app isn't  related with Contacts or Team directly or indirectly) I connect other apps directly to the Timer app. 

    Rainer

     


    0
    Comment actions Permalink
  • Conor O'Donoghue

    Thanks Rainer - super helpful. 

    One last question to close the loop on this - and possibly a naive question at that.  I'm struggling to get my 'flow' to update the date. After exploring different flows I landed on the one below, but it's failing to trigger. Do you have any suggestions?

    0
    Comment actions Permalink
  • Rainer Grabowski

    Hello Conor,

    don't use that kind of flow ("Triggered by an items date field"), use a By Date or Day flow (at the top of the workspace tree - see screenshots).

     

    Btw: The flow shown in your screenshot is configured correctly. It the date in the field "Today" is today's date (28.02.2019) then it should be updated shortly after midnight to 01.03.2019. 

    Rainer

    0
    Comment actions Permalink
  • Conor O'Donoghue

    Hi Rainer - 

     

    Just closing out the loop on this:

    • I have the calculations working
    • I have the date app updating with GlobiFlow (thank you!)
    • Every time a new customer is created in another app, I want to link it to the date app.  I created the following GlobiFlow flow, but it appears not to be working after letting it run for a few days:

    Any thoughts on how to resolve?

    Best,

    Conor

     

     

    0
    Comment actions Permalink
  • Rainer Grabowski

    Hi Conor,

    what your flow does at the moment is updating the (empty) field Link to Date App with itself.
    In the Update This Clinic action click "Value" and select App Item ID, then fill in the needed data (select app = Date App, App Item ID = unique id of the item where the current date is in. The unique id you can see when you open the item - it's the number at the end of the item url). 
    That should work.

    Rainer 

    0
    Comment actions Permalink
  • Operations Team

    I know I'm 3 years late, but this is great! If I want to calculate for the current month, how would the formula change?

    0
    Comment actions Permalink

Please sign in to leave a comment.

Powered by Zendesk