• Jayesh Deo 2
  • NEWBIE
  • 45 Points
  • Member since 2023

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 8
    Questions
  • 9
    Replies
I tried many times but I am getting below error after updating the recruiter record.Please help.
**recruiter record and Hiring Manager records are having exact same fields**

Error:
SyncRecruiterRecords: execution of AfterUpdate caused by: System.DmlException: Update failed. First exception on row 0; first error: MISSING_ARGUMENT, Id not specified in an update call: [] Class.RecruiterRecordsSyncHandler.AfterUpdate: line 36, column 1 Trigger.SyncRecruiterRecords: line 6, column 1
---------------------------------------------------------------------------------------------
  • Hiring_Manager__c =Parent Object
  • Recruiter__c= Child Object (Lookup relation)
---------------------------------------------------------------------------------------------
Trigger=Recruiter Object

trigger SyncRecruiterRecords on Recruiter__c (After update) 
{
      if(trigger.isAfter && trigger.IsUpdate)
        {
    
        RecruiterRecordsSyncHandler.Afterupdate(trigger.New);
            
        }
}
---------------------------------------------------------------------------------------------
Trigger Handler Class:

public class RecruiterRecordsSyncHandler 
{
   
    Public static void AfterUpdate(List< Recruiter__C> lstrecs)
    {
        
        If (!lstrecs.isEmpty())
        {
            List <ID>HrIds= new List<ID>();
            for(recruiter__c  rec: lstrecs)
            {
                
                HrIds.add(rec.Hiring_manager__c);
            }
            Map<id, Hiring_Manager__C> mapHrs = new Map<ID,Hiring_MAnager__C>([select id, name,
                                 location__C, email__c,Phone__C from Hiring_Manager__C
                                         where id in : hrIds]);
            
            if(!MapHrs.isEmpty())
            {
                List<Hiring_manager__C> lstHRS= new list <Hiring_manager__C>();
                
                for(recruiter__c rec:lstrecs)
                {
                    Hiring_Manager__c hr=new Hiring_Manager__c();
                    hr.Name=rec.name;
                    hr.Phone__c=rec.phone__C;
                    hr.Email__c=rec.Email__c;
                    hr.location__c=rec.location__c;
                    
                    lstHRS.add(hr);
                    
                }
                if(!lsthrs.isEmpty())
                {
                    update lsthrs;
                }
            }
        }
    }
    
}
Hiring_Manager__c =Parent Object
Recruiter__c= Child Object (Lookup relation)

I am trying to automatically update parent record fields when child record gets updated by using After Update trigger but I got below error in SOQL query. 

  List <Hiring_Manager__C> GetHiringManagersList=[select id,name, Location__c, Phone__C, Email__c from Hiring_manager__C
                                                           where recruiter__r.id    IN:lstrecs.keyset()];

ERROR=Didn't understand relationship 'recruiter__r' in field path. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. 

I am using Map collection here. Which will be best suitable type of collection (List/MAp)in such scenarios?

 
Hiring_Manager__c =Parent Object
Recruiter__cm = Child Object (Lookup relation)

I am trying to collect hiring manager ID  from recruiter object as shown in below query.

 Public Static Void AfterUpdate(Map<ID, Hiring_manager__c> MapHrRecords)
    { 
        List <Recruiter__c> LstRecruiters=[select id, name , location__c, Email__c, Phone__c, HiringManagerid__c 
                                           from recruiter__c 
                                                  where HiringManagerid__c IN:MapHrRecords.keySet() ];
        
    }

ERROR encountered:
No such column 'HiringManagerid__c' on entity 'Recruiter__c'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names.

 
If (trigger.isAfter && trigger.isUpdate)
    {
        //Get the related contact updated based on updated account details.
        List<Contact> lstcontact=[Select id, firstName, LastName, Fax, Phone, MailingCity, Mailingstate, MailingCountry,MailingPostalcode,MailingStreet
                                                 From Contact
                                                  Where Accountid in:Trigger.newMap.KeySet()];
        
        for(contact con:lstcontact)
        {
            Account acc= Trigger.newMap.get(con.AccountId);
            con.Phone=acc.Phone;
            con.fax=acc.Fax;
            con.MailingCity=acc.BillingCity;
            con.MailingStreet=acc.BillingStreet;
            con.MailingPostalCode=acc.BillingPostalCode;
            con.MailingCountry=acc.BillingCountry;
            
            
        }
        update lstcontact;
        
    }
From the below code I can insert hiring manager record and positions records seperately but cannot able to insert related section hiring manager records and related section candidate records. I am learning Apex. Please Help!

public static void HiringManagerInsertrec()
{
 Hiring_Manager__c hrmo=new Hiring_Manager__c();
    hrmo.Name='rajees shubhamq';
    hrmo.Email__c='ja@tzoq.com';
    hrmo.location__c='Mumbai'; 
    id hrID=hrmo.id;
    
    insert hrmo;
    
    list<position__c> pos=new list <position__c>();
  
    for (integer counter=1; counter<10; counter++)
    {
          position__c posObj=new position__c();
        posObj.Name='HR subedar1';
        posObj.Hiring_Manager__c=hrID;
        pos.Add(posobj);
        
    }  

    if(!pos.Isempty())
    {
      insert pos;  
    }
    
    list <Candidate__c> can=new list <Candidate__c>();
    
     for (integer counter=1; counter<=2; counter++)
     {
       Candidate__c cc=new Candidate__c();
         cc.name='rahul2 pawarq';
        
     }
    IF(!CAN.IsEmpty())
    {
        insert can;
    }
    
    
    system.debug('number of DML used:'+limits.getDmlStatements());
    system.debug('Number of record processed:'+limits.getDmlRows());
    system.debug('number of max limigt dml statements:'+limits.getLimitDmlStatements());
   
   
}
}
 
I am getting mentioned error while adding related 10 case records to account record. Please help.


account acc=new account();
acc.name='cognizant';
insert acc;

ID accID=acc.ID;

list <contact> con=new list <contact>();
for(integer counter=1;counter<=5; counter++)
{
    contact cont= new contact();
    cont.lastname='plumber'+counter;
    cont.email='bulky'+counter+'@gmail.com';
    cont.AccountId=accID;
    con.add(cont);
}
insert con;

list <case> caselist=new list <case> ();

for(integer counter=1; counter<=10; counter++)
{
    case cd=new case();
    cd.status='working';
    cd.SuppliedPhone='counter'+counter;
    cd.AccountId=accID;
    cd.add(caselist);
    
}
insert caselist;
 
Write an apex program, to insert an Account Record, and 5 Related Contacts, and 4 Related Opportunities, and 2 Related Case records inside the object.
Account record(1)
|
|_______contact records(5)
|
|_______Opportunity records(4)
|
|________Case records(2)
I tried many times but I am getting below error after updating the recruiter record.Please help.
**recruiter record and Hiring Manager records are having exact same fields**

Error:
SyncRecruiterRecords: execution of AfterUpdate caused by: System.DmlException: Update failed. First exception on row 0; first error: MISSING_ARGUMENT, Id not specified in an update call: [] Class.RecruiterRecordsSyncHandler.AfterUpdate: line 36, column 1 Trigger.SyncRecruiterRecords: line 6, column 1
---------------------------------------------------------------------------------------------
  • Hiring_Manager__c =Parent Object
  • Recruiter__c= Child Object (Lookup relation)
---------------------------------------------------------------------------------------------
Trigger=Recruiter Object

trigger SyncRecruiterRecords on Recruiter__c (After update) 
{
      if(trigger.isAfter && trigger.IsUpdate)
        {
    
        RecruiterRecordsSyncHandler.Afterupdate(trigger.New);
            
        }
}
---------------------------------------------------------------------------------------------
Trigger Handler Class:

public class RecruiterRecordsSyncHandler 
{
   
    Public static void AfterUpdate(List< Recruiter__C> lstrecs)
    {
        
        If (!lstrecs.isEmpty())
        {
            List <ID>HrIds= new List<ID>();
            for(recruiter__c  rec: lstrecs)
            {
                
                HrIds.add(rec.Hiring_manager__c);
            }
            Map<id, Hiring_Manager__C> mapHrs = new Map<ID,Hiring_MAnager__C>([select id, name,
                                 location__C, email__c,Phone__C from Hiring_Manager__C
                                         where id in : hrIds]);
            
            if(!MapHrs.isEmpty())
            {
                List<Hiring_manager__C> lstHRS= new list <Hiring_manager__C>();
                
                for(recruiter__c rec:lstrecs)
                {
                    Hiring_Manager__c hr=new Hiring_Manager__c();
                    hr.Name=rec.name;
                    hr.Phone__c=rec.phone__C;
                    hr.Email__c=rec.Email__c;
                    hr.location__c=rec.location__c;
                    
                    lstHRS.add(hr);
                    
                }
                if(!lsthrs.isEmpty())
                {
                    update lsthrs;
                }
            }
        }
    }
    
}
Hiring_Manager__c =Parent Object
Recruiter__cm = Child Object (Lookup relation)

I am trying to collect hiring manager ID  from recruiter object as shown in below query.

 Public Static Void AfterUpdate(Map<ID, Hiring_manager__c> MapHrRecords)
    { 
        List <Recruiter__c> LstRecruiters=[select id, name , location__c, Email__c, Phone__c, HiringManagerid__c 
                                           from recruiter__c 
                                                  where HiringManagerid__c IN:MapHrRecords.keySet() ];
        
    }

ERROR encountered:
No such column 'HiringManagerid__c' on entity 'Recruiter__c'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names.

 
From the below code I can insert hiring manager record and positions records seperately but cannot able to insert related section hiring manager records and related section candidate records. I am learning Apex. Please Help!

public static void HiringManagerInsertrec()
{
 Hiring_Manager__c hrmo=new Hiring_Manager__c();
    hrmo.Name='rajees shubhamq';
    hrmo.Email__c='ja@tzoq.com';
    hrmo.location__c='Mumbai'; 
    id hrID=hrmo.id;
    
    insert hrmo;
    
    list<position__c> pos=new list <position__c>();
  
    for (integer counter=1; counter<10; counter++)
    {
          position__c posObj=new position__c();
        posObj.Name='HR subedar1';
        posObj.Hiring_Manager__c=hrID;
        pos.Add(posobj);
        
    }  

    if(!pos.Isempty())
    {
      insert pos;  
    }
    
    list <Candidate__c> can=new list <Candidate__c>();
    
     for (integer counter=1; counter<=2; counter++)
     {
       Candidate__c cc=new Candidate__c();
         cc.name='rahul2 pawarq';
        
     }
    IF(!CAN.IsEmpty())
    {
        insert can;
    }
    
    
    system.debug('number of DML used:'+limits.getDmlStatements());
    system.debug('Number of record processed:'+limits.getDmlRows());
    system.debug('number of max limigt dml statements:'+limits.getLimitDmlStatements());
   
   
}
}
 
I am getting mentioned error while adding related 10 case records to account record. Please help.


account acc=new account();
acc.name='cognizant';
insert acc;

ID accID=acc.ID;

list <contact> con=new list <contact>();
for(integer counter=1;counter<=5; counter++)
{
    contact cont= new contact();
    cont.lastname='plumber'+counter;
    cont.email='bulky'+counter+'@gmail.com';
    cont.AccountId=accID;
    con.add(cont);
}
insert con;

list <case> caselist=new list <case> ();

for(integer counter=1; counter<=10; counter++)
{
    case cd=new case();
    cd.status='working';
    cd.SuppliedPhone='counter'+counter;
    cd.AccountId=accID;
    cd.add(caselist);
    
}
insert caselist;
 
Write an apex program, to insert an Account Record, and 5 Related Contacts, and 4 Related Opportunities, and 2 Related Case records inside the object.
Account record(1)
|
|_______contact records(5)
|
|_______Opportunity records(4)
|
|________Case records(2)