Thank you for supporting the Cloud Customer Connect Community in 2024. It's a gift to work with you!

Look back
You're almost there! Please answer a few more questions for access to the Applications content. Complete registration
Interested in joining? Complete your registration by providing Areas of Interest here. Register

Workarounds for Using Formulas in Routines

in Sales 1 comment

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 }

Howdy, Stranger!

Log In

To view full details, sign in.

Register

Don't have an account? Click here to get started!