Is it at all possible to create a trigger, workflow rule, process builder, flow, etc that would automatically update a custom field on the User object when the "Freeze" button is clicked on the User's page? I have been down all of the avenues that I have listed above and have hit a wall each time. Since the isFrozen is located on the UserLogin object, I don't believe you can create a trigger that would populate the custom field. I wasn't able to create a formula field either since the isFrozen aspect is not on the User object. I am currently out of ideas at the moment. Any help would be much appreciated or a comment stating that this cannot be done at this point in time so I don't keep banging my head against a wall :) Thank you!
-
1Would a Scheduable class work? – NewbieDeveloper27 Jul 13 '15 at 21:51
As long as these updates don't have to be close to real time (meaning: immediate), I would suggest taking the path @NewbieDeveloper27 alluded to and set up Scheduled Apex that does the following and runs every night, or whatever interval you deem appropriate:
// Retrieve all UserLogin records with SOQL whose SystemModStamp is within the time range since the last run
// Use SOQL to retrieve all User records whose ID match UserLogin.UserID
// Update the custom field on User
One thing to be mindful of is Salesforce does not guarantee an exact execution time for Scheduled Apex; it can vary based on load. Therefore, it would be prudent to give the time range a little bit of a buffer to ensure no records are missed by the query.
-
is there anything that would perform this function immediately? – NewbieDeveloper27 Jul 13 '15 at 22:06