• Larry D. Dortch
  • NEWBIE
  • 10 Points
  • Member since 2015
  • Salesforce Administrator
  • The Salesforce Guy


  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 19
    Replies
Hello Group,
Need help writing a Trigger on Account object that will run when an account is created or updated.  We use "Service Location Codes" based on the address zip code.  I have a custom object named SLC to Zip where I want to match the account address zip to the SLC Zip, get the SLC Code (ie. CD3BAY) and update it on the account custom field Service_Location_Code__c

Here's the code I have written so far and any help is much appreciated!
 
// @Description: - Trigger Logic:-

//                1) Collect Account Ids in Set.
//                2) Create Map of Address ID to Zipcode.
//                3) Create Map of ZipCode and SLC to Zip Object.
//                4) Update Account obj Service_Location_Code__c on zip match

trigger SLCInsertAndUpdate on Account (after insert, after update){
    
    // declare an instance of Account obj as Variable: a
    Account a = new Account();

    List<Account> aSLCupdateList = new List<Account>();
    Map<id, Account> mapAccount = new Map<id, Account>();
    Map<String, String> aZipMap = new Map<String, String>();
    Map<String,SLC_to_ZIP__c> zipCodeSLCMap = new Map<String,SLC_to_ZIP__c>();
    Set<Id> accIDs = new Set<Id>();
    
    for(SLC_to_ZIP__c zipCode : [SELECT Id, SLC_Code__c, Zip_Code__c
                                     FROM SLC_to_ZIP__c
                                     WHERE Zip_Code__c IN: aZipMap.values()]) {
            zipCodeSLCMap.put(zipCode.Zip_Code__c,zipCode);
            zipCodeSLCMap.put(zipCode.SLC_Code__c,zipCode);
             System.debug(zipCode);
        
        system.debug('check zipCodeSLCMap' + zipCodeSLCMap);
        system.debug('check SLC Cose' + zipCode.SLC_Code__c);
                                                
     	if(zipCodeSLCMap.containsKey(aZipMap.get(zipCode.SLC_Code__c)))
           a.Service_Location_Code__c = zipCode.SLC_Code__c;
           
            
            if(!mapAccount.containsKey(a.id)) {
                mapAccount.put(a.id, a);
            }
        }
         
        if(mapAccount.values().size() > 0) {
            update mapAccount.values();
        }
    }

 
Seperately these statements work fine but when I add the OR function I get the error.  Doesn't make sense???

User-added image
Hello Group,
In just the last few days my users are impacted by an issue when trying to capture their geo coordiantes as part of a Check-in/Check-out process.
So far it's only affecting the Salesforce1 mobile app and as a workaround we're accessing the Salesforce mobile app with Chrome Mobile Browser where everything works fine.
Is anyone else seeing this behavior or have experienced something like this in the past?
Hello Group,

I'm trying to create a simple inline VF page but not able to filter just the records I need.

I'm working with 3 objects = Accounts >Customer Visit >Visit Notes.  
I just want to display the last 2 or 3 "Visit Notes" records when a new "Customer Visit" is created,  so our Reps can more easily follow up on their action items.

Customer Visit is a Lookup to Accounts, and Visit Notes is a Master-Detail to Customer Visit.
Visit Notes also has a Lookup relationship to Accounts.

I've tried several different WHERE clauses but only to produce a variety of compiler errors.
Any help would be greatly appreciated!
Hello Group,

I've been attemtping to prepoulate a Date/Time field with the now() function in a Visualforce page but not having any luck.
I've tried using apex inputField, inputText and just apexInput - all returning their various errors and issues.

Is this not possible to do this with Visualforce markup and a Standard controller or does it require a custom apex controller or using javascript?
Hello Group,
Need help writing a Trigger on Account object that will run when an account is created or updated.  We use "Service Location Codes" based on the address zip code.  I have a custom object named SLC to Zip where I want to match the account address zip to the SLC Zip, get the SLC Code (ie. CD3BAY) and update it on the account custom field Service_Location_Code__c

Here's the code I have written so far and any help is much appreciated!
 
// @Description: - Trigger Logic:-

//                1) Collect Account Ids in Set.
//                2) Create Map of Address ID to Zipcode.
//                3) Create Map of ZipCode and SLC to Zip Object.
//                4) Update Account obj Service_Location_Code__c on zip match

trigger SLCInsertAndUpdate on Account (after insert, after update){
    
    // declare an instance of Account obj as Variable: a
    Account a = new Account();

    List<Account> aSLCupdateList = new List<Account>();
    Map<id, Account> mapAccount = new Map<id, Account>();
    Map<String, String> aZipMap = new Map<String, String>();
    Map<String,SLC_to_ZIP__c> zipCodeSLCMap = new Map<String,SLC_to_ZIP__c>();
    Set<Id> accIDs = new Set<Id>();
    
    for(SLC_to_ZIP__c zipCode : [SELECT Id, SLC_Code__c, Zip_Code__c
                                     FROM SLC_to_ZIP__c
                                     WHERE Zip_Code__c IN: aZipMap.values()]) {
            zipCodeSLCMap.put(zipCode.Zip_Code__c,zipCode);
            zipCodeSLCMap.put(zipCode.SLC_Code__c,zipCode);
             System.debug(zipCode);
        
        system.debug('check zipCodeSLCMap' + zipCodeSLCMap);
        system.debug('check SLC Cose' + zipCode.SLC_Code__c);
                                                
     	if(zipCodeSLCMap.containsKey(aZipMap.get(zipCode.SLC_Code__c)))
           a.Service_Location_Code__c = zipCode.SLC_Code__c;
           
            
            if(!mapAccount.containsKey(a.id)) {
                mapAccount.put(a.id, a);
            }
        }
         
        if(mapAccount.values().size() > 0) {
            update mapAccount.values();
        }
    }

 
Seperately these statements work fine but when I add the OR function I get the error.  Doesn't make sense???

User-added image
Hello Group,

I'm trying to create a simple inline VF page but not able to filter just the records I need.

I'm working with 3 objects = Accounts >Customer Visit >Visit Notes.  
I just want to display the last 2 or 3 "Visit Notes" records when a new "Customer Visit" is created,  so our Reps can more easily follow up on their action items.

Customer Visit is a Lookup to Accounts, and Visit Notes is a Master-Detail to Customer Visit.
Visit Notes also has a Lookup relationship to Accounts.

I've tried several different WHERE clauses but only to produce a variety of compiler errors.
Any help would be greatly appreciated!
Hello Group,

I've been attemtping to prepoulate a Date/Time field with the now() function in a Visualforce page but not having any luck.
I've tried using apex inputField, inputText and just apexInput - all returning their various errors and issues.

Is this not possible to do this with Visualforce markup and a Standard controller or does it require a custom apex controller or using javascript?