You need to sign in to do that
Don't have an account?
venkat bojja
Employee Object Department is need to update with User Object Department PickList value
Hi Team,
I have a requirement.
On User Object I have one Department Picklist field and same field on Employe Object. But there is no relation, when ever the User is created with pertecular Department PickList Value is need to be updated in Employee object Department field.
What are the best possibilities to achieve this requiment. Please share me some helpful information.
Thanks in advance....
Thanks
Venkat.
I have a requirement.
On User Object I have one Department Picklist field and same field on Employe Object. But there is no relation, when ever the User is created with pertecular Department PickList Value is need to be updated in Employee object Department field.
What are the best possibilities to achieve this requiment. Please share me some helpful information.
Thanks in advance....
Thanks
Venkat.
Do you have any common field in both User and Employee Object?
If you don't have any common field, you can create one externalId field in both objects, then you can create trigger after update on User.
So you can retrieve Employee Object records based on external Id of User(Which you are updating),then update user department picklist value with Employee Object department picklist value.
If you want I will help you with the code as well.
If it is helpful mark it as Best Answer.
Thanks&Regards
Divya.
You can create one externalId field in both User and Employee and try below code.
Or else if you have any common field in both objects use that field.
trigger UserTrigger on User(after update){
UserTriggerHelper helper = new UserTriggerHelper();
helper.updateEmployee(trigger.new);
}
public class UserTriggerHelper(){
public void updateEmployee(List<User> listUsers){
List<Employee__c> emps = new List<Employee__c>();
for(List<User> usr: listUsers){
Employee__c emp= new Employee__c();
emp.externalId__c = usr.externalId__c;
emp.department __c=usr.department __c;
emps.add(emp);
}//end for
update emps;
}//endmethod updateEmployee()
}//end class.
If it is helpful mark it as Best Answer.
Thanks&Regards
Divya.