You need to sign in to do that
Don't have an account?

Update a field on user object
Hi
I have requirement that we need to update a field on user object from custom object .Here we dunable to create lookup field to custom object from user object .
for example
we have Qulification field in custom object and also there in User object
I want to update the Qulification field value on user object
Please share your code if you have
Thanks
I have requirement that we need to update a field on user object from custom object .Here we dunable to create lookup field to custom object from user object .
for example
we have Qulification field in custom object and also there in User object
I want to update the Qulification field value on user object
Please share your code if you have
Thanks
You can write a trigger and then using below code you can update the saem..
All Answers
What is the relation between custom object and user object ?
Hi sandeep,
Thanks for reply
I have took the lookup relationship from custom object to user
You can write a trigger and then using below code you can update the saem..
{
list<user> lstUsersToUpdate = new list<user>();
for(Department__c obj : trigger.new)
{
user objuser = new user(Id = obj.User__c) ;
objuser.Qualification__c= obj.Qualification__c;
lstUsersToUpdate.add(obj);
}
if(!lstUsersToUpdate.isEmpty())
update lstUsersToUpdate;
}
I am getting this type of error
Incompatible element type Department__c for collection of User
lstUsersToUpdate.add(obj);
in this you should add user object not department__C
lstUsersToUpdate.add(objuser); use this as its a user type list..
Thanks
Department__c )
Iam getting following error
Error: Invalid Data.
Review all error messages below to correct your data.
Apex trigger Populatetrigger caused an unexpected exception, contact your administrator: Populatetrigger: execution of AfterInsert caused by: System.DmlException: Update failed. First exception on row 0; first error: MISSING_ARGUMENT, Id not specified in an update call: []: Trigger.Populatetrigger: line 13, column 1
I have given id
Now its working!!
Thanks
sandeep