Workarounds for Using Formulas in Routines
We are attempting to setup routines based on the last activity date with a customer. Since rollups are not usable within the routines section, we created a date formula to query the last activity date, the issue with this is that formulas are not usable within Routines as they are not searchable. Are there any possible workarounds or approaches we could implement/utilize to be able to use this latest activity date in routines?
Groovy Script for reference:
def accountId = PartyId
def activityVO = newView('Activity') addBindVariable(activityVO, 'AccountId') // Create a new View Criteria to filter activities by AccountId def vc = newViewCriteria(activityVO, 'AccountId = :AccountId') setBindVariable(activityVO, 'AccountId', accountId) activityVO.appendViewCriteria(vc) activityVO.executeQuery() def latestActivityDate = null // Iterate through the activities and find the latest activity date while (activityVO.hasNext()) { def activityRow = activityVO.next() def activityDate = activityRow.getAttribute('ActivityEndDate') if (latestActivityDate == null || activityDate > latestActivityDate) { latestActivityDate = activityDate } } if (latestActivityDate != null) { return latestActivityDate } else { return null }
0