• EricSSH
  • NEWBIE
  • 0 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 5
    Replies
Recently It has been requested by my manager to begin handling all Salesforce development requests in order to not have to hire outside help from consultants, so he told me to begin doing research for some courses so I will be able to handle these requests more effectively.

I know this question is subjective and I would actually like to hear your experiences and opinions. It looks like I will primarily be working with more of the "back-end" aspect of Sales force and won't need to have a great deal of requests for Visual force yet. So as long as admins don't have an issue with subjective and opinionated answers, I would like to hear what you guys have to say.

So to sum it up, How do I get started?
I'm creating a trigger to do some validations and I have a map that is Country_Key__c, Description_Name__c, Name.  I would like to get them all into a map so I can do some validations.  I have googled and search this form for some answers, but I am very new to Salesforce and Apex and do not grasp many of the concepts..  I would like to create these maps to do be multidimensional..

trigger OverrideAddressTrigger on Sampling__c (before insert) {
    

 
    Map<String, Validation_Country__c> validCountries = new Map<String, Validation_Country__c>();
    Map<String, Validation_Region__c> validRegions = new Map<String, Validation_Region__c>();
   
    //Getting Country Validation.
    For(Validation_Country__c obj : [Select Id,Country_Name__c,Transportation_Zone__C FROM Validation_Country__c]){
        validCountries.put( obj.Country_Name__c,obj);
}
    //Getting Region Validation
    For(Validation_Region__c objR : [Select Id,Country_Key__c,Description__c,Name FROM Validation_Region__c]){
        validRegions.put( objR.Description__c,objR);
        validRegions.put( objR.Country_Key__c,objR);
}
   
    For( Sampling__c s : Trigger.new){
        IF(s.Country__c != null){
            IF(validRegions.containsKey(s.Country__c) && (validRegions.contains(s.State_Province__c)){//Not quite right.. logic? 
                s.Country__c == validCountries.get(s.Country__c);//Wrong needs fixing
               
               
        }
    }
   }
}


Hello All,
I have been assigned a pretty daunting task to create a validation trigger for Ship to information.  I am very stressed out considering I have 0 experince inside the Salesforce enviroment.  Requirements below..

-------------
This support is needed on the Sampling__c object.
When saved with field Override__c = "Yes", we need to verify
1. that values entered in the Country__c field are are restricted to those listed on the attached file on the first tab in the Valid Country Codes column (column A)
2. that values in the State_Province__c field are restricted to those listed as valid for the entered Country__c value as noted on the second tab (column C lists valid options for the Country Code listed in column A)
3. that values entered in the Zip_Postal_Code__c field adhere to the attached rules for the entered Country__c as noted on the first tab (columns D, E and F indicate the rule for the Country Code listed in column A)
4. that values entered in the SAP_Transportation_Zone__c field are restricted to those listed as valid for the entered Country__c value as noted on the first tab (column c) – in fact if your trigger instead could auto-populate this field based on what is valid for the country code the user selects in the  Country__c field, that would be even better!

We are not able to accomplished this via dependent picklists as we feed these fields from our lead convert and custom address object and need to allow users to freely type values in those objects. We only want this validation to take place once the Sample record is saved with Override__c = "Yes" as stated above.----------

I will almost post the code that I have so far.   You guys have a load more of experince than I do so if you can think of a better way to do it please feel free to tell me..  Any insite is appericatied. 

trigger OverrideAddressTrigger on Sampling__c (before insert) {
     //String[] countryCodeZero = new String[]{'AD','AE','AF','AG','AI','AL','AM','AN','AO','AQ','AS','AW','AZ','BA','BB','BD','BF','BG','BH','BI','BJ','BM','BN','BO','BS','BT','BV','BW','BY','BZ','CC','CD','CF','CG','CI','CK','CM','CU','CV','CX','DJ','DM','DO','EC','EE','EG','EH','ER','ET','FJ','FK','FM','GA','GD','GE','GF','GH','GI','GL','GM','GN','GP','GQ','GS','GT','GU','GW','GY','HM','HN','HT','IO','IQ','JM','JO','KE','KG','KH','KI','KM','KN','KY','LA','LB','LC','LK','LR','LT','LY','MA','MD','MG','MH','MK','ML','MM','MN','MO','MP','MQ','MR','MS','MT','MU','MV','MW','MZ','NA','NC','NE','NF','NG','NI','NR','NU','OM','PA','PE','PF','PG','PK','PM','PN','PR','PW','PY','QA','RE','RW','SB','SC','SD','SH','SJ','SL','SM','SN','SO','SR','ST','SV','SY','SZ','TC','TF','TG','TJ','TK','TL','TM','TO','TP','TT','TV','TZ','UG','UM','UZ','VA','VC','VG','VI','VU','WF','WS','YE','YT','ZM','ZW'};
       
     Set<String> countryCodeZero = new Set<String>{'AD','AE','AF','AG','AI','AL','AM','AN','AO','AQ','AS','AW','AZ','BA','BB','BD','BF','BG','BH','BI','BJ','BM','BN','BO','BS','BT','BV','BW','BY','BZ','CC','CD','CF','CG','CI','CK','CM','CU','CV','CX','DJ','DM','DO','EC','EE','EG','EH','ER','ET','FJ','FK','FM','GA','GD','GE','GF','GH','GI','GL','GM','GN','GP','GQ','GS','GT','GU','GW','GY','HM','HN','HT','IO','IQ','JM','JO','KE','KG','KH','KI','KM','KN','KY','LA','LB','LC','LK','LR','LT','LY','MA','MD','MG','MH','MK','ML','MM','MN','MO','MP','MQ','MR','MS','MT','MU','MV','MW','MZ','NA','NC','NE','NF','NG','NI','NR','NU','OM','PA','PE','PF','PG','PK','PM','PN','PR','PW','PY','QA','RE','RW','SB','SC','SD','SH','SJ','SL','SM','SN','SO','SR','ST','SV','SY','SZ','TC','TF','TG','TJ','TK','TL','TM','TO','TP','TT','TV','TZ','UG','UM','UZ','VA','VC','VG','VI','VU','WF','WS','YE','YT','ZM','ZW'};
        System.debug('**********' +countryCodeZero);
        For(Sampling__c S: Trigger.new){
        //Creating the Rules for Zipcodes that have to be larger than 0
        IF((S.Override__c == 'Yes') && (S.Zip_Postal_Code__c.length() > 0)){  
           
            IF(string.ISBLANK(S.Country__c))
            {         
                System.debug('Country is Blank');
                //Do something
            }ELSE IF(string.isNotBlank(S.Country__c)){ 
     IF(countryCodeZero.contains(S.Country__c)
    {
                System.debug('Success!')
                return true;
             }ELSE{
                System.debug('Failure')
                return false;
           }
      }
               
            IF(string.ISBLANK(S.City__c))
            {
             System.debug('City is blank');
                //Do something
            }ELSE IF(string.isNotBlank(S.City__c)){
               //Do Stuff
            }
    
   IF(string.ISBLANK(S.State_Province__c))
            {
               System.debug('Province is blank');
                //Do something
            }ELSE IF(string.isNotBlank(S.State_Province__c)){
                //Do stuff
            }
            IF(string.ISBLANK(S.Zip_Postal_Code__c))
            {
             System.debug('Zip code is blank');
                //Do something
            }ElSE IF(S.Zip_Postal_Code__c != NULL){
                    System.debug('Zipcode filled');
            }ElSE{
              System.debug('Zipcode is Empty');
               
            }
                
            }
        }
    }
}