Next date after Yesterday

Answered

Comments

5 comments

  • Rainer Grabowski

    Hi Nelson,

    I'm not sure if I understand your question right and what exactly you want to achieve.
    You've the contact history app which is related via a relationship field to Contacts.
    In Contact history you've a date field "next contact"
    What exactly should be shown in the calculation field? Number of days between next contact date and today? Or another date?

    0
    Comment actions Permalink
  • Nelson Oliveira

    HI Rainer,

    Many thanks for your answer.

    In app CONTACTS we add all contacts we have schedule with customer.

    In app CRM i have a field that returns with @max of date of contact

    This works if a customer has only a single acount.

    We have some customers that has 2 acounts.

    Imagine customer A has the account person 1 and acount person 2

    Person 1 schedule a metting to october 15th
    Person 2 schedule a meeting to october 7th

    The way i have now, on my filter (max date of contact)

    What i need is, no matter the number of meetings scheduled, i need to know when and who have to make the next contact.

    Is it more or less clear now?

    I'm sorry, but it's difficult to explain all in english

    0
    Comment actions Permalink
  • Rainer Grabowski

    So CONTACTS is related to CRM via a relationship field "Customer" in CONTACTS? Is there an App for Persons too?

    0
    Comment actions Permalink
  • Nelson Oliveira

    Yes, you are correct

    0
    Comment actions Permalink
  • Rainer Grabowski

    First you've to collect all dates which are > yesterday. But that's not really possible in Podio calculation fields cause you can't get a value "today". You can use the function moment() = it fetches the date and time when a variable has been changed in the calculation. Everytime a new CONTACTS-item is added to a CRM-Item the value of momen() is changed to the time when the Contact-item is added. The calculation below does the following:
    1. Look in CONTACTS for all items with a date >= momen() (i.e. >= the date the last item has been added).
    2. Create a list of all found items.
    3. sort this list and put the date with the lowest value at the top of the list ( cause it's the next date)
    4. Look in CONTACTS for the item with exactly this date, pull the date and time value and display it as a date (so it can be shown in calendars)

    var nd = @All of Next Date;
    var dateList= [];
    for(var i = 0; i < nd.length; i++){
    if(moment(nd[i]).format("YYYYMMDD") >= moment().format("YYYYMMDD")){
    dateList.push(moment(nd[i]).format("YYYYMMDD"));
    }};
    var getNext = dateList.sort().join().split(",")[0]
    
    var next1 = "";
    for(var i = 0; i < nd.length; i++){
    if(moment(nd[i]).format("YYYYMMDD") == getNext){
    next1 += nd[i];
    }};
    moment(next1).toDate() 
    

    You can create a second calculation field to show the name of the person who should be contacted. For that you have to change the last part of the code a bit (first part stays the same):

    var person = @all of field with person's name    
    var person1 = "";
    for(var i = 0; i < nd.length; i++){
    if(moment(nd[i]).format("YYYYMMDD") == getNext){
    person1 += person[i];
    }};
    person1
    

    If you've a category field (or another indicator) in CONTACTS which indicates that this contact happened, you could use it as a filter, so that old "next dates" for CRM-items aren't displayed (e.g. for CRM A you had scheduled the lst contact for Sep. 9th. In the calculated Next Date for CRM A this date will stay till you add the next contact-item. If you have a "done"-indicator you can enhance the code "Display not, if done").

    If your Contact-items have a time entry it could happen that the time in calculated Next date in CRM is displayed wrong. This depends on the difference of your time zone and the Podio server time. If so, you've to subtract or add the difference (depends on your time zone).

    Rainer
    rg@delos-consulting.com

    0
    Comment actions Permalink

Please sign in to leave a comment.

Powered by Zendesk