I wrote a trigger which attempts to grab the LastModifiedById
and populate it to another field. When I use trigger.NewMap
to get the LastModifiedById
, it
throws this error:
Error: Compile Error: Illegal assignment from Account to String
This is the line throwing the error:
String userIdString = trigger.newmap.get(acc.LastModifiedById);
Here's the complete trigger:
trigger Test on Account (after insert)
{
system.debug('test::'+trigger.new);
for (account acc:trigger.new)
{
account dd = new account(id=acc.id);
String userIdString = trigger.newmap.get(acc.LastModifiedById);
dd.Last_Modified_By_End_User__c =userIdString.substring(0, 15);
update dd;
}
}
Why am I getting this error? How can I fix it?