• Kabb12
  • NEWBIE
  • 85 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 13
    Replies
Here is my test class its giving me test coverage of 68% please help me to get 100% coverage if possible  I am posting my trigger in next post 

Any help would be appreciated thanks in advance

@isTest
public class TestRegionName {
    static testMethod void testRegionName(){
     // Let's create our records from scratch!
     set<string> BanyuleC=new Set<string>{'3081', '3088', '3083', '3084', '3095', '3084', '3095', '3088', '3084', '3081', '3079', '3093', '3085', '3094', '3087'};
set<string> BassCoastS=new Set<string>{'3984', '3937', '3995', '3991', '3992', '3995', '3925', '3984', '3922', '3992', '3979', '3990', '3984', '3996', '3984', '3979', '3951', '3945', '3925', '3951', '3984', '3996', '3923', '3925', '3923', '3922', '3984', '3945'};
set<string> BawBawS=new Set<string>{'3825', '3833', '3823', '3871', '3818', '3233', '3820', '3825', '3821', '3825', '3824', '3822', '3840', '3818', '3821', '3825', '3822', '3833', '3854', '3953', '3981', '3825', '3833', '3816', '3821', '3820', '3833', '3816', '3956', '3988', '3824', '3832', '3831', '3832', '3831', '3821', '3833', '3987', '3833', '3988', '3825', '3950', '3825', '3833', '3824', '3856', '3833', '3953', '3833'};
set<string> BaysideC=new Set<string>{'3193', '3186', '3187', '3192', '3186', '3188', '3190', '3189', '3191'};
set<string> BenallaRC=new Set<string>{'3723', '3670', '3723', '3672', '3669', '3720', '3675', '3723', '3672', '3669', '3720', '3675', '3725', '3723', '3673', '3726', '3725', '3669', '3726', '3675', '3673', '3723', '3675', '3673', '3725', '3675', '3732', '3773', '3725', '3666', '3673', '3723', '3675', '3670', '3673', '3726', '3723', '3672', '3678', '3670', '3673'};
set<string> BrimbankC=new Set<string>{'3021', '3020', '3022', '3012', '3023', '3049', '3023', '3037', '3030', '3020', '3875', '3021', '3036', '3038', '3033', '3036', '3021', '3042', '3023', '3037', '3038', '3043'};
set<string> CampaspeS=new Set<string>{'3561', '3558', '3564', '3623', '3559', '3551', '3559', '3558', '3561', '3571', '3570', '3564', '3558', '3561', '3624', '3566', '3616', '3564', '3565', '3567', '3622', '3621', '3620', '3559', '3561', '3620', '3563', '3564', '3572', '3573', '3612', '3620', '3610', '3557', '3551', '3561', '3564', '3572', '3573', '3561', '3523', '3561', '3564', '3559', '3612', '3564', '3623', '3622', '3620', '3572', '3573', '3575', '3561', '3621', '3551', '3562', '3616', '3612', '3564', '3620', '3621'};
set<string> CardiniaS=new Set<string>{'3782', '3981', '3807', '3808', '3815', '3984', '3978', '3981', '3782', '3781', '3814', '3981', '3808', '3782', '3814', '3783', '3782', '3815', '3984', '3816', '3812', '3159', '3816', '3984', '3781', '3812', '3987', '3809', '3810', '3782', '3810', '3984', '3815', '3980', '3813', '3814', '3981'};
set<string> CaseyC=new Set<string>{'3807', '3806', '3977', '3978', '3177', '3805', '3803', '3976', '3806', '3977', '3975', '3156', '3805', '3804', '3807', '3805', '3912', '3980'};
set<string> CentralGoldfieldsS=new Set<string>{'3465', '3371', '3475', '3472', '3465', '3472', '3465', '3364', '3371', '3475', '3465', '3370', '3465', '3472', '3462', '3371', '3465', '3472', '3465', '3370', '3371', '3472', '3465', '3371', '3364', '3371'};
set<string> ColacOtwayS=new Set<string>{'3237', '3249', '3233', '3249', '3243', '3251', '3237', '3242', '3237', '3260', '3233', '3239', '3233', '3239', '3250', '3249', '3254', '3237', '3249', '3322', '3251', '3249', '3250', '3251', '3237', '3236', '3237', '3239', '3243', '3238', '3221', '3238', '3221', '3238', '3249', '3266', '3237', '3238', '3249', '3239', '3221', '3249', '3238', '3233', '3236', '3243', '3249', '3237', '3241', '3249', '3235', '3233', '3249', '3221', '3266', '3233', '3260', '3237', '3249', '3243', '3237', '3251', '3243', '3241', '3237'};
set<string> CorangamiteS=new Set<string>{'3249', '3268', '3323', '3260', '3265', '3260', '3361', '3268', '3266', '3260', '3249', '3239', '3260', '3239', '3260', '3266', '3268', '3322', '3251', '3268', '3271', '3325', '3265', '3249', '3323', '3249', '3265', '3266', '3237', '3266', '3265', '3268', '3366', '3239', '3265', '3325', '3324', '3266', '3268', '3265', '3249', '3268', '3270', '3249', '3360', '3269', '3271', '3260', '3267', '3266', '3260', '3361', '3265', '3249', '3264', '3260', '3268', '3325', '3269', '3237', '3352', '3249', '3237'};
set<string> DarebinC=new Set<string>{'3078', '3083', '3058', '3078', '3073', '3083', '3085', '3070', '3078', '3072', '3073', '3071'};
set<string> FrankstonC=new Set<string>{'3201', '3199', '3200', '3199', '3910', '3911', '3977', '3198'};
set<string> GannawarraS=new Set<string>{'3579', '3677', '3579', '3568', '3540', '3579', '3568', '3579', '3568', '3537', '3567', '3581', '3568', '3580', '3581', '3542', '3567', '3579', '3568', '3585', '3579', '3568', '3540', '3579', '3542', '3527', '3579', '3568', '3579'};
set<string> GlenEiraC=new Set<string>{'3204', '3165', '3187', '3163', '3162', '3145', '3161', '3162', '3165', '3185', '3163', '3204', '3163', '3183'};
set<string> GlenelgS=new Set<string>{'3305', '3312', '3304', '3305', '3302', '3312', '3303', '3312', '3301', '3305', '3311', '3315', '3303', '3311', '3305', '3304', '3312', '3309', '3304', '3312', '3305', '3302', '3304', '3303', '3691', '3304', '3310', '3315', '3312', '3315', '3285', '3292', '3315', '3301', '3285', '3303', '3312'};
set<string> GoldenPlainsS=new Set<string>{'3333', '3331', '3329', '3351', '3323', '3352', '3351', '3352', '3351', '3322', '3342', '3352', '3331', '3351', '3332', '3360', '3331', '3333', '3334', '3324', '3352', '3221', '3352', '3351', '3360', '3330', '3329', '3331', '3328', '3352'};
set<string> GrDandenongC=new Set<string>{'3175', '3164', '3174', '3171', '3172', '3173', '3175'};
set<string> GrBendigoC=new Set<string>{'3556', '3523', '3551', '3559', '3557', '3550', '3555', '3556', '3523', '3550', '3570', '3556', '3558', '3556', '3551', '3550', '3557', '3555', '3453', '3523', '3556', '3558', '3551', '3550', '3556', '3551', '3570', '3555', '3550', '3551', '3516', '3551', '3444', '3551', '3515', '3444', '3551', '3523', '3556', '3444', '3570', '3523', '3444', '3556', '3463'};
set<string> GreaterGeelongC=new Set<string>{'3221', '3212', '3340', '3216', '3220', '3227', '3215', '3216', '3219', '3214', '3227', '3222', '3214', '3215', '3220', '3218', '3216', '3215', '3223', '3212', '3224', '3211', '3221', '3218', '3222', '3216', '3219', '3220', '3214', '3226', '3225', '3212', '3223', '3215', '3219', '3223', '3321', '3225', '3219'};
set<string> HepburnS=new Set<string>{'3364', '3460', '3468', '3364', '3352', '3461', '3364', '3370', '3461', '3363', '3364', '3352', '3461', '3446', '3461', '3371', '3461', '3371', '3458', '3461', '3370', '3451', '3364', '3361', '3352', '3354', '3461', '3363', '3364', '3461', '3364', '3458', '3461', '3462', '3371', '3461', '3352', '3447', '3451', '3458', '3444', '3370', '3352', '3354', '3461'};
set<string> HindmarshS=new Set<string>{'3424', '3414', '3418', '3393', '3418', '3414', '3423', '3419', '3395', '3418', '3423', '3419', '3395', '3418', '3423', '3418'};
set<string> HobsonsBayC=new Set<string>{'3018', '3025', '3012', '3015', '3028', '3016'};
set<string> HorshamRC=new Set<string>{'3409', '3401', '3385', '3400', '3390', '3409'};
set<string> HumeC=new Set<string>{'3049', '3047', '3064', '3036', '3048', '3045', '3063', '3064', '3062', '3429', '3043', '3049', '3429'};
set<string> IndigoS=new Set<string>{'3691', '3688', '3747', '3685', '3749', '3685', '3695', '3683', '3682', '3737', '3691', '3682', '3691', '3695', '3691', '3747', '3687', '3749'};
set<string> KingstonC=new Set<string>{'3195', '3196', '3197', '3192', '3169', '3172', '3202', '3190', '3194', '3189', '3195', '3167', '3195', '3197', '3195'};
set<string> KnoxC=new Set<string>{'3153', '3155', '3156', '3180', '3156', '3178', '3787', '3179', '3152', '3154', '3156', '3152'};
set<string> LatrobeC=new Set<string>{'3971', '3825', '3870', '3844', '3842', '3857', '3971', '3871', '3840', '3844', '3854', '3870', '3840', '3825', '3869', '3844', '3840', '3871', '3971', '3825', '3840', '3844', '3824', '3825', '3856', '3825', '3869'};
set<string> LoddonS=new Set<string>{'3579', '3551', '3570', '3537', '3475', '3517', '3516', '3525', '3475', '3573', '3556', '3478', '3516', '3571', '3472', '3576', '3463', '3472', '3475', '3518', '3520', '3575', '3517', '3527', '3472', '3579', '3478', '3537', '3567', '3517', '3472', '3517', '3573', '3570', '3571', '3520', '3518', '3517', '3463', '3525', '3579', '3516', '3567', '3551', '3575', '3475', '3579', '3515', '3472', '3537', '3573', '3472', '3556', '3463', '3478', '3575', '3571', '3463', '3518', '3525', '3537', '3516'};
set<string> MacedonRangesS=new Set<string>{'3442', '3444', '3435', '3432', '3437', '3762', '3442', '3434', '3762', '3442', '3756', '3430', '3442', '3756', '3461', '3446', '3458', '3437', '3435', '3442', '3440', '3433', '3441', '3438', '3431', '3764', '3442', '3447', '3337', '3458', '3442'};
set<string> ManninghamC=new Set<string>{'3105', '3108', '3109', '3111', '3131', '3114', '3134', '3106', '3107', '3113', '3134', '3115'};

     set<string> AlpineS=new Set<string>{'3737', '3862', '3691', '3893', '3739', '3699', '3741', '3737', '3741', '3691', '3741', '3737', '3741', '3691', '3737', '3691', '3699', '3740', '3741', '3737', '3738', '3740', '3741', '3740', '3691', '3741', '3697', '3698', '3691', '3744', '3862', '3737'};

      List<Account> accounts = new List<Account>{};
   /* for(Integer i = 0; i < 4; i++){
        //Account a = new Account(Name = 'Test Account ',BillingPostalCode = '3009');
        Account a = new Account(Name = 'Test' + i,BillingPostalCode = '300'+i,LGA__c='');
      
        accounts.add(a);
        }*/

      Account acc1   = new Account();
      acc1.Name = 'Testing Region1';
      acc1.BillingPostalCode = '3001';
      acc1.LGA__c = 'a';
      accounts.add(acc1);
     
      Account acc2   = new Account();
      acc2.Name = 'Testing Region2';
      acc2.BillingPostalCode = '3002';
      acc2.LGA__c = 'b';
      accounts.add(acc2);
     
      Account acc3   = new Account();
      acc3.Name = 'Testing Region3';
      acc3.BillingPostalCode = '3003';
      acc3.LGA__c = 'c';
      accounts.add(acc3);
     
      Account acc4   = new Account();
      acc4.Name = 'Testing Region4';
      acc4.BillingPostalCode = '3004';
      acc4.LGA__c = 'd';
      accounts.add(acc4);
     
      Account acc5   = new Account();
      acc5.Name = 'Testing Region5';
      acc5.BillingPostalCode = '3005';
      acc5.LGA__c = 'e';
      accounts.add(acc5);
     
      Account acc6   = new Account();
      acc6.Name = 'Testing Region1';
      acc6.BillingPostalCode = '3006';
      acc6.LGA__c = 'aa';
      accounts.add(acc6);
     
  
     insert accounts;
     update accounts;
     Account accountresult= [Select Name,BillingPostalCode,LGA__c from Account where Id = :acc1.Id ];
        system.debug('******************************************************End Date: ' + acc1.LGA__c);
        system.assertEquals(accountresult.Name, accountresult.BillingPostalCode='Testing Region1',accountresult.LGA__c);
       
    // update accounts;
     
      
    }
}


  • April 29, 2014
  • Like
  • 0
Hi,

Just wondering if the trigger below is written properly? this trigger is looking for a newly entered BillingPostalCode value and then check this value against a given list of values if it matches it then updates a custom field Region name by code.

As you can see this trigger only works when a new record is created I would like to update regionName value for existing records too..... I would really help if someone can help, thanks

trigger regionName on Account (before insert) {
set<string> a=new Set<string>{'3125','3352','3014'};
for(Account myAccount: Trigger.new){
     if(myAccount.BillingPostalCode !=NULL){
         String s = myAccount.BillingPostalCode;
                if(a.contains(s)){
               
                string errMsg = 'This area belong to hume!';
                myAccount.regionName__c = 'ABC';
        }
   
     }
  }
}
  • April 16, 2014
  • Like
  • 0
I have written this trigger and when I write my test class I only get 67% coverage can someone help me write test class for this trigger please.....


trigger regionName2 on Account (before insert,before update) {
set<string> AlpineS=new Set<string>{'3737', '3862', '3691', '3893', '3739', '3699', '3741', '3737', '3741', '3691', '3741', '3737', '3741', '3691', '3737', '3691', '3699', '3740', '3741', '3737', '3738', '3740', '3741', '3740', '3691', '3741', '3697', '3698', '3691', '3744', '3862', '3737'};
set<string> EastGippslandS=new Set<string>{'3885', '3898', '3875', '3889', '3900', '3885', '3888', '3875', '3896', '3898', '3880', '3875', '3888', '3896', '3885', '3890', '3875', '3902', '3898', '3885', '3889', '3875', '3890', '3875', '3889', '3862', '3889', '3898', '3701', '3875', '3895', '3893', '3878', '3895', '3889', '3895', '3875', '3864', '3875', '3898', '3862', '3875', '3902', '3909', '3887', '3865', '3875', '3892', '3889', '3891', '3875', '3904', '3701', '3875', '3885', '3707', '3875', '3886', '3882', '3890', '3887', '3909', '3896', '3888', '3909', '3880', '3898', '3888', '3880', '3895', '3893', '3885', '3903', '3896', '3875', '3893', '3885', '3890', '3864', '3885', '3707', '3890', '3896', '3909', '3885', '3900', '3887', '3891', '3875', '3891', '3890', '3891', '3885', '3885', '3875'};
set<string> AraratRC=new Set<string>{'3377', '3375', '3379', '3361', '3294', '3469', '3293', '3381', '3351', '3381', '3351', '3375', '3351', '3293', '3351', '3381', '3271', '3379', '3377', '3373', '3378', '3272', '3378', '3272', '3378', '3373', '3378', '3377', '3379', '3272', '3378'};
set<string> BallaratC=new Set<string>{'3352', '3350', '3364', '3354', '3351', '3356', '3357', '3363', '3356', '3363', '3355'};
set<string> BanyuleC=new Set<string>{'3081', '3088', '3083', '3084', '3095', '3084', '3095', '3088', '3084', '3081', '3079', '3093', '3085', '3094', '3087'};
set<string> BassCoastS=new Set<string>{'3984', '3937', '3995', '3991', '3992', '3995', '3925', '3984', '3922', '3992', '3979', '3990', '3984', '3996', '3984', '3979', '3951', '3945', '3925', '3951', '3984', '3996', '3923', '3925', '3923', '3922', '3984', '3945'};
set<string> BawBawS=new Set<string>{'3825', '3833', '3823', '3871', '3818', '3233', '3820', '3825', '3821', '3825', '3824', '3822', '3840', '3818', '3821', '3825', '3822', '3833', '3854', '3953', '3981', '3825', '3833', '3816', '3821', '3820', '3833', '3816', '3956', '3988', '3824', '3832', '3831', '3832', '3831', '3821', '3833', '3987', '3833', '3988', '3825', '3950', '3825', '3833', '3824', '3856', '3833', '3953', '3833'};
set<string> BaysideC=new Set<string>{'3193', '3186', '3187', '3192', '3186', '3188', '3190', '3189', '3191'};
set<string> BenallaRC=new Set<string>{'3723', '3670', '3723', '3672', '3669', '3720', '3675', '3723', '3672', '3669', '3720', '3675', '3725', '3723', '3673', '3726', '3725', '3669', '3726', '3675', '3673', '3723', '3675', '3673', '3725', '3675', '3732', '3773', '3725', '3666', '3673', '3723', '3675', '3670', '3673', '3726', '3723', '3672', '3678', '3670', '3673'};
set<string> BrimbankC=new Set<string>{'3021', '3020', '3022', '3012', '3023', '3049', '3023', '3037', '3030', '3020', '3875', '3021', '3036', '3038', '3033', '3036', '3021', '3042', '3023', '3037', '3038', '3043'};
set<string> CampaspeS=new Set<string>{'3561', '3558', '3564', '3623', '3559', '3551', '3559', '3558', '3561', '3571', '3570', '3564', '3558', '3561', '3624', '3566', '3616', '3564', '3565', '3567', '3622', '3621', '3620', '3559', '3561', '3620', '3563', '3564', '3572', '3573', '3612', '3620', '3610', '3557', '3551', '3561', '3564', '3572', '3573', '3561', '3523', '3561', '3564', '3559', '3612', '3564', '3623', '3622', '3620', '3572', '3573', '3575', '3561', '3621', '3551', '3562', '3616', '3612', '3564', '3620', '3621'};
set<string> CardiniaS=new Set<string>{'3782', '3981', '3807', '3808', '3815', '3984', '3978', '3981', '3782', '3781', '3814', '3981', '3808', '3782', '3814', '3783', '3782', '3815', '3984', '3816', '3812', '3159', '3816', '3984', '3781', '3812', '3987', '3809', '3810', '3782', '3810', '3984', '3815', '3980', '3813', '3814', '3981'};
set<string> CaseyC=new Set<string>{'3807', '3806', '3977', '3978', '3177', '3805', '3803', '3976', '3806', '3977', '3975', '3156', '3805', '3804', '3807', '3805', '3912', '3980'};
set<string> CentralGoldfieldsS=new Set<string>{'3465', '3371', '3475', '3472', '3465', '3472', '3465', '3364', '3371', '3475', '3465', '3370', '3465', '3472', '3462', '3371', '3465', '3472', '3465', '3370', '3371', '3472', '3465', '3371', '3364', '3371'};
set<string> ColacOtwayS=new Set<string>{'3237', '3249', '3233', '3249', '3243', '3251', '3237', '3242', '3237', '3260', '3233', '3239', '3233', '3239', '3250', '3249', '3254', '3237', '3249', '3322', '3251', '3249', '3250', '3251', '3237', '3236', '3237', '3239', '3243', '3238', '3221', '3238', '3221', '3238', '3249', '3266', '3237', '3238', '3249', '3239', '3221', '3249', '3238', '3233', '3236', '3243', '3249', '3237', '3241', '3249', '3235', '3233', '3249', '3221', '3266', '3233', '3260', '3237', '3249', '3243', '3237', '3251', '3243', '3241', '3237'};
set<string> CorangamiteS=new Set<string>{'3249', '3268', '3323', '3260', '3265', '3260', '3361', '3268', '3266', '3260', '3249', '3239', '3260', '3239', '3260', '3266', '3268', '3322', '3251', '3268', '3271', '3325', '3265', '3249', '3323', '3249', '3265', '3266', '3237', '3266', '3265', '3268', '3366', '3239', '3265', '3325', '3324', '3266', '3268', '3265', '3249', '3268', '3270', '3249', '3360', '3269', '3271', '3260', '3267', '3266', '3260', '3361', '3265', '3249', '3264', '3260', '3268', '3325', '3269', '3237', '3352', '3249', '3237'};
set<string> DarebinC=new Set<string>{'3078', '3083', '3058', '3078', '3073', '3083', '3085', '3070', '3078', '3072', '3073', '3071'};
set<string> FrankstonC=new Set<string>{'3201', '3199', '3200', '3199', '3910', '3911', '3977', '3198'};
set<string> GannawarraS=new Set<string>{'3579', '3677', '3579', '3568', '3540', '3579', '3568', '3579', '3568', '3537', '3567', '3581', '3568', '3580', '3581', '3542', '3567', '3579', '3568', '3585', '3579', '3568', '3540', '3579', '3542', '3527', '3579', '3568', '3579'};
set<string> GlenEiraC=new Set<string>{'3204', '3165', '3187', '3163', '3162', '3145', '3161', '3162', '3165', '3185', '3163', '3204', '3163', '3183'};

for(Account myAccount: Trigger.new){
     if(myAccount.BillingPostalCode !=NULL){
         String s = myAccount.BillingPostalCode;
                if(AlpineS.contains(s)){
                 myAccount.LGA__c = 'Alpine S';
                }
                else if(EastGippslandS.contains(s)){
                 myAccount.LGA__c = 'East Gippsland S';
                }
                else if(AraratRC.contains(s)){
                 myAccount.LGA__c = 'Ararat RC';
                }
                else if(BallaratC.contains(s)){
                 myAccount.LGA__c = 'Ballarat C';
                }
                else if(BanyuleC.contains(s)){
                 myAccount.LGA__c = 'Banyule C';
                }
                else if(BassCoastS.contains(s)){
                 myAccount.LGA__c = 'Bass Coast S';
                }
                else if(BawBawS.contains(s)){
                 myAccount.LGA__c = 'Baw Baw S';
                }
                else if(BaysideC.contains(s)){
                 myAccount.LGA__c = 'Bayside C';
                }
               
                else if(BenallaRC.contains(s)){
                 myAccount.LGA__c = 'Benalla RC';
                }
                else if(BrimbankC.contains(s)){
                 myAccount.LGA__c = 'Brimbank C';
                }
                else if(CampaspeS.contains(s)){
                 myAccount.LGA__c = 'Campaspe S';
                }
                else if(CardiniaS.contains(s)){
                 myAccount.LGA__c = 'Cardinia S';
                }
                else if(CaseyC.contains(s)){
                 myAccount.LGA__c = 'Casey C';
                }
                else if(CentralGoldfieldsS.contains(s)){
                 myAccount.LGA__c = 'Central Goldfields S';
                }
                else if(ColacOtwayS.contains(s)){
                 myAccount.LGA__c = 'Colac Otway S';
                }
                else if(CorangamiteS.contains(s)){
                 myAccount.LGA__c = 'Corangamite S';
                }
                else if(DarebinC.contains(s)){
                 myAccount.LGA__c = 'Darebin C';
                }
                else if(FrankstonC.contains(s)){
                 myAccount.LGA__c = 'Frankston C';
                }
                else if(GannawarraS.contains(s)){
                 myAccount.LGA__c = 'Gannawarra S';
                }
                else if(GlenEiraC.contains(s)){
                 myAccount.LGA__c = 'GlenEira C';
                }
                else
                {
                    //myAccount.addError('This area not belong to hume!');
                    myAccount.LGA__c = 'Not a Valid PostCode';
                }
        } // end main if
//update myAccount;

     }// end for
  
  }
  • April 28, 2014
  • Like
  • 0
Hi,

Just wondering if the trigger below is written properly? this trigger is looking for a newly entered BillingPostalCode value and then check this value against a given list of values if it matches it then updates a custom field Region name by code.

As you can see this trigger only works when a new record is created I would like to update regionName value for existing records too..... I would really help if someone can help, thanks

trigger regionName on Account (before insert) {
set<string> a=new Set<string>{'3125','3352','3014'};
for(Account myAccount: Trigger.new){
     if(myAccount.BillingPostalCode !=NULL){
         String s = myAccount.BillingPostalCode;
                if(a.contains(s)){
               
                string errMsg = 'This area belong to hume!';
                myAccount.regionName__c = 'ABC';
        }
   
     }
  }
}
  • April 16, 2014
  • Like
  • 0

Hello. I want to know how can i create a Map<String, CustomObject> where the key will not be the Id of the custom field but the Name field and without using a list and going through each record and puting in the map a pair.

If I use Map<String, CustomObject__c> myMap = new Map<String, CustomObject__c>([Select z.Name, z.Id From CustomObject__c z]); i have a map where the key is my CustomObject.Id and I want it to be CustomObject.Name.