You need to sign in to do that
Don't have an account?
Synthia Beauvais
Incompatible element type Schema.SObjectField for collection of Id
- Work Order is created from the Account Object
- When work order is saved, LookUp Field: Primary_Sales_Rep_Name__c should populate with the name from field Primary_Sales_Rep_Name__c from the Account Object
- Getting Error on Line 5: Incompatible element type Schema.SObjectField for collection of Id
trigger UpdatePSR on WorkOrder (before insert, before update){ Set<id> accIds = new Set<id>(); for(WorkOrder Account: trigger.new){ if(WorkOrder.Primary_Sales_Rep_Name__c!= null){ accIds.add(WorkOrder.Primary_Sales_Rep_Name__c); } } if(accIds.size() > 0){ Map<Id,Account> mapOfAccounts = new Map<Id,Account>([Select Primary_Sales_Rep_Name__c from Account where id in :accIds]); if(mapOfAccounts.containsKey(Account.Primary_Sales_Rep_Name__c)){ Account.Primary_Sales_Rep_Name__c = mapOfAccounts.get(Account.Primary_Sales_Rep_Name__c).Primary_Sales_Rep_Name__c; } } }Thanks in advance!
Updated your code.
Let me know if you need any help.
Thanks,
Naval
I am getting Compile Error: Variable does not exist: Account.WORecord at line 13 column 28
Please update line 13 to following line.
Here is my latest update. I renamed the field to Primary_Sales_Rep_2__c on the Work Order Object. I am getting a new error.
Compile Error: Invalid field WORecord for SObject WorkOrder at line 11 column 36
Try this again.
Can you try this again.
Primary_Sales_Rep_Name__c from account to Primary_Sales_Rep_2__c on work order
There is a name in the field.