You need to sign in to do that
Don't have an account?
montez
List has more than 1 row for assignment to SObject - Error on Process Builder
I have this class I am using to assign leads via process builder. When the class tries to run in bulk, I get the following error:
Any thoughts on how to resolve this error?
Here is the class I an using to assign leads:
Error Occurred: An Apex error occurred: System.QueryException: List has more than 1 row for assignment to SObject
Any thoughts on how to resolve this error?
Here is the class I an using to assign leads:
public class AssignLeadsUsingAssignmentRules { @InvocableMethod public static void LeadAssign(List<Id> LeadIds) { Database.DMLOptions dmo = new Database.DMLOptions(); dmo.assignmentRuleHeader.useDefaultRule= true; Lead Leads=[select id from lead where lead.id in :LeadIds]; Leads.setOptions(dmo); update Leads; } }
Please try the following code:
All Answers
Please try the following code:
Updated your code :
I hope this will work for you.
Regards,
Naval
Please find the below code:
Here I considered:
(1) Naming Convention
(2) Always its better to send Set of Ids as it will not maintain duplicate ids and it duplicates are not required here.
(3) Corrected the logic to not to get exception.
Please do let me know if it helps you.
Regards,
Mahesh