• ABC XYZ 39
  • NEWBIE
  • 120 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 24
    Questions
  • 29
    Replies
On edit page of the clone record, I see all field values from the original record. But when the record is saved, few of the populated values for specific custom fields (not all) are blank on the cloned record. 
What is happening? How to resolve this...Pls help. Thanks.
Hi, 
Basic Logic:
 Create Contact Scenario - 
 Conditions - Last Name should not be same as Account Name, Contact type is Customer
  Everytime a new contact is created meeting the above conditions, it is written to Queue object
   In this case, Description would be 'New Contact' (to be written into Queue object)
   
 Update Contact Scenario -
 2 scenarios here -   
  1) In addition to abouve conditions being valid, if custom field PID is missing and any of the 
    fields in Contact record are updated, push the record to Queue object.
    In this case, Description would be 'PID Missing'
    
  2)  In addition to above conditions - Last Nane not same as Account Name, Contact type being 'Customer'
     type,  if custom fields A, B, C or D are changed on the existing record, push the record to 
       Queue object.
      In this case, Description would be 'Updated Contact' 
  
Behavior Observed Now :
Whenever a  new contact  is created, 2 copies of the same record are inserted into the Queue object. This I am assuming is happening because 'after insert' and 'after update' triggers aer firing for every new contact created. 

Insert Scenario(New Contact Creation) - Update scenario triggered - 'MDM Id Missing' message observed; Record inserted into Queue object twice
Update Scenario (PID null and record updated) - Working as expected - 'MDM Id Missing' message written into Queue object
Update scenario ( A,B,C or D field values change) - Update Scenario triggerd - 'Update contact' message written into Queue object



I don't understand why this is happening. There are no workflows impacting the behavior . It has to do with logic in the class below or the way I am invoking the trigger. 
Controller Class and Trigger Invocation are below.

I am trying to fix this code for sometime without any luck. I need to fix it as soon as possible. I am new to programming and can't figure out how to make this functionality work. I have posted the same queury for  past couple of days. I will greatly appreciate if you could help identify and fix this issue..Thanks.









// Controller Class with processContact method

public class ContactController {

public  void processContact(Map<Id, Contact> newContactMap, Map<Id, Contact> oldContactMap)
{
       List<Queue__c> lstQ = new List<Queue__c>();   
         Id idContactCustomerRecType;
         Map<Id, String> mapIdToAccountName = new Map<Id, String>();
       
           List<RecordType> lstRecType = new List<RecordType>([SELECT Id FROM RecordType WHERE Name = 'Customer' AND SobjectType = 'Contact']);
          
      if(!lstRecType.isEmpty())
     idContactCustomerRecType = lstRecType[0].Id;
       
        if(idContactCustomerRecType != null)
         {
         // we can't fetch parent fields directly, so collecting account Ids first
           for(Contact objContact : newContactMap.values())
              {
                  if(objContact.AccountId != null)
                mapIdToAccountName.put(objContact.AccountId, null);
              }
          }
 
         // iterate over account with matching collected Ids and fetch names
          for(Account objAccount : [SELECT Id, Name FROM Account WHERE Id IN : mapIdToAccountName.keySet()])
          {
           mapIdToAccountName.put(objAccount.Id, objAccount.Name);
           }
  
         // loop again to perform business logic
        for(Contact objContact : newContactMap.values())
        {
             /* 1. If Contact RecordType is Customer AND if LastName != Account.Name, insert Queue **/
            if( objContact.RecordTypeId == idContactCustomerRecType
               && objContact.AccountId != null   && objContact.LastName != mapIdToAccountName.get(objContact.AccountId)
             {
             if(Trigger.isUpdate)
             {
                 if(label.Unauthorized_User!=objContact.lastmodifiedbyid)
                 {
                    if(objContact.A__c!= oldContactMap.get(objContact.Id).A__c
                        || objContact.B__c!= oldContactMap.get(objContact.Id).B__c
                        || objContact.D__c!= oldContactMap.get(objContact.Id).D__c)
                  {
                  
                   objQ.Description__c= 'Updated Contact';
                   objQ.Record_Id__c = objContact.Id;
                   objQ.Notification_Timestamp__c= objContact.CreatedDate;
                   lstQ.add(objQ);
                   }
                   
                   else if(objContact.PID__c == null)
                   {
                   objQ.Description__c= 'PID Missing';
                   objQ.Record_Id__c = objContact.Id;
                   objQ.Notification_Timestamp__c= objContact.CreatedDate;
                   lstQ.add(objQ);
                   
                   }
                   
                 }
             }
             
               if(Trigger.isInsert)
               {
                 objQ.Description__c= 'New Contact';
                   objQ.Record_Id__c = objContact.Id;
                   objQ.Notification_Timestamp__c= objContact.CreatedDate;
                   lstQ.add(objQ);
                   
               }
             }

            
                   
                
       }

       if(!lstQ.isEmpty())
       insert lstQ;
             
    }
     
    
     
}


Trigger Invocation :

Contact - After Insert 

if(Trigger.isInsert && Trigger.isAfter){
   ContactController.processContact(Trigger.newMap, Trigger.oldMap);
   }

Contact - After Update 

 if(Trigger.isUpdate && Trigger.isAfter){
        ContactController.processContact(Trigger.newMap, Trigger.oldMap);
    } 
Hi, 
Basic Logic:
 Create Contact Scenario - 
 Conditions - Last Name should not be same as Account Name, Contact type is Customer
  Everytime a new contact is created meeting the above conditions, it is written to Queue object
   In this case, Description would be 'New Contact' (to be written into Queue object)
   
 Update Contact Scenario -
 2 scenarios here -   
  1) In addition to abouve conditions being valid, if custom field PID is missing and any of the 
    fields in Contact record are updated, push the record to Queue object.
    In this case, Description would be 'PID Missing'
    
  2)  In addition to above conditions - Last Nane not same as Account Name, Contact type being 'Customer'
     type,  if custom fields A, B, C or D are changed on the existing record, push the record to 
       Queue object.
      In this case, Description would be 'Updated Contact' 
  
Behavior Observed Now :
Whenever a  new contact  is created, 2 copies of the same record are inserted into the Queue object. This I am assuming is happening because 'after insert' and 'after update' triggers aer firing for every new contact created. 

Insert Scenario(New Contact Creation) - Update scenario triggered - 'MDM Id Missing' message observed; Record inserted into Queue object twice
Update Scenario (PID null and record updated) - Working as expected - 'MDM Id Missing' message written into Queue object
Update scenario ( A,B,C or D field values change) - Update Scenario triggerd - 'Update contact' message written into Queue object



I don't understand why this is happening. There are no workflows impacting the behavior . It has to do with logic in the class below or the way I am invoking the trigger. 
Controller Class and Trigger Invocation are below.

I am trying to fix this code for sometime without any luck. I need to fix it as soon as possible. I am new to programming and can't figure out how to make this functionality work.
Please help. Thanks.









// Controller Class with processContact method

public class ContactController {

public  void processContact(Map<Id, Contact> newContactMap, Map<Id, Contact> oldContactMap)
{
       List<Queue__c> lstQ = new List<Queue__c>();   
         Id idContactCustomerRecType;
         Map<Id, String> mapIdToAccountName = new Map<Id, String>();
       
           List<RecordType> lstRecType = new List<RecordType>([SELECT Id FROM RecordType WHERE Name = 'Customer' AND SobjectType = 'Contact']);
          
      if(!lstRecType.isEmpty())
     idContactCustomerRecType = lstRecType[0].Id;
       
        if(idContactCustomerRecType != null)
         {
         // we can't fetch parent fields directly, so collecting account Ids first
           for(Contact objContact : newContactMap.values())
              {
                  if(objContact.AccountId != null)
                mapIdToAccountName.put(objContact.AccountId, null);
              }
          }
 
         // iterate over account with matching collected Ids and fetch names
          for(Account objAccount : [SELECT Id, Name FROM Account WHERE Id IN : mapIdToAccountName.keySet()])
          {
           mapIdToAccountName.put(objAccount.Id, objAccount.Name);
           }
  
         // loop again to perform business logic
        for(Contact objContact : newContactMap.values())
        {
             /* 1. If Contact RecordType is Customer AND if LastName != Account.Name, insert Queue **/
            if( objContact.RecordTypeId == idContactCustomerRecType
               && objContact.AccountId != null   && objContact.LastName != mapIdToAccountName.get(objContact.AccountId)
             {
             if(Trigger.isUpdate)
             {
                 if(label.Unauthorized_User!=objContact.lastmodifiedbyid)
                 {
                    if(objContact.A__c!= oldContactMap.get(objContact.Id).A__c
                        || objContact.B__c!= oldContactMap.get(objContact.Id).B__c
                        || objContact.D__c!= oldContactMap.get(objContact.Id).D__c)
                  {
                  
                   objQ.Description__c= 'Updated Contact';
                   objQ.Record_Id__c = objContact.Id;
                   objQ.Notification_Timestamp__c= objContact.CreatedDate;
                   lstQ.add(objQ);
                   }
                   
                   else if(objContact.PID__c == null)
                   {
                   objQ.Description__c= 'PID Missing';
                   objQ.Record_Id__c = objContact.Id;
                   objQ.Notification_Timestamp__c= objContact.CreatedDate;
                   lstQ.add(objQ);
                   
                   }
                   
                 }
             }
             
               if(Trigger.isInsert)
               {
                 objQ.Description__c= 'New Contact';
                   objQ.Record_Id__c = objContact.Id;
                   objQ.Notification_Timestamp__c= objContact.CreatedDate;
                   lstQ.add(objQ);
                   
               }
             }

            
                   
                
       }

       if(!lstQ.isEmpty())
       insert lstQ;
             
    }
     
    
     
}


Trigger Invocation :

Contact - After Insert 

if(Trigger.isInsert && Trigger.isAfter){
   ContactController.processContact(Trigger.newMap, Trigger.oldMap);
   }

Contact - After Update 

 if(Trigger.isUpdate && Trigger.isAfter){
        ContactController.processContact(Trigger.newMap, Trigger.oldMap);
    } 
June 3, 2016
Hi, 
Basic Logic:
 Create Contact Scenario - 
 Conditions - Last Name should not be same as Account Name, Contact type is Customer
  Everytime a new contact is created meeting the above conditions, it is written to Queue object
   In this case, Description would be 'New Contact' (to be written into Queue object)
   
 Update Contact Scenario -
 2 scenarios here -   
  1) In addition to abouve conditions being valid, if custom field PID is missing and any of the 
    fields in Contact record are updated, push the record to Queue object.
    In this case, Description would be 'PID Missing'
    
  2)  In addition to above conditions - Last Nane not same as Account Name, Contact type being 'Customer'
     type,  if custom fields A, B, C or D are changed on the existing record, push the record to 
       Queue object.
      In this case, Description would be 'Updated Contact' 
  
Behavior Observed Now :
Whenever a  new contact  is created, 2 copies of the same record are inserted into the Queue object. This I am assuming is happening because 'after insert' and 'after update' triggers aer firing for every new contact created. 

Insert Scenario(New Contact Creation) - Update scenario triggered - 'MDM Id Missing' message observed; Record inserted into Queue object twice
Update Scenario (PID null and record updated) - Working as expected - 'MDM Id Missing' message written into Queue object
Update scenario ( A,B,C or D field values change) - Update Scenario triggerd - 'Update contact' message written into Queue object



I don't understand why this is happening. There are no workflows impacting the behavior . It has to do with logic in the class below or the way I am invoking the trigger. 
Controller Class and Trigger Invocation are below.

I am trying to fix this code for sometime without any luck. I need to fix it as soon as possible. I am new to programming and can't figure out how to make this functionality work.
Please help. Thanks.









// Controller Class with processContact method

public class ContactController {

public  void processContact(Map<Id, Contact> newContactMap, Map<Id, Contact> oldContactMap)
{
       List<Queue__c> lstQ = new List<Queue__c>();   
         Id idContactCustomerRecType;
         Map<Id, String> mapIdToAccountName = new Map<Id, String>();
       
           List<RecordType> lstRecType = new List<RecordType>([SELECT Id FROM RecordType WHERE Name = 'Customer' AND SobjectType = 'Contact']);
          
      if(!lstRecType.isEmpty())
     idContactCustomerRecType = lstRecType[0].Id;
       
        if(idContactCustomerRecType != null)
         {
         // we can't fetch parent fields directly, so collecting account Ids first
           for(Contact objContact : newContactMap.values())
              {
                  if(objContact.AccountId != null)
                mapIdToAccountName.put(objContact.AccountId, null);
              }
          }
 
         // iterate over account with matching collected Ids and fetch names
          for(Account objAccount : [SELECT Id, Name FROM Account WHERE Id IN : mapIdToAccountName.keySet()])
          {
           mapIdToAccountName.put(objAccount.Id, objAccount.Name);
           }
  
         // loop again to perform business logic
        for(Contact objContact : newContactMap.values())
        {
             /* 1. If Contact RecordType is Customer AND if LastName != Account.Name, insert Queue **/
            if( objContact.RecordTypeId == idContactCustomerRecType
               && objContact.AccountId != null   && objContact.LastName != mapIdToAccountName.get(objContact.AccountId)
             {
             if(Trigger.isUpdate)
             {
                 if(label.Unauthorized_User!=objContact.lastmodifiedbyid)
                 {
                    if(objContact.A__c!= oldContactMap.get(objContact.Id).A__c
                        || objContact.B__c!= oldContactMap.get(objContact.Id).B__c
                        || objContact.D__c!= oldContactMap.get(objContact.Id).D__c)
                  {
                  
                   objQ.Description__c= 'Updated Contact';
                   objQ.Record_Id__c = objContact.Id;
                   objQ.Notification_Timestamp__c= objContact.CreatedDate;
                   lstQ.add(objQ);
                   }
                   
                   else if(objContact.PID__c == null)
                   {
                   objQ.Description__c= 'PID Missing';
                   objQ.Record_Id__c = objContact.Id;
                   objQ.Notification_Timestamp__c= objContact.CreatedDate;
                   lstQ.add(objQ);
                   
                   }
                   
                 }
             }
             
               if(Trigger.isInsert)
               {
                 objQ.Description__c= 'New Contact';
                   objQ.Record_Id__c = objContact.Id;
                   objQ.Notification_Timestamp__c= objContact.CreatedDate;
                   lstQ.add(objQ);
                   
               }
             }

            
                   
                
       }

       if(!lstQ.isEmpty())
       insert lstQ;
             
    }
     
    
     
}


Trigger Invocation :

Contact - After Insert 

if(Trigger.isInsert && Trigger.isAfter){
   ContactController.processContact(Trigger.newMap, Trigger.oldMap);
   }

Contact - After Update 

 if(Trigger.isUpdate && Trigger.isAfter){
        ContactController.processContact(Trigger.newMap, Trigger.oldMap);
    } 
Hi, 
I will explain the requirement first. 


Basic Logic:

 Create Contact Scenario - 
 Conditions - Last Name should not be same as Account Name, Contact type is Customer
  Everytime a new contact is created meeting the above conditions, it is written to Queue object
   In this case, Description would be 'New Contact' (to be written into Queue object)
   
   
  Update Contact Scenario -
  
  2 scenarios here - 
  
  1) In addition to abouve conditions being valid, if custom field PID is missing and any of the 
    fields in Contact record are updated, push the record to Queue object.
    In this case, Description would be 'PID Missing'
    
  2)  In addition to above conditions - Last Nane not same as Account Name, Contact type being 'Customer'
     type,  if custom fields A, B, C or D are changed on the existing record, push the record to 
       Queue object.
      In this case, Description would be 'Updated Contact' 
  

  
Behavior Observed Now :
Whenever a  new contact  is created, 2 copies of the same record are inserted into the Queue object. This I am assuming is happening because 'after insert' and 'after update' triggers aer firing for every new contact created. 

Insert Scenario(New Contact Creation) - Update scenario triggered - 'MDM Id Missing' message observed; Record inserted into Queue object twice
Update Scenario (PID null and record updated) - Working as expected - 'MDM Id Missing' message written into Queue object
Update scenario ( A,B,C or D field values change) - Update Scenario triggerd - 'Update contact' message written into Queue object



I don't understand why this is happening. There are no workflows impacting the behavior . It has to do with logic in the class below or the way I am invoking the trigger. 
Controller Class and Trigger Invocation are below.

I am trying to fix this code for sometime without any luck. I need to fix it as soon as possible. I am new to programming and can't figure out how to make this functionality work.
Please help. Thanks.









// Controller Class with processContact method

public class ContactController {

public  void processContact(Map<Id, Contact> newContactMap, Map<Id, Contact> oldContactMap)
{
       List<Queue__c> lstQ = new List<Queue__c>();   
         Id idContactCustomerRecType;
         Map<Id, String> mapIdToAccountName = new Map<Id, String>();
       
           List<RecordType> lstRecType = new List<RecordType>([SELECT Id FROM RecordType WHERE Name = 'Customer' AND SobjectType = 'Contact']);
          
      if(!lstRecType.isEmpty())
     idContactCustomerRecType = lstRecType[0].Id;
       
        if(idContactCustomerRecType != null)
         {
         // we can't fetch parent fields directly, so collecting account Ids first
           for(Contact objContact : newContactMap.values())
              {
                  if(objContact.AccountId != null)
                mapIdToAccountName.put(objContact.AccountId, null);
              }
          }
 
         // iterate over account with matching collected Ids and fetch names
          for(Account objAccount : [SELECT Id, Name FROM Account WHERE Id IN : mapIdToAccountName.keySet()])
          {
           mapIdToAccountName.put(objAccount.Id, objAccount.Name);
           }
  
         // loop again to perform business logic
        for(Contact objContact : newContactMap.values())
        {
             /* 1. If Contact RecordType is Customer AND if LastName != Account.Name, insert Queue **/
            if( objContact.RecordTypeId == idContactCustomerRecType
               && objContact.AccountId != null   && objContact.LastName != mapIdToAccountName.get(objContact.AccountId)
             {
             if(Trigger.isUpdate)
             {
                 if(label.Unauthorized_User!=objContact.lastmodifiedbyid)
                 {
                    if(objContact.A__c!= oldContactMap.get(objContact.Id).A__c
                        || objContact.B__c!= oldContactMap.get(objContact.Id).B__c
                        || objContact.D__c!= oldContactMap.get(objContact.Id).D__c)
                  {
                  
                   objQ.Description__c= 'Updated Contact';
                   objQ.Record_Id__c = objContact.Id;
                   objQ.Notification_Timestamp__c= objContact.CreatedDate;
                   lstQ.add(objQ);
                   }
                   
                   else if(objContact.PID__c == null)
                   {
                   objQ.Description__c= 'PID Missing';
                   objQ.Record_Id__c = objContact.Id;
                   objQ.Notification_Timestamp__c= objContact.CreatedDate;
                   lstQ.add(objQ);
                   
                   }
                   
                 }
             }
             
               if(Trigger.isInsert)
               {
                 objQ.Description__c= 'New Contact';
                   objQ.Record_Id__c = objContact.Id;
                   objQ.Notification_Timestamp__c= objContact.CreatedDate;
                   lstQ.add(objQ);
                   
               }
             }

            
                   
                
       }

       if(!lstQ.isEmpty())
       insert lstQ;
             
    }
     
    
     
}


Trigger Invocation :

Contact - After Insert 

if(Trigger.isInsert && Trigger.isAfter){
   ContactController.processContact(Trigger.newMap, Trigger.oldMap);
   }

Contact - After Update 

 if(Trigger.isUpdate && Trigger.isAfter){
        ContactController.processContact(Trigger.newMap, Trigger.oldMap);
    } 
01if(Trigger.isInsert && Trigger.isAfter)
02{
03    ContactController.processContact(Trigger.newMap, Trigger.oldMap);
04}
05else if(Trigger.isUpdate && Trigger.isAfter)
06{
07    ContactController.processContact(Trigger.newMap, Trigger.oldMap);
08}
09 
10 
11 
12// call process contact on both insert and update
13public  void processContact(Map<Id, Contact> newContactMap, Map<Id, Contact> oldContactMap) 
14{ 
15    List<Queue__c> lstQ = new List<Queue__c>();    
16    Id idContactCustomerRecType;
17    Map<Id, String> mapIdToAccountName = new Map<Id, String>();
18     
19    // Assuming Developer Name is 'Customer'
20    List<RecordType> lstRecType = new List<RecordType>([SELECT Id FROMRecordType WHERE DeveloperName = 'Customer' AND SobjectType ='Contact']);
21    if(!lstRecType.isEmpty())
22        idContactCustomerRecType = lstRecType[0].Id;
23         
24    if(idContactCustomerRecType != null)
25    {
26        // we can;t fetch parent fields directly, so collect account Ids first
27        for(Contact objContact : newContactMap.values())
28        {
29            if(objContact.AccountId != null)
30                mapIdToAccountName.put(objContact.AccountId, null);
31        }
32    }
33     
34    // iterate over account with matching collected Ids and fetch names
35    for(Account objAccount : [SELECT Id, Name FROM Account WHERE Id IN : mapIdToAccountName.keySet()])
36    {
37        mapIdToAccountName.put(objAccount.Id, objAccount.Name);
38    }
39     
40    // loop again to perform business logic
41    for(Contact objContact : newContactMap.values())
42    {
43        /* 1. If Contact RecordType is Customer AND if LastName != Account.Name, insert Queue **/
44        if( objContact.RecordTypeId == idContactCustomerRecType 
45            && objContact.AccountId != null
46            && objContact.LastName != mapIdToAccountName.get(objContact.AccountId)
47            (
48                Trigger.isInsert
49                    ||
50                (
51                    Trigger.isUpdate
52                        &&
53                    (   
54                        objContact.A__c!= oldContactMap.get(objContact.Id).A__c
55                        || objContact.B__c!= oldContactMap.get(objContact.Id).B__c
56                        || objContact.D__c!= oldContactMap.get(objContact.Id).D__c
57                    )
58                )
59            )
60            )
61        {
62            Queue__c objQ = new Queue__c();
63            objQ.Object_Name__c='Contact';
64             
65            if(Trigger.isUpdate)
66            {
67                if(objContact.PID__c == null)
68                    objQ.Description__c= 'PID Missing';
69                else
70                    objQ.Description__c= 'Updated Contact';
71            }
72            else
73            {
74                objQ.Description__c= 'New Contact';
75            }
76             
77            objQ.Record_Id__c = objContact.Id;
78            objQ.Notification_Timestamp__c= objContact.CreatedDate;
79            lstQ.add(objQ);
80        }
81             
82    }
83     
84    if(!lstQ.isEmpty())
85        insert lstQ;
86     
87}
Basic Logic is :
For insert trigger case --- processNewContact is the class. 
Whenever a new contact is created of the type 'customer', it is inserted into objQ object.
Now, when the contact is created, a custom field 'PID' needs to be updated from external system into Salesforce. 


After Update Trigger Case --->
Whenever an existing contact is updated - If any of the fields change with 'PID' value null, updated record needs to be pushed into objQ object. Then the external system will reply back with 'PID' value which will assigned to Salesforce record.

Behavior now :
Whenever a  new contact  is created, 2 copies of the same record are inserted into the Queue object. This I am assuming is happening because 'after insert' and 'after update' triggers aer firing for every new contact created. 


I don't understand why this is happening. There are no workflows impacting the behavior . It has to do with logic in the class below. UpdateContact  is similar to processNewContact method below ; only difference is checking whether any of the fields have changed. If they have and 'PID' value is null, record will be pushed into Queue object.  Please assist. I have been trying to fix for sometime without any luck...I need to fix it as soon as possible. I had posted the same earlier but didn't get any reply.  I am new to  programming and can't figure out how to fix it. Thanks...




public static void processNewContact(Map<Id, Contact> newContactMap, Map<Id, Contact> oldContactMap)
02{
03    List<Queue__c> lstQ = new List<Queue__c>();   
04    Id idContactCustomerRecType;
05    Map<Id, String> mapIdToAccountName = new Map<Id, String>();
06     
07    // Assuming Contact type Name is 'Customer'
08    List<RecordType> lstRecType = new List<RecordType>([SELECT Id FROM RecordType WHERE Name = 'Customer' AND SobjectType = 'Contact']);
09    if(!lstRecType.isEmpty())
10        idContactCustomerRecType = lstRecType[0].Id;
11         
12    if(idContactCustomerRecType != null)
13    {
14        // we can;t fetch parent fields directly, so collect account Ids first
15        for(Contact objContact : newContactMap.values())
16        {
17            if(objContact.AccountId != null)
18                mapIdToAccountName.put(objContact.AccountId, null);
19        }
20    }
21     
22    // iterate over account with matching collected Ids and fetch names
23    for(Account objAccount : [SELECT Id, Name FROM Account WHERE Id IN : mapIdToAccountName.keySet()])
24    {
25        mapIdToAccountName.get(objAccount.Id, objAccount.Name);
26    }
27     
28    // loop again to perform business logic
29    for(Contact objContact : newContactMap.values())
30    {
31        /* 1. If Contact RecordType is Customer AND if LastName != Account.Name, insert Queue **/
32        if(objContact.RecordTypeId == idContactCustomerRecType && objContact.AccountId != null && objContact.LastName != mapIdToAccountName.get(objContact.AccountId))
33        {
34            Queue__c objQ = new Queue__c();
35            objQ.Object_Name__c='Contact';
36            objQ.Description__c= 'New Contact';
37            objQ.Record_Id__c = objContact.Id;
38            objQ.Notification_Timestamp__c= objContact.CreatedDate;
39            lstQ.add(objQ);
40        }
41             
42    }
43     
               isCreated = true;

44    if(!lstQ.isEmpty())
45        insert lstQ;
46     
47  }

Trigger Invocation :  After UPDATE
if(ContactController.isCreated==false ){
        ContactController.UpdateContact(Trigger.newMap, Trigger.oldMap);
    } 

AFTER INSERT 
    ContactController.processNewContact(Trigger.newMap, Trigger.oldMap);

 
Basic Logic is :
For insert trigger case --- processNewContact is the class. 
Whenever a new contact is created of the type 'customer', it is inserted into objQ object.
Now, when the contact is created, a custom field 'PID' needs to be updated from external system into Salesforce. 


After Update Trigger Case --->
Whenever an existing contact is updated - If any of the fields change with 'PID' value null, updated record needs to be pushed into objQ object. Then the external system will reply back with 'PID' value which will assigned to Salesforce record.

Behavior now :
Whenever a  new contact  is created, 2 copies of the same record are inserted into the Queue object. This I am assuming is happening because 'after insert' and 'after update' triggers aer firing for every new contact created. 


I don't understand why this is happening. There are no workflows impacting the behavior . It has to do with logic in the class below. UpdateContact  is similar to processNewContact method below ; only difference is checking whether any of the fields have changed. If they have and 'PID' value is null, record will be pushed into Queue object.  Please assist. I have been trying to fix for sometime without any luck...Thanks...




public static void processNewContact(Map<Id, Contact> newContactMap, Map<Id, Contact> oldContactMap)
02{
03    List<Queue__c> lstQ = new List<Queue__c>();   
04    Id idContactCustomerRecType;
05    Map<Id, String> mapIdToAccountName = new Map<Id, String>();
06     
07    // Assuming Contact type Name is 'Customer'
08    List<RecordType> lstRecType = new List<RecordType>([SELECT Id FROM RecordType WHERE Name = 'Customer' AND SobjectType = 'Contact']);
09    if(!lstRecType.isEmpty())
10        idContactCustomerRecType = lstRecType[0].Id;
11         
12    if(idContactCustomerRecType != null)
13    {
14        // we can;t fetch parent fields directly, so collect account Ids first
15        for(Contact objContact : newContactMap.values())
16        {
17            if(objContact.AccountId != null)
18                mapIdToAccountName.put(objContact.AccountId, null);
19        }
20    }
21     
22    // iterate over account with matching collected Ids and fetch names
23    for(Account objAccount : [SELECT Id, Name FROM Account WHERE Id IN : mapIdToAccountName.keySet()])
24    {
25        mapIdToAccountName.get(objAccount.Id, objAccount.Name);
26    }
27     
28    // loop again to perform business logic
29    for(Contact objContact : newContactMap.values())
30    {
31        /* 1. If Contact RecordType is Customer AND if LastName != Account.Name, insert Queue **/
32        if(objContact.RecordTypeId == idContactCustomerRecType && objContact.AccountId != null && objContact.LastName != mapIdToAccountName.get(objContact.AccountId))
33        {
34            Queue__c objQ = new Queue__c();
35            objQ.Object_Name__c='Contact';
36            objQ.Description__c= 'New Contact';
37            objQ.Record_Id__c = objContact.Id;
38            objQ.Notification_Timestamp__c= objContact.CreatedDate;
39            lstQ.add(objQ);
40        }
41             
42    }
43     
               isCreated = true;

44    if(!lstQ.isEmpty())
45        insert lstQ;
46     


Trigger Invocation :  After UPDATE
if(ContactController.isCreated==false ){
        ContactController.UpdateContact(Trigger.newMap, Trigger.oldMap);
    } 

AFTER INSERT 
    ContactController.processNewContact(Trigger.newMap, Trigger.oldMap);

47}
Hi, I am getting compile error: Method does not exist or incorrenct signature  for for  mapIdToAccountName.get(objAccount.Id, objAccount.Name) at line 25. Not able to resolve this error. Please help. I am new to Apex programming. Thanks...



01public static void processNewContact(Map<Id, Contact> newContactMap, Map<Id, Contact> oldContactMap)
02{
03    List<Queue__c> lstQ = new List<Queue__c>();   
04    Id idContactCustomerRecType;
05    Map<Id, String> mapIdToAccountName = new Map<Id, String>();
06     
07    // Assuming Developer Name is 'Customer'
08    List<RecordType> lstRecType = new List<RecordType>([SELECT Id FROM RecordType WHEREDeveloperName = 'Customer' AND SobjectType = 'Contact']);
09    if(!lstRecType.isEmpty())
10        idContactCustomerRecType = lstRecType[0].Id;
11         
12    if(idContactCustomerRecType != null)
13    {
14        // we can;t fetch parent fields directly, so collect account Ids first
15        for(Contact objContact : newContactMap.values())
16        {
17            if(objContact.AccountId != null)
18                mapIdToAccountName.put(objContact.AccountId, null);
19        }
20    }
21     
22    // iterate over account with matching collected Ids and fetch names
23    for(Account objAccount : [SELECT Id, Name FROM Account WHERE Id IN : mapIdToAccountName.keySet()])
24    {
25        mapIdToAccountName.get(objAccount.Id, objAccount.Name);
26    }
27     
28    // loop again to perform business logic
29    for(Contact objContact : newContactMap.values())
30    {
31        /* 1. If Contact RecordType is Customer AND if LastName != Account.Name, insert Queue **/
32        if(objContact.RecordTypeId == idContactCustomerRecType && objContact.AccountId != null && objContact.LastName != mapIdToAccountName.get(objContact.AccountId))
33        {
34            Queue__c objQ = new Queue__c();
35            objQ.Object_Name__c='Contact';
36            objQ.Description__c= 'New Contact';
37            objQ.Record_Id__c = objContact.Id;
38            objQ.Notification_Timestamp__c= objContact.CreatedDate;
39            lstQ.add(objQ);
40        }
41             
42    }
43     
44    if(!lstQ.isEmpty())
45        insert lstQ;
46     
47}
Basic Logic is : Every new contact of record type 'customer' will be inserted into q Queue object. Additional logic is the new contact won't be inserted into the Queue if Contact's last name is not qual to Account Name. This is what I am unable to implement. I have tried to use this condition everywhere in the logic. It simple does not work. I am new to Apex programming. Please help. 

Logic :
public static void processNewContact(Map<Id, Contact> newContactMap, Map<Id, Contact> oldContactMap) { 
                List<Queue__c> objList = new List<Queue__c>();    
                Map<id, recordtype> contactRecTypeMap = new Map<id, recordType>([select id from Recordtype where SobjectType='Contact' and Name = 'Customer']);
                     if(contactRecTypeMap!=null ){
                    System.debug('RECORDTYPES RETRIEVED>>>' + contactRecTypeMap + 'size>>>' + contactRecTypeMap.size());
              //   if(contact.account.name!=contact.lastname) {
                    for(Contact c: newContactMap.values()) {  
                  //   if(c.account.name!=c.lastname) {
                    System.debug('checking for last name and account name entry >>>> If Loop1 >>' + c.lastname + c.account.name);
                   //   if(c.account.name!=null && c.lastname!=c.account.name) {
      //   if(c.lastname!=c.account.name) {
             if(contactRecTypeMap !=null && contactRecTypeMap.keySet().contains(c.recordtypeID)){   
            //    if(c.lastname!=c.account.name) {
                  Queue__c q1 = new Queue__c();
                         q1.Object_Name__c='Contact';
                         q1.Description__c= 'New Contact';
                         q.Record_Id__c = C.Id;
                          q1.Notification_Timestamp__c= c.CreatedDate;
                          
                         /*   if(c.lastname!=c.account.name) {
                  objList.add(obj1);
                
                          }
                         
                         else {
                         
                         delete objList;
                         
                         }  */
        
                         
                        }  
              //   }
                     
                 //  }
              }
       
                           }
         
         }
Hi, I have 3 fields - A,B,C  These fields have values Yes and No. 
Basic functionality is everytime A, B or C field values change, date for A gets changed to time user made the changes . Same for B and Same for C. I have using 3 workflow rules with field update for 3 fields A,B, C

Issue : Whenever field 'A'  value is changed from 'Yes' to 'No', date for 'A' changes to system time. In addition, date for 'B' and 'C' field is also getting changed to same system time as 'A' system time even if there is no change in values for fields 'B' and 'C'.

Below is the workflow and equivalent field update I am using 

OR(NOT( ISPICKVAL(A__c, "")),AND((ISCHANGED( A__c )), NOT(Ischanged(ADate__c)))  )
Field update : Change ADate__c to now()

Same workflow rule for fields 'B' and 'C'. Not able to figure out why workflows for 'B' and 'C' are also getting triggered because of 'A' and vice versa. Please help. I am trying to resolve this issue for a couple of hours now. Thanks
HI,
I am writing logic for the scenarios: When a lead is created, few of the fields are written to a
custom object. When the same less record is updated, I want to push the record into the same custom object.
The problem: with creation of a record, fields a,b, c are  mandatory to save the record. These would be pushed.
Now, when the same record is updated, details are to be sent. Issue is with every creation scenario, even the update trigger is getting fired- there are 2 sets of records. I have tried to use flags but it didn't help. Eg: 
if(flag is true or 'd' field is not updated), update lead. This doesn't work. Please help. Thanks .
Is this possible?
Eg: I have using a workflow rule to default the date(D field) to system date when user selects changes one of the values in another field(E). Everytime the value changes in 'E' field, date(D) field changes to system date. Now, can the same changes be made by an external system? Can an interface supply these values? Please let me know. Thanks.
Is this a Salesforce maintenance/ system issue? Not able to get my class to run since yesterday...Any idea what's happening here?
Hi, I am new to Apex.  I am having difficulty writing a test class for update lead scenario. 
I have written the code for new leads. Here, I am creating new lead records and inserting them, I am not sure of the approach to reference these newly created leads for update scenario. I also have to compare old and new values in update scenario.

Example : I created a lead ' test'  with  phone number = '12345', I inserted this record. Now,  I will update lead 'test' with phone number ='54321'.  Now, I want to compare old phone number and new phone number and perform next step ( insert into another object) only if 'phone number' value is changed for lead 'test'. How do I implement a test class for this scenario? Please assist. Thanks
Hi, I am new to Apex.  I am having difficulty writing a test class for update lead scenario. 
I have written the code for new leads. Here, I am creating new lead records and inserting them, I am not sure of the approach to reference these newly created leads for update scenario. I also have to compare old and new values in u[date scenario. Please assist. Thanks
Hi, I need to add a list of users to a Cusom Label. I then need to reference this label to allow only users in Custom Label the ability to write data into a custom object using a trigger . I'm new to Apex and Salesforce. Please assist. Thanks.
Hi, I need to return only specific records by recordtype name. How do I implement this in trigger . Thanks
Hi, I need to insert only those records in a custom object using after update trigger, where the lastModifiedBy User is not 'User X'
Thanks
Hi, 
Basic Logic:
 Create Contact Scenario - 
 Conditions - Last Name should not be same as Account Name, Contact type is Customer
  Everytime a new contact is created meeting the above conditions, it is written to Queue object
   In this case, Description would be 'New Contact' (to be written into Queue object)
   
 Update Contact Scenario -
 2 scenarios here -   
  1) In addition to abouve conditions being valid, if custom field PID is missing and any of the 
    fields in Contact record are updated, push the record to Queue object.
    In this case, Description would be 'PID Missing'
    
  2)  In addition to above conditions - Last Nane not same as Account Name, Contact type being 'Customer'
     type,  if custom fields A, B, C or D are changed on the existing record, push the record to 
       Queue object.
      In this case, Description would be 'Updated Contact' 
  
Behavior Observed Now :
Whenever a  new contact  is created, 2 copies of the same record are inserted into the Queue object. This I am assuming is happening because 'after insert' and 'after update' triggers aer firing for every new contact created. 

Insert Scenario(New Contact Creation) - Update scenario triggered - 'MDM Id Missing' message observed; Record inserted into Queue object twice
Update Scenario (PID null and record updated) - Working as expected - 'MDM Id Missing' message written into Queue object
Update scenario ( A,B,C or D field values change) - Update Scenario triggerd - 'Update contact' message written into Queue object



I don't understand why this is happening. There are no workflows impacting the behavior . It has to do with logic in the class below or the way I am invoking the trigger. 
Controller Class and Trigger Invocation are below.

I am trying to fix this code for sometime without any luck. I need to fix it as soon as possible. I am new to programming and can't figure out how to make this functionality work. I have posted the same queury for  past couple of days. I will greatly appreciate if you could help identify and fix this issue..Thanks.









// Controller Class with processContact method

public class ContactController {

public  void processContact(Map<Id, Contact> newContactMap, Map<Id, Contact> oldContactMap)
{
       List<Queue__c> lstQ = new List<Queue__c>();   
         Id idContactCustomerRecType;
         Map<Id, String> mapIdToAccountName = new Map<Id, String>();
       
           List<RecordType> lstRecType = new List<RecordType>([SELECT Id FROM RecordType WHERE Name = 'Customer' AND SobjectType = 'Contact']);
          
      if(!lstRecType.isEmpty())
     idContactCustomerRecType = lstRecType[0].Id;
       
        if(idContactCustomerRecType != null)
         {
         // we can't fetch parent fields directly, so collecting account Ids first
           for(Contact objContact : newContactMap.values())
              {
                  if(objContact.AccountId != null)
                mapIdToAccountName.put(objContact.AccountId, null);
              }
          }
 
         // iterate over account with matching collected Ids and fetch names
          for(Account objAccount : [SELECT Id, Name FROM Account WHERE Id IN : mapIdToAccountName.keySet()])
          {
           mapIdToAccountName.put(objAccount.Id, objAccount.Name);
           }
  
         // loop again to perform business logic
        for(Contact objContact : newContactMap.values())
        {
             /* 1. If Contact RecordType is Customer AND if LastName != Account.Name, insert Queue **/
            if( objContact.RecordTypeId == idContactCustomerRecType
               && objContact.AccountId != null   && objContact.LastName != mapIdToAccountName.get(objContact.AccountId)
             {
             if(Trigger.isUpdate)
             {
                 if(label.Unauthorized_User!=objContact.lastmodifiedbyid)
                 {
                    if(objContact.A__c!= oldContactMap.get(objContact.Id).A__c
                        || objContact.B__c!= oldContactMap.get(objContact.Id).B__c
                        || objContact.D__c!= oldContactMap.get(objContact.Id).D__c)
                  {
                  
                   objQ.Description__c= 'Updated Contact';
                   objQ.Record_Id__c = objContact.Id;
                   objQ.Notification_Timestamp__c= objContact.CreatedDate;
                   lstQ.add(objQ);
                   }
                   
                   else if(objContact.PID__c == null)
                   {
                   objQ.Description__c= 'PID Missing';
                   objQ.Record_Id__c = objContact.Id;
                   objQ.Notification_Timestamp__c= objContact.CreatedDate;
                   lstQ.add(objQ);
                   
                   }
                   
                 }
             }
             
               if(Trigger.isInsert)
               {
                 objQ.Description__c= 'New Contact';
                   objQ.Record_Id__c = objContact.Id;
                   objQ.Notification_Timestamp__c= objContact.CreatedDate;
                   lstQ.add(objQ);
                   
               }
             }

            
                   
                
       }

       if(!lstQ.isEmpty())
       insert lstQ;
             
    }
     
    
     
}


Trigger Invocation :

Contact - After Insert 

if(Trigger.isInsert && Trigger.isAfter){
   ContactController.processContact(Trigger.newMap, Trigger.oldMap);
   }

Contact - After Update 

 if(Trigger.isUpdate && Trigger.isAfter){
        ContactController.processContact(Trigger.newMap, Trigger.oldMap);
    } 
Hi EveryOne,
I am a newbee, here is my trigger which is not working as expected,I would like to make this work on both before Insert and before update events,the requirement is whenever an account is either going to be created or updated with its Test_Amount__c  field's value = or > 100000,
then the Rating field should have the value as 'Hot' on both Before insert and Before upadate event.
 
trigger InUpAccts on Account (before insert,before update) {
    
    if (trigger.isbefore && trigger.Isupdate)
    {     
        for (Account A : Trigger.New)
        {  List <Account> Aclist = New List <Account> ();
            System.debug('------------------------>'+Trigger.New);
          
            If (A.Name !=null && A.Test_Amount__c == 100000)
             {   
                System.debug('------------------------>'+A.Test_Amount__c);
                Account Acct = New Account();
                //Acct.Name =
                Acct.Rating = 'Hot';
                Aclist.add(Acct);
             }
            If (Aclist.size()>0)
              {   
                System.debug('------------------------>'+Aclist.size());
                Insert Aclist;
                System.debug('------------------------>'+Aclist);
              } 
            else If (A.Name !=null && A.Test_Amount__c == 100)
            {
            Update Aclist;
            }    
        }
    }
}

 
  • June 04, 2016
  • Like
  • 0
01if(Trigger.isInsert && Trigger.isAfter)
02{
03    ContactController.processContact(Trigger.newMap, Trigger.oldMap);
04}
05else if(Trigger.isUpdate && Trigger.isAfter)
06{
07    ContactController.processContact(Trigger.newMap, Trigger.oldMap);
08}
09 
10 
11 
12// call process contact on both insert and update
13public  void processContact(Map<Id, Contact> newContactMap, Map<Id, Contact> oldContactMap) 
14{ 
15    List<Queue__c> lstQ = new List<Queue__c>();    
16    Id idContactCustomerRecType;
17    Map<Id, String> mapIdToAccountName = new Map<Id, String>();
18     
19    // Assuming Developer Name is 'Customer'
20    List<RecordType> lstRecType = new List<RecordType>([SELECT Id FROMRecordType WHERE DeveloperName = 'Customer' AND SobjectType ='Contact']);
21    if(!lstRecType.isEmpty())
22        idContactCustomerRecType = lstRecType[0].Id;
23         
24    if(idContactCustomerRecType != null)
25    {
26        // we can;t fetch parent fields directly, so collect account Ids first
27        for(Contact objContact : newContactMap.values())
28        {
29            if(objContact.AccountId != null)
30                mapIdToAccountName.put(objContact.AccountId, null);
31        }
32    }
33     
34    // iterate over account with matching collected Ids and fetch names
35    for(Account objAccount : [SELECT Id, Name FROM Account WHERE Id IN : mapIdToAccountName.keySet()])
36    {
37        mapIdToAccountName.put(objAccount.Id, objAccount.Name);
38    }
39     
40    // loop again to perform business logic
41    for(Contact objContact : newContactMap.values())
42    {
43        /* 1. If Contact RecordType is Customer AND if LastName != Account.Name, insert Queue **/
44        if( objContact.RecordTypeId == idContactCustomerRecType 
45            && objContact.AccountId != null
46            && objContact.LastName != mapIdToAccountName.get(objContact.AccountId)
47            (
48                Trigger.isInsert
49                    ||
50                (
51                    Trigger.isUpdate
52                        &&
53                    (   
54                        objContact.A__c!= oldContactMap.get(objContact.Id).A__c
55                        || objContact.B__c!= oldContactMap.get(objContact.Id).B__c
56                        || objContact.D__c!= oldContactMap.get(objContact.Id).D__c
57                    )
58                )
59            )
60            )
61        {
62            Queue__c objQ = new Queue__c();
63            objQ.Object_Name__c='Contact';
64             
65            if(Trigger.isUpdate)
66            {
67                if(objContact.PID__c == null)
68                    objQ.Description__c= 'PID Missing';
69                else
70                    objQ.Description__c= 'Updated Contact';
71            }
72            else
73            {
74                objQ.Description__c= 'New Contact';
75            }
76             
77            objQ.Record_Id__c = objContact.Id;
78            objQ.Notification_Timestamp__c= objContact.CreatedDate;
79            lstQ.add(objQ);
80        }
81             
82    }
83     
84    if(!lstQ.isEmpty())
85        insert lstQ;
86     
87}
Basic Logic is :
For insert trigger case --- processNewContact is the class. 
Whenever a new contact is created of the type 'customer', it is inserted into objQ object.
Now, when the contact is created, a custom field 'PID' needs to be updated from external system into Salesforce. 


After Update Trigger Case --->
Whenever an existing contact is updated - If any of the fields change with 'PID' value null, updated record needs to be pushed into objQ object. Then the external system will reply back with 'PID' value which will assigned to Salesforce record.

Behavior now :
Whenever a  new contact  is created, 2 copies of the same record are inserted into the Queue object. This I am assuming is happening because 'after insert' and 'after update' triggers aer firing for every new contact created. 


I don't understand why this is happening. There are no workflows impacting the behavior . It has to do with logic in the class below. UpdateContact  is similar to processNewContact method below ; only difference is checking whether any of the fields have changed. If they have and 'PID' value is null, record will be pushed into Queue object.  Please assist. I have been trying to fix for sometime without any luck...I need to fix it as soon as possible. I had posted the same earlier but didn't get any reply.  I am new to  programming and can't figure out how to fix it. Thanks...




public static void processNewContact(Map<Id, Contact> newContactMap, Map<Id, Contact> oldContactMap)
02{
03    List<Queue__c> lstQ = new List<Queue__c>();   
04    Id idContactCustomerRecType;
05    Map<Id, String> mapIdToAccountName = new Map<Id, String>();
06     
07    // Assuming Contact type Name is 'Customer'
08    List<RecordType> lstRecType = new List<RecordType>([SELECT Id FROM RecordType WHERE Name = 'Customer' AND SobjectType = 'Contact']);
09    if(!lstRecType.isEmpty())
10        idContactCustomerRecType = lstRecType[0].Id;
11         
12    if(idContactCustomerRecType != null)
13    {
14        // we can;t fetch parent fields directly, so collect account Ids first
15        for(Contact objContact : newContactMap.values())
16        {
17            if(objContact.AccountId != null)
18                mapIdToAccountName.put(objContact.AccountId, null);
19        }
20    }
21     
22    // iterate over account with matching collected Ids and fetch names
23    for(Account objAccount : [SELECT Id, Name FROM Account WHERE Id IN : mapIdToAccountName.keySet()])
24    {
25        mapIdToAccountName.get(objAccount.Id, objAccount.Name);
26    }
27     
28    // loop again to perform business logic
29    for(Contact objContact : newContactMap.values())
30    {
31        /* 1. If Contact RecordType is Customer AND if LastName != Account.Name, insert Queue **/
32        if(objContact.RecordTypeId == idContactCustomerRecType && objContact.AccountId != null && objContact.LastName != mapIdToAccountName.get(objContact.AccountId))
33        {
34            Queue__c objQ = new Queue__c();
35            objQ.Object_Name__c='Contact';
36            objQ.Description__c= 'New Contact';
37            objQ.Record_Id__c = objContact.Id;
38            objQ.Notification_Timestamp__c= objContact.CreatedDate;
39            lstQ.add(objQ);
40        }
41             
42    }
43     
               isCreated = true;

44    if(!lstQ.isEmpty())
45        insert lstQ;
46     
47  }

Trigger Invocation :  After UPDATE
if(ContactController.isCreated==false ){
        ContactController.UpdateContact(Trigger.newMap, Trigger.oldMap);
    } 

AFTER INSERT 
    ContactController.processNewContact(Trigger.newMap, Trigger.oldMap);

 
Basic Logic is : Every new contact of record type 'customer' will be inserted into q Queue object. Additional logic is the new contact won't be inserted into the Queue if Contact's last name is not qual to Account Name. This is what I am unable to implement. I have tried to use this condition everywhere in the logic. It simple does not work. I am new to Apex programming. Please help. 

Logic :
public static void processNewContact(Map<Id, Contact> newContactMap, Map<Id, Contact> oldContactMap) { 
                List<Queue__c> objList = new List<Queue__c>();    
                Map<id, recordtype> contactRecTypeMap = new Map<id, recordType>([select id from Recordtype where SobjectType='Contact' and Name = 'Customer']);
                     if(contactRecTypeMap!=null ){
                    System.debug('RECORDTYPES RETRIEVED>>>' + contactRecTypeMap + 'size>>>' + contactRecTypeMap.size());
              //   if(contact.account.name!=contact.lastname) {
                    for(Contact c: newContactMap.values()) {  
                  //   if(c.account.name!=c.lastname) {
                    System.debug('checking for last name and account name entry >>>> If Loop1 >>' + c.lastname + c.account.name);
                   //   if(c.account.name!=null && c.lastname!=c.account.name) {
      //   if(c.lastname!=c.account.name) {
             if(contactRecTypeMap !=null && contactRecTypeMap.keySet().contains(c.recordtypeID)){   
            //    if(c.lastname!=c.account.name) {
                  Queue__c q1 = new Queue__c();
                         q1.Object_Name__c='Contact';
                         q1.Description__c= 'New Contact';
                         q.Record_Id__c = C.Id;
                          q1.Notification_Timestamp__c= c.CreatedDate;
                          
                         /*   if(c.lastname!=c.account.name) {
                  objList.add(obj1);
                
                          }
                         
                         else {
                         
                         delete objList;
                         
                         }  */
        
                         
                        }  
              //   }
                     
                 //  }
              }
       
                           }
         
         }
Hi, I have 3 fields - A,B,C  These fields have values Yes and No. 
Basic functionality is everytime A, B or C field values change, date for A gets changed to time user made the changes . Same for B and Same for C. I have using 3 workflow rules with field update for 3 fields A,B, C

Issue : Whenever field 'A'  value is changed from 'Yes' to 'No', date for 'A' changes to system time. In addition, date for 'B' and 'C' field is also getting changed to same system time as 'A' system time even if there is no change in values for fields 'B' and 'C'.

Below is the workflow and equivalent field update I am using 

OR(NOT( ISPICKVAL(A__c, "")),AND((ISCHANGED( A__c )), NOT(Ischanged(ADate__c)))  )
Field update : Change ADate__c to now()

Same workflow rule for fields 'B' and 'C'. Not able to figure out why workflows for 'B' and 'C' are also getting triggered because of 'A' and vice versa. Please help. I am trying to resolve this issue for a couple of hours now. Thanks