You need to sign in to do that
Don't have an account?
Brooks Bruce 47
How to account for the possibility that a Hiring Manager for a Position could change?
I've got a trigger which calls a method in a class designed so that the Hiring Manager (lookup field on Position) automatically follows their Positions in Chatter:
Class:
public class SubscriptionsClass {
public static void HiringManagerSubscribeNewPosition(List <Position__c> positions) {
System.Debug('HiringManagerSubscribeNewPosition: Entering');
List <EntitySubscription> subscriptions = new List <EntitySubscription>();
for (Position__c pos :positions) {
EntitySubscription eSubs = new EntitySubscription(parentid = pos.id, subscriberid = pos.Hiring_Manager__c);
subscriptions.add(eSubs);
Database.insert(subscriptions);
}
}
Trigger:
trigger PositionTrigger on Position__c (after insert) {
SubscriptionsClass.HiringManagerSubscribeNewPosition(Trigger.new);
}
Works great but I can't figure out how to account for the possibility that a Hiring Manager for a Position could change; any ideas? Thanks for any help and advice.
Class:
public class SubscriptionsClass {
public static void HiringManagerSubscribeNewPosition(List <Position__c> positions) {
System.Debug('HiringManagerSubscribeNewPosition: Entering');
List <EntitySubscription> subscriptions = new List <EntitySubscription>();
for (Position__c pos :positions) {
EntitySubscription eSubs = new EntitySubscription(parentid = pos.id, subscriberid = pos.Hiring_Manager__c);
subscriptions.add(eSubs);
Database.insert(subscriptions);
}
}
Trigger:
trigger PositionTrigger on Position__c (after insert) {
SubscriptionsClass.HiringManagerSubscribeNewPosition(Trigger.new);
}
Works great but I can't figure out how to account for the possibility that a Hiring Manager for a Position could change; any ideas? Thanks for any help and advice.
You need to write the trigger for the update as well. Assuming that one position will have one hiring manger please find the code below. If there can be multiple you can create the map as id versus list of subscriptions.
Thanks
Anupama
All Answers
You need to write the trigger for the update as well. Assuming that one position will have one hiring manger please find the code below. If there can be multiple you can create the map as id versus list of subscriptions.
Thanks
Anupama