You need to sign in to do that
Don't have an account?
sdetweil
how to determine user during before insert trigger.
I have a field in a custom objec that needs to be set before the data is put in the database.
I want some data (custom field) from the current users record to be copied into one of the fields.
but it needs to be changable later.. (so the field can't be defined as calculated)..
but trigger.new.createdby is not set in the before insert trigger..
how can I get access to this info? the UserInfo object doesn't give me access to the custom fields..
thx for any insight
I presume you can use the UserInfo.getUserId() method to retrieve the ID of the context user, then retrieve the custom fields through SOQL.
ID id = UserInfo.getUserId();
contextUser = [SELECT yourcustomobjects FROM User WHERE Id = :id];
yes, I suppose, but I was 'hoping' for a user 'object' that I could reference the fields from.. we added fields to the user record, and these are the ones I want to get access to..
thanks..
Sam