I'm trying nothing more than to update a lookup field when I create a new record. The field it should pull the value from is a lookup.
I have this code:
List <Job__c> opListInsert = new List<Job__c>();
List <Job__c> opListUpdate = new List<Job__c>();
if(trigger.isInsert){
for(Job__c op:trigger.New){
if(op.Acct__c != Null){
op.Account__c = op.Acct__c;
opListInsert.add(op); }
}
}
else if(trigger.isUpdate){
for(Job__c op:trigger.New){
if(op.Acct__c != Null && op.Acct__c !=trigger.oldMap.get(op.id).Acct__c){
op.Account__c = op.Acct__c;
opListUpdate.add(op);
}
}
}
But it's throwing the following error:
Error:Apex trigger UpdateAccounts caused an unexpected exception, contact your administrator: UpdateAccounts: execution of BeforeUpdate caused by: System.StringException: Invalid id: accountname : Trigger.UpdateAccounts: line 20, column 1
Anyone know how I can convert the account to string or vice versa?
Thanks.