Report on next birthdays in 30 days

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • chrismc
    Member
    • Jun 2019
    • 47

    Report on next birthdays in 30 days

    Hi, first of: I love Espo! its such a clean design and I can customize such a lot of things with only view technically know-how.

    My question:
    - for each contact we have configured a birtday date field ("contactBirthday")
    - we want to generate reports about the upcoming birthdays (we have the Advanved Pack)
    - my idea: have a field with the date of the next upcoming birthday for a contact ("contactBirthdayNextdate", hidden from user interface)
    - what is the best way to regularly recalculate those upcoming birthdays? Is it a process, workflow, calculated field? I want it to be scheduled recalculation

    Any other ideas how to implement this?

    Thanks
    Christoph

  • eymen.elkum
    Member
    • Aug 2019
    • 41

    #2
    this can be done in several ways, but I prefer to make it from the Contact.json entityDefs

    just add a new field entry for 'contactBirthdayNextdate' and mar
    "fields" : {
    "contactBirthdayNextdate": {
    "type": "date",
    "notStorable": true,
    "select": "DATE_ADD(contacts.contactBirthday, INTERVAL 1 YEAR)"
    }
    }
    please note I not tested this, but think it must work

    Comment

    • chrismc
      Member
      • Jun 2019
      • 47

      #3
      Thanks! I will try it out, just one question: how can this work is e.g. someone is born 12. December 1980 and INTERVAL 1 YEAR will add one year its 1981? What I want is 12. December 2019 as the next upcoming birthday.

      Comment

      • yuri
        Member
        • Mar 2014
        • 8440

        #4
        Hi Christoph,

        You can create a scheduled workflow with Update Target Record action with formula:

        Code:
        $bd = entity\attribute('contactBirthday');
        $today = datetime\today();
        $diffY = datetime\diff($today, $bd, 'years');
        $nextBd = datetime\addYears($bd, $diffY + 1);
        entity\setAttribute('contactBirthdayNextdate', $nextBd);
        If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

        Comment

        • chrismc
          Member
          • Jun 2019
          • 47

          #5
          Amazing, thank you very much! Works perfect!

          Comment

          • chrismc
            Member
            • Jun 2019
            • 47

            #6
            Just for the archive if someone searches for it:
            To also include todays birthdays I added:
            $today = datetime\addDays($today, -1);

            Comment

            Working...