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

Previous Owner Field update
I'm still learning apex so I wanted to see if this was even possible.
I have a user look up field on the lead that I want filled in automatically with the previous owner when the lead owner is changed.
Thoughts?
Thanks everyone!
here's the code if anyone was interested:
All Answers
Yes you can do it with A trigger on lead. Before update trigger on lead.
Here is your trigger
MyLookupField__C change this with your lookup field api name
I'm receiving this error
Error: Apex trigger PrevLeadOwner caused an unexpected exception, contact your administrator: PrevLeadOwner: data changed by trigger for field Previous Lead Owner: id value of incorrect type: 00G800000021t6SEAQ
When I changed lead from my name to the queue it worked correctly but when I try to remove it out of a queue I received the error. Any suggestions?
Thanks,
Can you please explain your error more, as Shashikant's trigger is absolutely fine.
Thanks
Ankit Arora
Blog | Facebook | Blog Page
I received the error when the previous owner was a Queue because it was trying to inser the queue id into a user id field. I have this working now; thanks for the jumping off poing.
here's the code if anyone was interested:
Gr8 You Sorted it Out,
And Thanks for sharing your solution.
Thanks for sharing this.
Thanks
Ankit Arora
Blog | Facebook | Blog Page
Hi JJJenkins,
I have the same kind of requirement for opportunity. I tried this code but only issue is that I get only previous owner id not the name in my previous owner field(PreviousOwner__c). Do you also get the id only in field which is being populated.
If you are getting name, then why in my case it is happening that I am getting id. Any pointers.
Hope for a quick reply!