• Karthik Mohan 6
  • NEWBIE
  • 0 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 4
    Replies
I wrote a apex code which is triggerd when a particular filed in updated above a certain value. When i manually edit that field the code works fine. But the code had to be excute whenever the value is updated, it shouldnt wait until manual edit. The apex helps in assigning a account to particular queue.
the apex code is as follows : 
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;
   }
}


Error message :  Error element myWaitEvent_myWait_myRule_1_event_0_SA1 (FlowActionCall).
An Apex error occurred: System.QueryException: List has more than 1 row for assignment to SObject


Can someone help me with this?. Thanks in advance.
I wrote a apex code which is triggerd when a particular filed in updated above a certain value. When i manually edit that field the code works fine. But the code had to be excute whenever the value is updated, it shouldnt wait until manual edit. The apex helps in assigning a account to particular queue.
the apex code is as follows : 
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;
   }
}


Error message :  Error element myWaitEvent_myWait_myRule_1_event_0_SA1 (FlowActionCall).
An Apex error occurred: System.QueryException: List has more than 1 row for assignment to SObject


Can someone help me with this?. Thanks in advance.