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

How to get $User.Department in Apex class
HI,
I want to get the information from $User.Department and assign it to a variable in the Apex class.
However, I don't know how to do this. Basically I want to get the user department object info and then
prefill the custom object field Department__c. Please help.
thanks
Paul
String dept = u.Department;
That will get the department.
Then in your custom object:
Cust_obj_c obj = new Cust_obj_c(Department__c = dept); // plus any other fields here
insert obj;
hope this helps !!
Thanks so much. it worked.
Paul