0

I'd like to create Scheduled Apex to run overnight. The requirement is to remove sensitive information from a Contact if they have finished attending any courses they are booked onto (i.e. the Course__c.End_Date__c of any course is in the past). Courses is a custom object and has a lookup relationship to the contact. The Contact is likely to have multiple course records that would need to be checked for end date. No field information should be removed if any courses are yet to be taken/finished.

e.g. Make Contact.Field1__c = Null, Contact.Field2__c = Null, Contact.Field3__c = Null when Course__c.End_Date__c (for all the related Course records) < TODAY

If anyone can help that would be fantastic!

1 Answer 1

0

Directly speaking, you can't do this without some "help." Assuming Course has a Master-Detail relationship with Contact, you can create a rollup summary field on Contact to find "MAX End_Date__c" on the Course object. From there, your process builder should be able to trigger on that new field with a scheduled action.

2
  • many thanks for your answer. Unfortunately it's not a master-detail relationship, but you have given me a prompt to go in a different direction :)
    – user64500
    Commented Feb 10, 2019 at 17:31
  • I have a slight workaround now, but it is doing what I want. I've now got a Process/Flow that updates a field on Contact with the latest Course end date. I've also created some scheduled Apex that updates another field by +1 every night to automatically trigger the Process.
    – user64500
    Commented Feb 10, 2019 at 18:33

You must log in to answer this question.