You need to sign in to do that
Don't have an account?
Populate Custom Task field with Custom User Field - Trigger Help for Newbie
I am very new to writing triggers. I've been reading the cookbook and scouring the community for similar newbie posts. I know this is a simple concept, but I'm unsure of how to proceed. Any guidance would be appreciated.
What I Want to Do: Populate a custom field on the Task object with a custom picklist value on the User object. (If a lookup to the user object was possible, this would solve all my problems!)
My Method: So far, this is what I've got. Pretty pathetic.
I created a class like this:
public class DetermineUserRegion { // This class should automatically set the Region field to the assigned user's region User currentUserRegion = [Select region__c From User Where User.Id = Task.OwnerId ]; Task.User_Region__c = currentUserRegion; }
And then I was going to call that from the trigger.
But, no success as of yet. Perhaps that isn't even the best method.
Any advice for a newbie?
You should just do this all in a trigger.
something like
trigger trgUserRegion on Task (before insert) {
String URegion = [select subject from USER where id = {!USER.ID} LIMIT 1].region;
System.debug('URegion : ' + URegion );
Ron929:
Thanks for your reply. I'll test it out!