
Here is the mapping required
Field Mexico_Postal_Code__c.IC_Channel_Manager__c goes to Account.IC_Account_Manager__c
Mexico_Postal_Code__c.AT_SF_FAE__c goes to Account.AT_Account_Manager__c and
Mexico_Postal_Code__c.AT_SF_FAE__c.Email goes to Account.Account_Manager_Email__c
Here is the current trigger. CAn anyone help?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
trigger UpdateZipCode on Account (before insert, before update) {
list<string> zipcodeList = new List<string>();
string zipCode;
for (integer i = 0; i <trigger.new.size(); i++) {
zipcode = trigger.new[i].billingpostalCode;
system.debug('ZipCode: ' + zipcode);
if (zipcode != null) {
integer index = zipcode.indexof('-',0);
if (index != -1) {
zipcode = zipcode.substring(0, index);
}
// could not find delimiter, then try space instead for Canada zip code
else
{
index = zipcode.indexof(' ',0);
if(index != -1) {zipcode = zipcode.substring(0,index);}
}
system.debug('ZipCode after the filter: ' + zipcode);
zipcodeList.add(zipCode);
}
}
system.debug('zipcode size: ' + zipcodelist.size());
if (zipcodelist.size() > 0) {
List<Zip_Code_Table__c> zipCodeTableList = [Select id, name from Zip_Code_Table__c where name in :zipcodeList];
system.debug('Data returned by zipcodeTable : ' + zipCodeTableList.size());
if (zipCodeTableList.size() > 0) {
//Add the zip code into a map
map<string, id> mapZipName= new map<string, id>();
for (integer i=0; i<zipcodeTableList.size(); i++) {
mapZipName.put(zipcodeTableList[i].name, zipcodeTableList[i].id);
}
//There is possibility that the number of zipcode from account is more than the zipcodeid return from zipcode table
id zipcodeid;
for (integer i = 0; i <trigger.new.size(); i++) {
zipcode = trigger.new[i].billingpostalCode;
if (zipcode != null) {
integer index = zipcode.indexof('-',0);
if (index != -1) {
zipcode = zipcode.substring(0, index);
}
// could not find delimiter, then try space instead for Canada zip code
else
{
index = zipcode.indexof(' ',0);
if(index != -1) {zipcode = zipcode.substring(0,index);}
}
zipcodeid = mapZipName.get(zipcode);
system.debug('zipcodeid: ' + zipcodeid);
Trigger.new[i].Zip_Code__c = zipcodeid;
}
}
}
}
}
1 Antwort
Hi I would also suggest you to post this question to the developer community for speedy resolution !
This Answers Community is focused on configuration and design questions. Programmatic questions are best submitted to the developer forums at https://developer.salesforce.com where the forums and participants are geared toward programming troubleshooting and support.