Calculated Field - MaxRelatedDate Function Issue

Hello All,

I have been trying for sometime to use the MaxRelatedDate to return the latest meeting that has been created within Meetings module.

In terms of relationship, Meetings are linked to my Opportunity module in 1-to-M relationship. So, within opportunity module, I am creating a calculated field which will count the days between latest meeting and today:

Calculated Field Formula = daysUntil(maxRelatedDate($meetings,"date_start"))

Not sure, what I am missing here. I have used different combinations like copying the Meeting Start Date into a different field within Meeting record itself and referring to that field in Opportunity calculated field.

But this maxRelatedDate function doesnt yield any result. 

Would be of much help, if someone could provide some work arounds or solves here.

Regards - AP

  • Have you added any additional Opportunity/Meeting relationships to your system, or are you just using the core relationship? If you've added a new relationship, the link name ("$meetings"), will be different, and could explain why the data is not being populated correctly. To get the correct link name, when in the formula builder part of Studio, click "Related", and it will show a list of all relationships, and you'll probably see two relationships for Meetings. If you select one, you'll get $meetings - and if you select the other, you'll get the other relationship link name. Use that link name instead of $meetings and your formula will likely work.

    Let's suppose that no new relationships have been added - I would suggest starting with a more basic field "last meeting", and make it just maxRelatedDate($meetings,"date_start"). I created that exact field, added to a layout, and can see it being populated correctly (I'm on a clean v10.1.0 system)

    Once you do have the formula working, there'll still be another challenge to solve for - the calculation of the days. SugarLogic only recalculates when a record is updated, so when you view the same record the following day, you won't see the number field incremented by 1 until you trigger a save (or select the record via ListView and hit "Recalculate SugarLogic"). This requires either manual effort, or some additional piece of automation/code to address. If you think that the product should do this out of the box, please vote up this Idea here:

  • There is also the likelihood that bug 77246 is at play here. Does that bug describe the issue you're seeing?

  • Thank you this helps - Copying the Meeting start date time field into a separate field ('meeting date' : a date type field created through studio) within Meeting and then using MaxRelatedDate function on 'meeting date' from Opportunity module.

    This is though strange that MaxRelatedDate cannot be applied directly on the meeting start date time field.

    Regards - AP

  • That does sound unusual - chaining functions together is pretty normal. I generally advocate breaking them down into fields to make it easier to both debug and reuse business logic - since fields which are hidden from layouts/reports are basically the closest thing we have to a "variable".