You need to sign in to do that
Don't have an account?
ABC XYZ 39
Compile Error: Expecting right parentheses, found '(' at line 48. Please assist. Thanks.
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}
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}
All Answers
Because Statements from line 48 are executing inside if condition, so it should be inside curly brackets { } and not inside the ().
Please let me know if this helps u.