I wrote the following trigger and I'm getting the error :
Illegal assignment from Schema.SObjectField to String
But I don't know how to fix it. I wrote a similar trigger before and didn't have any issues.
trigger AccountDuplicates on Account (before insert, before update) {
for (Account myaccount : Trigger.new) {
List <Account> dupes = [SELECT Name FROM Account WHERE Name = :(myaccount.Name)];
if (dupes.size() > 0) {
myaccount.Duplicate_Account__c = Account.name;
}
}
}
The purpose of the trigger - when a new account is created that matches the name of an existing account, put the existing account's name into the "Duplicate Account" field.