• brijender singh rathore 16
  • NEWBIE
  • 25 Points
  • Member since 2017

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 10
    Questions
  • 10
    Replies
Hi
I have created an apex trigger to update contact address when the account address is changed. The code worked fine for already created accounts, but when I have created a new account the following error was thrown and I was not able to save the account. Please help me.

Error: updateContact: execution of AfterInsert caused by: System.NullPointerException: Attempt to de-reference a null object Trigger.updateContact: line 33, column 1​
 
trigger updateContact on Account (after insert, after update) {
    List<Contact> contactsForUpsert = New List<Contact>();

    Map<Id, Contact> contactsByAccountId = new Map<Id, Contact>();
    List<Contact> contacts = [SELECT Id,
                                     AccountId,
                                     mailingstreet,
                                     mailingcity,
                                     mailingstate,
                                     mailingpostalcode
                            FROM Contact WHERE AccountId IN: Trigger.newMap.keySet()];
    for (Contact cont: contacts) {
        contactsByAccountId.put(cont.accountId, cont);
    }

    for (Account account: Trigger.new) {

        Account old;
        if (Trigger.isUpdate) {
            old = Trigger.oldMap.get(account.Id);
        }

        Boolean isShippingAddressChangedOrNew = Trigger.isInsert ? true :
                                                (   account.ShippingStreet != old.ShippingStreet
                                                 || account.ShippingCity != old.ShippingCity
                                                 || account.ShippingState != old.ShippingState
                                                 || account.ShippingPostalCode != old.ShippingPostalCode
                                                 || account.ShippingCountry != old.ShippingCountry) ? true : false;

        if (isShippingAddressChangedOrNew) {
            Contact relatedContact = contactsByAccountId.get(account.Id);
           
            relatedContact.mailingstreet     = account.Shippingstreet;
            relatedContact.mailingcity       = account.Shippingcity;
            relatedContact.mailingstate      = account.Shippingstate;
            relatedContact.mailingpostalcode = account.shippingpostalcode;
            contactsForUpsert.add(relatedContact);
        

    }

    try {
        upsert contactsForUpsert;
    } catch(Dmlexception e) {
        System.debug(LoggingLevel.ERROR, 'Contact insert from createopp.trigger has failed with message:' + e.getMessage());
    }
}
}

 
  • January 23, 2018
  • Like
  • 0
-----------------------------------------------------------------------CONTROLLER CLASS--------------------------------------------------------------------------------------------------
 
public class QuickBackgroundCheckOrderCl {
 
  public string sOrderId = ApexPages.currentPage().getParameters().get('tfa_2935');
  //public String sPackageId = ApexPages.currentPage().getParameters().get('tfa_3025');
  public String sServiceorder_employment_package {get;set;}
  public String sServiceorder_education_package  {get;set;}
  public String sServiceorder_license_package  {get;set;}
  public String sServiceorder_reference_package  {get;set;}
  public String sServiceorder_international_employment_package {get;set;}
  public String sServiceorder_international_degree_package {get;set;}
  public String sServiceorder_employment_a_la_carte {get;set;}
  public String sServiceorder_education_a_la_carte  {get;set;}
  public String sServiceorder_license_a_la_carte  {get;set;}
  public String sServiceorder_reference_a_la_carte  {get;set;}
  public String sServiceorder_international_employment_a_la_carte {get;set;}
  public String sServiceorder_international_degree_a_la_carte {get;set;}
  public integer intEmploymentPackageCount = 0;
  public integer intEducationPackageCount = 0;
  public integer intLicensePackageCount = 0;
  public integer intReferencePackageCount = 0;
  public integer intInternationalEmploymentPackageCount = 0;
  public integer intInternationalDegreePackageCount = 0;
 
  public string sAccountId = ApexPages.currentPage().getParameters().get('tfa_3012');
  public string sPartnerId = ApexPages.currentPage().getParameters().get('tfa_22');
  public string sAnnualSalary = ApexPages.currentPage().getParameters().get('tfa_21511');
  public string sOrderNumber = ApexPages.currentPage().getParameters().get('tfa_2998');
  public string bFCRAEmploymentRelatedChecks = ApexPages.currentPage().getParameters().get('tfa_21508');
  public string bFCRAInvestigativeConsumerReports = ApexPages.currentPage().getParameters().get('tfa_21509');
  public string bCertificationRegardingNoLegalAdvice = ApexPages.currentPage().getParameters().get('tfa_21510');
  public string bFCRAPermissble = ApexPages.currentPage().getParameters().get('tfa_21512');
  public string bCreditReport = ApexPages.currentPage().getParameters().get('tfa_21513');
  public string spackagename {get;set;}
  public boolean bLicCount {set;get;}
  public boolean bDegCount {set;get;}
  public boolean bEmpCount {set;get;}
  public boolean bRefCount {set;get;}
  public integer iDegCount {get;set;}
  public integer iEmpCount {get;set;}
  public integer iRefCount {get;set;}
  public integer iLicCount {get;set;}
  public integer iInternationalDegcount {get;set;}
  public Integer itotaldegree {get;set;}
  public Integer itotalemp {get;set;}
  public boolean bInternationalDegcount {set;get;}
  public integer iInternationalEmpCount {get;set;}
  public boolean bInternationalEmpCount {set;get;}
  public string scountry {get;set;}
  public string sState {get;set;}
  public string sDLState {get;set;}
  public string sDLNumber {get;set;}
  public List<BGC_Order__c> lstBGCOrder {get;set;}
  public string sFirstName {set;get;}
  public string sLastName {set;get;}
  public string sMiddleName {set;get;}
  public string sGovermentIdType {set;get;}
  public string sGovermentIdNumber {set;get;}
  public string sEmail {set;get;}
  public string sPhoneNumber{set;get;}
  public string sUnitNumber {get; set;}
  public string sAddress {set;get;}
  public string sCity {set;get;}
  public string sDegreestate {set;get;}
  public date dDateOfBirth {set;get;}
  public string sZipCode {set;get;}
  public string sService {set;get;}
  public List<Contact> lstContact {get;set;}
  public string sNotesPreEmlpoy {get;set;}
  public boolean bYes {get;set;}
  public string sFirstAlterName {get;set;}
  public string sCurrentEmployer {get;set;}
  public string sLastAlterName {get;set;}
  public string sEmploystate {get;set;}
  public string sEmployCountry {get;set;}
  public string sDegree {get;set;}
  public string sDegreeCountry {get;set;}
  public string sAttendance {get;set;}
  public string sRequestUpdate {get;set;}
  public string sCommonform {get;set;}
  public string sUnitNumberMailing {get;set;}
  public string sAddressMailing {get;set;}
  public string sCityMailing {get;set;}
  public string stateMailing {get;set;}
  public string sZipCodeMailing {get;set;}
  public string sCountryMailing {get;set;}
  public Integer iTotalInternationalLicense{get;set;}
  public List<BGC_Degree_Intake__c> lstBGCDegreeList {get; set;}
  public List<BGC_Employment_Intakes__c> lstBGCEmploymentList {get; set;}
  public List<BGC_Reference_Intake__c> lstBGCReferenceList {get; set;}
  public List<BGC_License_Intake__c> lstBGCLicenseList {get; set;}
  public BGC_S_O_Individual__c  bgindivisual {get;set;}
    
  public List<SelectOption> getGovIdType() {
    List<SelectOption> options = new List<SelectOption>();
    options.add(new SelectOption('Please Select','Please Select'));
    options.add(new SelectOption('Social Security Number','Social Security Number'));
    options.add(new SelectOption('Alien Number','Alien Number'));
    options.add(new SelectOption('I-94 Number','I-94 Number'));
    options.add(new SelectOption('Other','Other'));
    return options;
  }
 
  public List<SelectOption> getDegree() {
    List<SelectOption> options = new List<SelectOption>();
    options.add(new SelectOption('Please Select...','Please Select...'));
    options.add(new SelectOption('High School Diploma','High School Diploma'));
    options.add(new SelectOption('Associates','Associates'));
    options.add(new SelectOption('Bachelors','Bachelors'));
    options.add(new SelectOption('Certificate','Certificate'));
    options.add(new SelectOption('PHD','PHD'));
    options.add(new SelectOption('Other','Other'));
    return options;
  }
    
  public List<SelectOption> getItems() {
    List<SelectOption> options = new List<SelectOption>();
    options.add(new SelectOption('Yes','Yes'));
    options.add(new SelectOption('No','No'));
    return options;
  }
 
  public List<SelectOption> getItem() {
    List<SelectOption> options = new List<SelectOption>();
    options.add(new SelectOption('true','Yes'));
    options.add(new SelectOption('false','No'));
    return options;
  }
  public List<SelectOption> getitemcontact() {
    List<SelectOption> options = new List<SelectOption>();
    options.add(new SelectOption('true','Yes'));
    options.add(new SelectOption('false','No'));
    return options;
  }
    
  public QuickBackgroundCheckOrderCl(){
    spackagename = ApexPages.currentPage().getParameters().get('tfa_3026');
    if(!Test.IsRunningTest()){
      if(salesforcecl.IsClientCommunity()) {
        sRequestUpdate = Salesforcecl.getCommunityUrl +'/main/BGCRequestUpdate_community?';
        sCommonform = Salesforcecl.getCommunityUrl +'/main/015?fcf=00l80000001K9Gl';
      }
      else {
        sRequestUpdate = Salesforcecl.getPortalUrl +'main/BGCRequestUpdate?';
        sCommonform = Salesforcecl.getPortalUrl +'main/015?fcf=00l80000001K9Gl';
      }
    }
    if (sOrderId != null){
      bYes = false;
      sAttendance = 'No';
      sGovermentIdType = 'Social Security Number';
      iDegCount = integer.valueof(ApexPages.currentPage().getParameters().get('tfa_2181'));
      iEmpCount = integer.valueof(ApexPages.currentPage().getParameters().get('tfa_2187'));
      iRefCount = integer.valueof(ApexPages.currentPage().getParameters().get('tfa_2964'));
      iLicCount = integer.valueof(ApexPages.currentPage().getParameters().get('tfa_2920'));
      System.debug(integer.valueof(ApexPages.currentPage().getParameters().get('tfa_6793')));
      iInternationalDegcount = integer.valueof(ApexPages.currentPage().getParameters().get('tfa_6793'));
      iInternationalEmpCount = integer.valueof(ApexPages.currentPage().getParameters().get('tfa_6776'));
      itotaldegree = iDegCount+ iInternationalDegcount;
      itotalemp = iEmpCount+ iInternationalEmpCount;
      lstBGCDegreeList = new List<BGC_Degree_Intake__c>();
      lstBGCEmploymentList = new List<BGC_Employment_Intakes__c>();
      lstBGCReferenceList = new List<BGC_Reference_Intake__c>();
      lstBGCLicenseList = new List<BGC_License_Intake__c>();
      List<BGC_S_O_Individual__c> lstindivisual = new List<BGC_S_O_Individual__c>();
      List<BGC_S_O_Individual__c > lstbsoi = [SELECT Id, Name, Quantity__c,Package__c, Minimum_Quantity__c, Service_Name__c, Selected_Service__c FROM BGC_S_O_Individual__c WHERE BGC_Order__c = :sOrderId AND Service_Name__c != null AND BGC_Order__c != Null AND Selected_Service__c != NUll ];
      for(BGC_S_O_Individual__c oBGC_S_O_Individual: lstbsoi) {
        if(oBGC_S_O_Individual.Service_Name__c.tolowercase().contains('employment verification') && !oBGC_S_O_Individual.Service_Name__c.tolowercase().contains('international')){
          if(oBGC_S_O_Individual.package__c) {
             sServiceorder_employment_package = oBGC_S_O_Individual.Id;
             intEmploymentPackageCount = intEmploymentPackageCount + integer.valueof(oBGC_S_O_Individual.Minimum_Quantity__c);
           }
           else {
             sServiceorder_employment_a_la_carte = oBGC_S_O_Individual.Id;
           }
        }
        else if(oBGC_S_O_Individual.Service_Name__c.tolowercase().contains('education verification')){
          if(oBGC_S_O_Individual.package__c) {
            sServiceorder_education_package = oBGC_S_O_Individual.Id;
            intEducationPackageCount = intEducationPackageCount + integer.valueof(oBGC_S_O_Individual.Minimum_Quantity__c);
          }
          else {
            sServiceorder_education_a_la_carte = oBGC_S_O_Individual.Id;
          }
        }
        else if(oBGC_S_O_Individual.Service_Name__c.tolowercase().contains('license verification') || oBGC_S_O_Individual.Service_Name__c.tolowercase().contains('international license') || oBGC_S_O_Individual.Service_Name__c.tolowercase().contains('professional license') ){
          if(oBGC_S_O_Individual.package__c) {
            sServiceorder_license_package = oBGC_S_O_Individual.Id;
            intLicensePackageCount = intLicensePackageCount + integer.valueof(oBGC_S_O_Individual.Minimum_Quantity__c);
          }
          else {
            sServiceorder_license_a_la_carte = oBGC_S_O_Individual.Id;
          }
        }
        else if(oBGC_S_O_Individual.Service_Name__c.tolowercase().contains('professional reference') || oBGC_S_O_Individual.Service_Name__c.tolowercase().contains('international reference')){
          if(oBGC_S_O_Individual.package__c) {
            sServiceorder_reference_package = oBGC_S_O_Individual.Id;
            intReferencePackageCount = intReferencePackageCount + integer.valueof(oBGC_S_O_Individual.Minimum_Quantity__c);
          }
          else {
            sServiceorder_reference_a_la_carte = oBGC_S_O_Individual.Id;
          }
        }
        else if(oBGC_S_O_Individual.Service_Name__c.tolowercase().contains('international employment verification')) {
          if(oBGC_S_O_Individual.package__c) {
            sServiceorder_international_employment_package = oBGC_S_O_Individual.Id;
            intInternationalEmploymentPackageCount = intInternationalEmploymentPackageCount + integer.valueof(oBGC_S_O_Individual.Minimum_Quantity__c);
          }
          else {
            sServiceorder_international_employment_a_la_carte = oBGC_S_O_Individual.Id;
          }
        }
        else if(oBGC_S_O_Individual.Service_Name__c.tolowercase().contains('international degree verification')){
          if(oBGC_S_O_Individual.package__c) {
            sServiceorder_international_degree_package = oBGC_S_O_Individual.Id;
            intInternationalDegreePackageCount = intInternationalDegreePackageCount + integer.valueof(oBGC_S_O_Individual.Minimum_Quantity__c);
          }
          else {
            sServiceorder_international_degree_a_la_carte = oBGC_S_O_Individual.Id;
          }
        }
      }
      if(iDegCount != null && iDegCount != 0){
        bDegCount = true;
        for(Integer i = 1; i <= iDegCount; i++){
          if(intEducationPackageCount > 0) {
            lstBGCDegreeList.add(new BGC_Degree_Intake__c(Provided_Degree_Earned__c = '', Provided_Major_Minor__c = '', Provided_School_End__c = null, Provided_Degree_Awarded_Date__c = null, School_Name__c = '', School_Phone__c = '', School_Fax__c = '', School_Address__c = '', School_City__c = '', School_Country__c = null, Provided_School_Start__c = null, School_State_Providence__c = null, Background_Check_Order__c = sOrderId, Classification__c = '', Attendance_Only__c =false, Service_Ordered__c = sServiceorder_education_package));
            intEducationPackageCount = intEducationPackageCount - 1;
          }
          else {
            lstBGCDegreeList.add(new BGC_Degree_Intake__c(Provided_Degree_Earned__c = '', Provided_Major_Minor__c = '', Provided_School_End__c = null, Provided_Degree_Awarded_Date__c = null, School_Name__c = '', School_Phone__c = '', School_Fax__c = '', School_Address__c = '', School_City__c = '', School_Country__c = null, Provided_School_Start__c = null, School_State_Providence__c = null, Background_Check_Order__c = sOrderId, Classification__c = '', Attendance_Only__c =false, Service_Ordered__c = sServiceorder_education_a_la_carte));
          }
        }
      }
      else {
        bDegCount = false;
      }
      if(iInternationalDegcount != null && iInternationalDegcount != 0){
        bDegCount = true;
        for(Integer i = 1; i <= iInternationalDegcount; i++){
          if(intInternationalDegreePackageCount > 0) {
            lstBGCDegreeList.add(new BGC_Degree_Intake__c(Provided_Degree_Earned__c = '', Provided_Major_Minor__c = '', Provided_School_End__c = null, Provided_Degree_Awarded_Date__c = null, School_Name__c = '', School_Phone__c = '', School_Fax__c = '', School_Address__c = '', School_City__c = '', School_Country__c = null, Provided_School_Start__c = null, School_State_Providence__c = null, Background_Check_Order__c = sOrderId, Classification__c = '', Attendance_Only__c =false, Service_Ordered__c = sServiceorder_international_degree_package));
            intInternationalDegreePackageCount = intInternationalDegreePackageCount - 1;
          }
          else {
            lstBGCDegreeList.add(new BGC_Degree_Intake__c(Provided_Degree_Earned__c = '', Provided_Major_Minor__c = '', Provided_School_End__c = null, Provided_Degree_Awarded_Date__c = null, School_Name__c = '', School_Phone__c = '', School_Fax__c = '', School_Address__c = '', School_City__c = '', School_Country__c = null, Provided_School_Start__c = null, School_State_Providence__c = null, Background_Check_Order__c = sOrderId, Classification__c = '', Attendance_Only__c =false, Service_Ordered__c = sServiceorder_international_degree_a_la_carte));
          }
        }
      }
      else {
        bInternationalDegcount = false;
      }
     
User-added image

I WANT TO MAKE CITY FIELD REQUIRED AND I HAVE MAKE IT REQUIRED BY ADDING THE CODE ON LINE 704 AND 705 BUT WHEN WE ARE ADDING ONLY  BLANK SPACES ON THE FIELD IT IS TAKING THEM AS A TEXT AND CREATING RECORD.SO PLEASE HELP.

POSTING THE CODE I USED


 
                <td class="ColLabel"><apex:outputText escape="false"  value="City"/><span class="required">*</span></td>
                <td class="ColValue"><apex:inputText value="{!sEmpCity}" maxlength="50" required="true"/></td>
              </tr>
I want regex for this format and filter out 123456 if match the current format
PO # 123456
PO# 123456
PO #123456
P.O. # 123456
P.O.# 123456
P.O. #123456

We have to filter substring from string notes__c field. my regex is only working for PO #123456 and P.O. #123456
tried PO# (\\S+)\\s not working
Matcher rm = r.matcher(oOrder.Notes__c); 
Pattern r = Pattern.compile('PO #(\\S+)\\s'); 

if(rm.find()) {
 string res2 = rm.group(1); 
oOrder.test__c = res2; 
}

 
This class is written for a VF page which will search contacts from contact objects when search button is clicked and when contact is selected it will display dispensory items which are in lookup with contacts (API - patient__c).when one or multiple dispensory items are selected by checkboxes and clicked on submit button  it will perform some operations.

CONTROLLER CLASS

 
public class SearchController {
  public List<contact> searchResults {get; set;}
  public Contact oContact {get; set;}
  public Dispensary_Item__c oDispensaryItem {get; set;}
  public List<string> lstProductId {get; set;}
  public List<string> lstOppId {get; set;}
  public boolean isList {get; set;}
  public string sPatientLastName {get; set;}
  public string sPatientAccountId {get; set;}

  public SearchController(ApexPages.StandardController controller) {
    oDispensaryItem = new Dispensary_Item__c();
    lstProductId = new List<string>();
    SearchResults = new List<contact>();
    SearchResults.clear();
    lstOppId = new List<string>();
    isList = false;
    sPatientLastName = '';
  }

  public PageReference search() {
    SearchResults.clear();
    sPatientLastName = '';
    sPatientAccountId = '';
    SearchResults = [SELECT Id, Name, LastName, FirstName,account.id, Accountid, (SELECT Id, Name, IsChecked__c, Opportunity__c, Practice__c, Product__c, Quantity__c, Price__c FROM Dispensary_Items__r) FROM contact WHERE Id = :oDispensaryItem.Patient__c Order By Name LIMIT 1];
    if(SearchResults.size() > 0) {
      List<Dispensary_Item__c> lstTempDispensaryItem = new List<Dispensary_Item__c>();
      lstTempDispensaryItem.addAll(SearchResults.get(0).Dispensary_Items__r);
      sPatientLastName = SearchResults.get(0).LastName;
      sPatientAccountId = SearchResults.get(0).AccountId;
      if(lstTempDispensaryItem.size() > 0) {
        isList = true;
        for(Dispensary_Item__c oDispItem : lstTempDispensaryItem) {
          oDispItem.IsChecked__c = false;
        }
      }
      else {
        ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING,'Related Dispensary Item not found.'));
      }
    }
    else {
      ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING,'No record found.'));
      SearchResults.clear();
    }
    return null;
  }

  public PageReference processSelected() {
    string sInsertedOpp = '';
    List<string> lstDispensaryItemId = new List<string>();
    List<Dispensary_Item__c> lstTempDispensaryItem = new List<Dispensary_Item__c>();
    for(Contact oContact : SearchResults) {
      lstTempDispensaryItem.addAll(oContact.Dispensary_Items__r);
    }
    List<Dispensary_Item__c> lstDispensaryItem = new List<Dispensary_Item__c>();
    for(Dispensary_Item__c oDispensaryItem : lstTempDispensaryItem){
      if(oDispensaryItem.IsChecked__c) {
        lstDispensaryItem.add(oDispensaryItem);
        lstDispensaryItemId.add(oDispensaryItem.Id);
        lstProductId.add(oDispensaryItem.Product__c);
        lstOppId.add(oDispensaryItem.Opportunity__c);
      }
    }
    Set<string> setProduct = new Set<string>();
    setProduct.addAll(lstProductId);
    if(setProduct.size() != lstProductId.size()) {
      ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING,'Please select unique Dispensary Product Item.'));
      lstProductId.clear();
      return null;
    }
    if(lstDispensaryItem.size() > 0) {
      String sQuery = 'SELECT Id';
      Set<String> lstFields = new Set<String>();
      Map<String,Schema.SObjectType> schemaMap = Schema.getGlobalDescribe();
      Schema.SObjectType sobjType = schemaMap.get('Opportunity');
      Schema.DescribeSObjectResult r = sobjType.getDescribe();
      Map <String, Schema.SObjectField> fieldMap = r.fields.getMap();
      for(Schema.SObjectField sfield : fieldMap.Values()){
        schema.describefieldresult dfield = sfield.getDescribe();
        if(dfield.isCreateable()) {
          lstFields.add(String.valueOf(dfield.getname()));
          sQuery = sQuery + ', ' + String.valueOf(dfield.getname());
        }
      }
      sQuery = sQuery + ' FROM Opportunity WHERE Id in (';
      if(lstOppId.size() > 0) {
        integer intCount = 1;
        for(string oString : lstOppId) {
          if(intCount < lstOppId.size()) {
            sQuery = sQuery + '\''+oString+'\',';
          }
          else {
            sQuery = sQuery + '\''+oString+'\')';
          }
          intCount = intCount + 1;
        }
      }
      sQuery = sQuery + ' Order By CreatedDate DESC LIMIT 1';
      List<SObject> lstOpportunity = Database.query(sQuery);
      Sobject oOppnew = sobjType.newSobject();
      if(lstOpportunity.size() > 0) {
        SObject oOpportunity = lstOpportunity.get(0);
        for(String sField : lstFields) {
          if(sField != 'OwnerId' && sField != 'Amount' && sField != 'Create_Dispensary_Items__c'  && sField != 'Dispensary_Items_Created__c' && sField != 'StageName' && sField != 'Priority__c' && sField != 'Name' && sField != 'Source__c' && sField != 'CloseDate' && sField != 'Tracking_Number__c' && sField != 'AccountId') {
            oOppnew.put(sField, oOpportunity.get(sField));
          }
          else if(sField == 'Create_Dispensary_Items__c') {
            oOppnew.put('Create_Dispensary_Items__c', false);
          }
          else if(sField == 'Priority__c') {
            oOppnew.put('Priority__c', 'Other');
          }
          else if(sField == 'Name') {
            oOppnew.put('Name', sPatientLastName);
          }
          else if(sField == 'Source__c') {
            oOppnew.put('Source__c', '');
          }
          else if(sField == 'CloseDate') {
            oOppnew.put('CloseDate', Date.valueOf(System.now()));
          }
          else if(sField == 'StageName') {
            oOppnew.put('StageName', 'Order Received');
          }
          else if(sField == 'Tracking_Number__c') {
            oOppnew.put('Tracking_Number__c', '');
          }
          else if(sField == 'AccountId') {
            oOppnew.put('AccountId', sPatientAccountId);
          }
        }
        oOppnew.put('IsRefillOpportunity__c', true);
        insert oOppnew;
        if(oOppnew.id != null) {
          sInsertedOpp = oOppnew.Id;
          List<Opportunity> lstOpportunityPriceBook = [SELECT Id, Pricebook2Id FROM Opportunity WHERE Id = :oOppnew.Id AND Pricebook2Id != null LIMIT 1];
          if(lstOpportunityPriceBook.size() > 0) {
            List<PricebookEntry> lstPricebookEntry = [SELECT Id, Name, Pricebook2Id, Product2Id FROM PricebookEntry where  IsActive = true AND Product2Id in: lstProductId AND Pricebook2Id =: lstOpportunityPriceBook.get(0).Pricebook2Id];
            if(lstPricebookEntry.size() > 0) {
              Map<string, string> mapPriEntry = new Map<string, string>();
              for(PricebookEntry oPricebookEntry : lstPricebookEntry) {
                mapPriEntry.put(oPricebookEntry.Product2Id, oPricebookEntry.Id);
              }
              if(!mapPriEntry.isEmpty()) {
                List<OpportunityLineItem> lstOppItemnew = new List<OpportunityLineItem>();
                for(Dispensary_Item__c oDispensaryItem : lstDispensaryItem) {
                  OpportunityLineItem oOpportunityLineItem = new OpportunityLineItem();
                  oOpportunityLineItem.OpportunityId = oOppnew.Id;
                  if(mapPriEntry.containsKey(oDispensaryItem.Product__c)) {
                    oOpportunityLineItem.PricebookEntryId = mapPriEntry.get(oDispensaryItem.Product__c);
                  }
                  oOpportunityLineItem.UnitPrice = oDispensaryItem.Price__c;
                  oOpportunityLineItem.Quantity = oDispensaryItem.Quantity__c;
                  lstOppItemnew.add(oOpportunityLineItem);
                }
                if(lstOppItemnew.size() > 0) {
                  insert lstOppItemnew;
                }
                oOppnew.put('Create_Dispensary_Items__c', true);
                update oOppnew;
              }
            }
          }
        }
      }
    }
    if(sInsertedOpp != null && sInsertedOpp != '') {
      ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO,'Opportunity has been created: '+sInsertedOpp));
    }
    return null;
  }
}
NAME OF VF PAGE - Refill_for_Patients

MY TEST CLASS WITH ONY 36% CODE COVERAGE.
 
@isTest (SeeAllData = true)
private class SearchController_Test{
  static void setupTestData(){
    test.startTest();
    String strRecordTypeId = [Select Id From RecordType Where SobjectType = 'account' and Name = 'Practice'].Id;
    account acc = new Account(Name='Test Account', Type = 'Customer', BillingCity = 'California', BillingPostalCode = '90001', BillingState = 'California', BillingStreet = 'Test', ShippingCity = 'California', ShippingPostalCode = '90001', ShippingState = 'California', ShippingStreet = 'Test', NPI__c = '123456', DEA__c = '1234567');
    insert acc;
    String conRecordTypeId = [Select Id From RecordType Where SobjectType = 'contact' and Name = 'Patient'].Id;
    Contact contact_Obj = new Contact(AccountId = acc.id, LastName = 'LastName515', RecordTypeId = conRecordTypeId);
    Insert contact_Obj;
    Opportunity oOpportunity = new Opportunity(Name = 'test', AccountId = acc.Id, New_or_Existing_Business__c = 'New Business', Patient__c = contact_Obj.Id, Doctor__c = acc.Id, Priority__c = 'Other', Bill_To_del2__c = 'BillToChooseClinic', Ship_To_del1__c = 'ShipToChooseClinic', Shipping_Preference__c = 'Medallian Free 1', StageName = 'Order Received', CloseDate = Date.Today(), Bill_To_del1__c = acc.Id, Ship_To_Clinic__c = acc.Id, Clinic__c = acc.Id, Pharmacy_Printed__c = true);
    insert oOpportunity;
    Dispensary_Item__c dispensary_item_Obj = new Dispensary_Item__c(DOB__c = Date.today(), NPI__c = 'NPI__c489', StickIt_Label_Printed__c = false, Opportunity__c = oOpportunity.id, Patient_History_Reviewed__c = false, Patient_Gender__c = 'Male', Pharmacy_Printed__c = false, Non_CPC_Requested__c = false, PT_Refused_Counseling__c = false, IsAllergy__c = false, Prescription_s_Attached__c = false, Awaiting_Information_Send_Notification__c = false, On_Backorder_Send_Notification__c = false, Too_Soon_To_Refill_Send_Notification__c = false, Awaiting_Payment_Send_Notification__c = false, IsChecked__c = true);
    Insert dispensary_item_Obj; 
    test.stopTest();
  }
  static testMethod void test_search_UseCase1(){
    List<Contact> contact_Obj  =  [SELECT AccountId,LastName from Contact];
    System.assertEquals(true,contact_Obj.size()>0);
    List<Dispensary_Item__c> dispensary_item_Obj  =  [SELECT DOB__c,NPI__c,StickIt_Label_Printed__c,Opportunity__c,Patient_History_Reviewed__c,Patient_Gender__c,Pharmacy_Printed__c,Non_CPC_Requested__c,PT_Refused_Counseling__c,IsAllergy__c,Prescription_s_Attached__c,Awaiting_Information_Send_Notification__c,On_Backorder_Send_Notification__c,Too_Soon_To_Refill_Send_Notification__c,Awaiting_Payment_Send_Notification__c, Patient__c, IsChecked__c from Dispensary_Item__c];
    System.assertEquals(true,dispensary_item_Obj.size()>0);
    SearchController obj01 = new SearchController(new ApexPages.StandardController(contact_Obj[0]));
    obj01.searchResults = contact_Obj;
    obj01.oContact = contact_Obj[0];
    obj01.oDispensaryItem = dispensary_item_Obj[0];
    obj01.lstProductId = new List<string>();
    obj01.search();
  }
  static testMethod void test_processSelected_UseCase1(){
    List<Contact> contact_Obj  =  [SELECT AccountId,LastName from Contact];
    System.assertEquals(true,contact_Obj.size()>0);
    List<Dispensary_Item__c> dispensary_item_Obj  =  [SELECT DOB__c,NPI__c,StickIt_Label_Printed__c,Opportunity__c,Patient_History_Reviewed__c,Patient_Gender__c,Pharmacy_Printed__c,Non_CPC_Requested__c,PT_Refused_Counseling__c,IsAllergy__c,Prescription_s_Attached__c,Awaiting_Information_Send_Notification__c,On_Backorder_Send_Notification__c,Too_Soon_To_Refill_Send_Notification__c,Awaiting_Payment_Send_Notification__c from Dispensary_Item__c where IsChecked__c = false];
    System.assertEquals(true,dispensary_item_Obj.size()>0);
    SearchController obj01 = new SearchController(new ApexPages.StandardController(contact_Obj[0]));
    obj01.searchResults = contact_Obj;
    obj01.oContact = contact_Obj[0];
    obj01.oDispensaryItem = dispensary_item_Obj[0];
    obj01.lstProductId = new List<string>();
    obj01.processSelected();
    
  }
 
  
}


 
THIS CODE IS WRITTEN TO SEARCH CONTACTS BY LASTNAME THROUGH SEARCH BOX IN VF PAGE.WHEN CONTACT DISPLAY IT ALSO SHOW ALL THE RELATED DISPENSORY ITEMS.MOTIVE IS TO ADD CHECKBOX BESIDE EVERY DISPENSORY ITEM AND WHEN I SELECT SOME OF THEM AND CLICK ON SUMBIT BUTTON IT WILL PERFORM AN OPERATION.

User-added image



so far my code


public class SearchController {
  public Boolean SelectedRecord {get;set;}  
  private apexpages.standardController controller {get; set; }
  private contact l;
  public set<id> conid;
  public List<contact> searchResults {get; set;}
  public List<Dispensary_Item__c> Results {get; set;}

  public string searchText {
    get{
      if (searchText==null) searchText = '';
        return searchText;
    }
    set;
  }
  public SearchController(ApexPages.StandardController controller) {
    this.controller = controller;
    this.l = (contact) controller.getRecord();
    this.SelectedRecord = false;
  }

  public PageReference search() {
    if(SearchResults == null) {
      SearchResults = new List<contact>();
  }
    else{
      SearchResults.Clear();
    }
    String qry = 'SELECT Id, LastName, FirstName,account.id,Accountid, (SELECT Name FROM Dispensary_Items__r) FROM contact WHERE LastName like \'%'+searchText+'%\' Order By LastName';
    SearchResults = Database.query(qry);
    conid = (new Map<Id,contact>(SearchResults)).keySet();
    system.debug('contactList' +conid);

    return null;
  }

  public List<cContact> contactList {get; set;}

  public List<cContact> getContacts() {
        system.debug('contactList' +conid);
 
    if(contactList == null) {
      contactList = new List<cContact>();

      for(Dispensary_Item__c c: [SELECT  Id, Name FROM Dispensary_Item__c WHERE patient__c in : conid ]) {
        contactList.add(new cContact(c,SelectedRecord));
      }
      system.debug('contactList' +contactList);
    }
      return contactList;
  }

  public PageReference processSelected() {
            system.debug('contactList' +conid);

    List<Dispensary_Item__c> selectedContacts = new List<Dispensary_Item__c>();
      for(cContact cCon: getContacts()) {
        if(cCon.selected == true) {
          selectedContacts.add(cCon.con);
        }
      }
    System.debug('These are the selected items...'+selectedContacts.size());
    for(Dispensary_Item__c con: selectedContacts) {
      system.debug(con);
    }
    contactList=null;
    return null;
  }
  public class cContact {
    public Dispensary_Item__c con {get; set;}
    public Boolean selected {get; set;}
    public cContact(Dispensary_Item__c c) {
      con = c;
      selected = false;
    }
   }  
}
                                                                                      VF
_______________________________________________________________________________________________________



<apex:page standardController="Contact" extensions="SearchController">
 <apex:form id="searchForm">
  <apex:PageBlock mode="edit">        
    <apex:pageblockSection id="searchBlockSection">
        <apex:pageBlockSectionItem id="searchBlockSectionItem">
            <apex:outputLabel >Enter Patient lastname</apex:outputLabel>
            <apex:panelGroup >
                <apex:inputtext id="searchTextBox" value="{!searchText}">
                    
                </apex:inputtext>
                <strong><apex:commandButton Id="btnSearch" action="{!search}" rerender="renderBlock" status="status" title="Search" value="Search"></apex:commandButton></strong>                    
            </apex:panelGroup>
        </apex:pageBlockSectionItem>
    </apex:pageblockSection>
    <apex:actionStatus id="status" startText="Searching... please wait..."/>        
    <apex:pageBlocksection id="renderBlock" >
    
      <apex:repeat value="{!SearchResults}" var="o"   rendered="{!NOT(ISNULL(SearchResults))}">
         <apex:pageBlock title="{!o.lastname}">
        <apex:pageBlockSection >
        <apex:outputField value="{!o.FirstName}"/>
        <apex:outputField value="{!o.Accountid}"/>
        <apex:outputField value="{!o.id}"/>
         </apex:pageBlockSection>
         </apex:PageBlock>

      
        <apex:pageBlockSection >
        <apex:pageBlockTable value="{!o.Dispensary_Items__r}" var="c">
            <apex:column value="{!c.Name}"/>
                 <apex:column headerValue="Select">
                     <apex:inputCheckbox value="{!SelectedRecord}" />   
         </apex:column>
          <apex:outputField value="{!o.FirstName}"/>
        </apex:pageBlockTable>
       <apex:commandButton action="{!processSelected}" value="Submit"/>

        </apex:pageBlockSection>
    </apex:repeat>
    
           </apex:pageBlocksection>
        </apex:PageBlock>
        </apex:form>
        </apex:page>
THIS CODE IS WRITTEN TO SEARCH CONTACTS BY LASTNAME THROUGH SEARCH BOX IN VF PAGE.WHEN CONTACT DISPLAY IT ALSO SHOW ALL THE RELATED DISPENSORY ITEMS.MOTIVE IS TO ADD CHECKBOX BESIDE EVERY DISPENSORY ITEM AND WHEN I SELECT SOME OF THEM AND CLICK ON SUMBIT BUTTON IT WILL PERFORM AN OPERATION.


User-added image



so far my code


public class SearchController {
  public Boolean SelectedRecord {get;set;}  
  private apexpages.standardController controller {get; set; }
  private contact l;
  public set<id> conid;
  public List<contact> searchResults {get; set;}
  public List<Dispensary_Item__c> Results {get; set;}

  public string searchText {
    get{
      if (searchText==null) searchText = '';
        return searchText;
    }
    set;
  }
  public SearchController(ApexPages.StandardController controller) {
    this.controller = controller;
    this.l = (contact) controller.getRecord();
    this.SelectedRecord = false;
  }

  public PageReference search() {
    if(SearchResults == null) {
      SearchResults = new List<contact>();
  }
    else{
      SearchResults.Clear();
    }
    String qry = 'SELECT Id, LastName, FirstName,account.id,Accountid, (SELECT Name FROM Dispensary_Items__r) FROM contact WHERE LastName like \'%'+searchText+'%\' Order By LastName';
    SearchResults = Database.query(qry);
    conid = (new Map<Id,contact>(SearchResults)).keySet();
    system.debug('contactList' +conid);

    return null;
  }

  public List<cContact> contactList {get; set;}

  public List<cContact> getContacts() {
        system.debug('contactList' +conid);
 
    if(contactList == null) {
      contactList = new List<cContact>();

      for(Dispensary_Item__c c: [SELECT  Id, Name FROM Dispensary_Item__c WHERE patient__c in : conid ]) {
        contactList.add(new cContact(c,SelectedRecord));
      }
      system.debug('contactList' +contactList);
    }
      return contactList;
  }

  public PageReference processSelected() {
            system.debug('contactList' +conid);

    List<Dispensary_Item__c> selectedContacts = new List<Dispensary_Item__c>();
      for(cContact cCon: getContacts()) {
        if(cCon.selected == true) {
          selectedContacts.add(cCon.con);
        }
      }
    System.debug('These are the selected items...'+selectedContacts.size());
    for(Dispensary_Item__c con: selectedContacts) {
      system.debug(con);
    }
    contactList=null;
    return null;
  }
  public class cContact {
    public Dispensary_Item__c con {get; set;}
    public Boolean selected {get; set;}
    public cContact(Dispensary_Item__c c) {
      con = c;
      selected = false;
    }
   }  
}
                                                                                      VF
_______________________________________________________________________________________________________



<apex:page standardController="Contact" extensions="SearchController">
 <apex:form id="searchForm">
  <apex:PageBlock mode="edit">        
    <apex:pageblockSection id="searchBlockSection">
        <apex:pageBlockSectionItem id="searchBlockSectionItem">
            <apex:outputLabel >Enter Patient lastname</apex:outputLabel>
            <apex:panelGroup >
                <apex:inputtext id="searchTextBox" value="{!searchText}">
                    
                </apex:inputtext>
                <strong><apex:commandButton Id="btnSearch" action="{!search}" rerender="renderBlock" status="status" title="Search" value="Search"></apex:commandButton></strong>                    
            </apex:panelGroup>
        </apex:pageBlockSectionItem>
    </apex:pageblockSection>
    <apex:actionStatus id="status" startText="Searching... please wait..."/>        
    <apex:pageBlocksection id="renderBlock" >
    
      <apex:repeat value="{!SearchResults}" var="o"   rendered="{!NOT(ISNULL(SearchResults))}">
         <apex:pageBlock title="{!o.lastname}">
        <apex:pageBlockSection >
        <apex:outputField value="{!o.FirstName}"/>
        <apex:outputField value="{!o.Accountid}"/>
        <apex:outputField value="{!o.id}"/>
         </apex:pageBlockSection>
         </apex:PageBlock>

      
        <apex:pageBlockSection >
        <apex:pageBlockTable value="{!o.Dispensary_Items__r}" var="c">
            <apex:column value="{!c.Name}"/>
                 <apex:column headerValue="Select">
                     <apex:inputCheckbox value="{!SelectedRecord}" />   
         </apex:column>
          <apex:outputField value="{!o.FirstName}"/>
        </apex:pageBlockTable>
       <apex:commandButton action="{!processSelected}" value="Submit"/>

        </apex:pageBlockSection>
    </apex:repeat>
    
           </apex:pageBlocksection>
        </apex:PageBlock>
        </apex:form>
        </apex:page>
THIS CODE IS WRITTEN TO SEARCH CONTACTS BY LASTNAME THROUGH SEARCH BOX IN VF PAGE.WHEN CONTACT DISPLAY IT ALSO SHOW ALL THE RELATED DISPENSORY ITEMS.MOTIVE IS TO ADD CHECKBOX BESIDE EVERY DISPENSORY ITEM AND WHEN I SELECT SOME OF THEM AND CLICK ON SUMBIT BUTTON IT WILL PERFORM AN OPERATION.



User-added image



NOW when i select the checkbox and click on submit i get nothing(check by debug) So motive is when i select the checkbox and click on submit i will be able to get that Dispensory item so that i can perform some operation from that by submit function

here is the controller class

public class SearchController {
  public Boolean SelectedRecord {get;set;}  
  private apexpages.standardController controller {get; set; }
  private contact l;
  public List<contact> searchResults {get; set; }
  public string searchText {
    get{
      if (searchText==null) searchText = '';
        return searchText;
    }
    set;
  }
  public SearchController(ApexPages.StandardController controller) {
    this.controller = controller;
    this.l = (contact) controller.getRecord();
    this.SelectedRecord = false;
  }

  public PageReference search() {
    if(SearchResults == null) {
      SearchResults = new List<contact>();
  }
    else{
      SearchResults.Clear();
    }
    String qry = 'SELECT Id, LastName, FirstName,account.id,Accountid, (SELECT Name FROM Dispensary_Items__r) FROM contact WHERE LastName like \'%'+searchText+'%\' Order By LastName';
    SearchResults = Database.query(qry);
    return null;
  }

  public List<cContact> contactList {get; set;}

  public List<cContact> getContacts() {
    if(contactList == null) {
      contactList = new List<cContact>();
      for(Dispensary_Item__c c: [SELECT  Id, Name FROM Dispensary_Item__c WHERE Id =: SearchResults[0].id]) {
        contactList.add(new cContact(c));
      }
      system.debug('contactList' +contactList);
    }
      return contactList;
  }

  public PageReference processSelected() {
    List<Dispensary_Item__c> selectedContacts = new List<Dispensary_Item__c>();
      for(cContact cCon: getContacts()) {
        if(cCon.selected == true) {
          selectedContacts.add(cCon.con);
        }
      }
    System.debug('These are the selected items...'+selectedContacts.size());
    for(Dispensary_Item__c con: selectedContacts) {
      system.debug(con);
    }
    contactList=null;
    return null;
  }
  public class cContact {
    public Dispensary_Item__c con {get; set;}
    public Boolean selected {get; set;}
    public cContact(Dispensary_Item__c c) {
      con = c;
      selected = false;
    }
   }  
}

here is the vf page

<apex:page standardController="Contact" extensions="SearchController">
 <apex:form id="searchForm">
  <apex:PageBlock mode="edit">        
    <apex:pageblockSection id="searchBlockSection">
        <apex:pageBlockSectionItem id="searchBlockSectionItem">
            <apex:outputLabel >Enter Patient lastname</apex:outputLabel>
            <apex:panelGroup >
                <apex:inputtext id="searchTextBox" value="{!searchText}">
                    
                </apex:inputtext>
                <strong><apex:commandButton Id="btnSearch" action="{!search}" rerender="renderBlock" status="status" title="Search" value="Search"></apex:commandButton></strong>                    
            </apex:panelGroup>
        </apex:pageBlockSectionItem>
    </apex:pageblockSection>
    <apex:actionStatus id="status" startText="Searching... please wait..."/>        
    <apex:pageBlocksection id="renderBlock" >
    
      <apex:repeat value="{!SearchResults}" var="o"   rendered="{!NOT(ISNULL(SearchResults))}">
         <apex:pageBlock title="{!o.lastname}">
        <apex:pageBlockSection >
        <apex:outputField value="{!o.FirstName}"/>
        <apex:outputField value="{!o.Accountid}"/>
        <apex:outputField value="{!o.id}"/>
         </apex:pageBlockSection>
         </apex:PageBlock>

      
        <apex:pageBlockSection >
        <apex:pageBlockTable value="{!o.Dispensary_Items__r}" var="c">
            <apex:column value="{!c.Name}"/>
                 <apex:column headerValue="Select">
                     <apex:inputCheckbox value="{!SelectedRecord}" />   
         </apex:column>
          <apex:outputField value="{!o.FirstName}"/>
        </apex:pageBlockTable>
       <apex:commandButton action="{!processSelected}" value="Submit"/>

        </apex:pageBlockSection>
    </apex:repeat>
    
           </apex:pageBlocksection>
        </apex:PageBlock>
        </apex:form>
        </apex:page>

 
Product  AND Inventory_Change__c HAVE LOOKUP RELATIONSHIP.PRODUCT IS THE PARENT OF Inventory_Change__c .TRIGGER IS UPDATEING In_Stock__c FIELD ON THE BASIS OF RECORD TYPE CHANGE.
____________________________________________________________________________________________________________________
_____________________________________TRIGGER_______________________________________________________________________
trigger InventoryChangeTrigger on Inventory_Change__c (after update) {
  if(Trigger.isAfter && Trigger.isUpdate) {
    for (Inventory_Change__c oIC : Trigger.new){
      Product2  oP = [SELECT Id, In_Stock__c  FROM Product2 WHERE Id = :oIC.Product__c];
      Id Rid = Schema.SObjectType.Inventory_Change__c.getRecordTypeInfosByName().get('Reduction').getRecordTypeId();
      Id Aid = Schema.SObjectType.Inventory_Change__c.getRecordTypeInfosByName().get('Addition').getRecordTypeId();
      if(trigger.oldmap.get(oIC.id).RecordTypeid != trigger.newmap.get(oIC.id).RecordTypeid){
        if(oIC.RecordTypeid == Rid ){
          oP.In_Stock__c = oP.In_Stock__c - oIC.Quantity__c;
        }
        if(oIC.RecordTypeid == Aid ){
          oP.In_Stock__c = oP.In_Stock__c + oIC.Quantity__c;
        }
      }
    update oP;
    }
  }
}
PRODUCT IS A STANDARD OBJECT AND Inventory_Change__c IS A CUSTOM OBJECT WITH ONLY ONE FIELD REQUIRED THAT IS "RECORD TYPE"

__________________________________________________________________________________________________________________________
                                                                                           TEST CLASS
____________________________________________________________________________________________________________________________


@isTest
public class InventoryChangeTrigger_Test{
  static testMethod void test_Inventory_ChangeTrigger(){
    test.startTest();
    product2 product2_Obj  = new product2(Name = 'Name735', IsActive = true, In_Stock__c = 19, Out_of_Stock__c = false);
    insert product2_Obj;
    Inventory_Change__c inventory_change_Obj = new Inventory_Change__c(RecordTypeId = '01236000000STHgAAO',Quantity__c = 16,product__c = product2_Obj.id );
    Insert inventory_change_Obj;
    product2 product2_Obj1 = [select id,Name,In_Stock__c from product2 where Name = 'Name735'  LIMIT 1];
    product2_Obj1.name= 'xyz';
    product2_Obj1.In_Stock__c = 3;
    update product2_Obj1;
     
    test.stopTest();
  }
}
PLZ HELP ME HOW GET ConvertedAccountid TO WHICH LEAD IS GEETING CONVERTED
IT IS SHOWING NULL IN SYSTEM DEBUG.
trigger converted on Lead (after insert)
{
set<id> s= new set<id>();
list<account> acc = new list<account>();
list<contact> cs = new list<contact>();
list<task> tsk = new list<task>();
list<opportunity> ops = new list<opportunity>();
for (lead ls:trigger.new)
{

s.add(ls.id);

}
for(lead l:[select id,ConvertedAccountId,company from lead where id in:s])
{
 system.debug('*************ConvertedAccountId************'+l.ConvertedAccountId);
account a = new account();
a.id = l.ConvertedAccountId;
a.name = l.company;

acc.add(a);
system.debug('@@@@@@'+a);
opportunity o = new opportunity();
o.name = l.company;
o.accountid = l.ConvertedAccountId;
o.StageName = 'Prospecting';
o.CloseDate = system.today();

ops.add(o);
system.debug('@@@@@@'+o);
task t = new task();
t.subject = 'converted lead task';
t.whatid = l.ConvertedAccountId;
t.priority = 'Normal';
t.status = 'Not Started';

tsk.add(t);
system.debug('@@@@@@'+t);
contact c = new contact();
c.lastname = l.company;
c.accountid = l.ConvertedAccountId;

cs.add(c);
system.debug('@@@@@@'+c);
}
insert acc;
insert cs;
insert tsk;
insert ops;


}
latest__c is rollup summary field = max(opportunity).This trigger is mapping latest opportunity amount into account field (acc.opty_amount__c).
trigger latest on Account (after update)  {    
  if(checkRecursive.runOnce())  
  {    set<id> acctid =new set<id>();    
  list<account> accnt=new list<account>();  
  for(account acc:trigger.new)  
  {       acctid.add(acc.id);           }          
  for(account acc : [select id,name,opty_amount__c,latest__c(select id,amount,CreatedDate from opportunities) from account where id  in:acctid])    {    list <opportunity> oppo = acc.opportunities;    
for(opportunity op:oppo)   
 {    if(acc.latest__c == op.CreatedDate)    
      {    acc.opty_amount__c=op.amount;  
      }
 
  }          
    accnt.add(acc);    
  }    
 update accnt;  
}
THIS TEST CLASS IS GIVING 80% COVERAGE PLZ HELP ME TO CONVERT IT TO 100%.
@isTest
private class UpdateAccount_Test
{  public static testMethod void TestUpdateAccount() 
  {        Account acc = new Account();           
         acc.Name = 'Test';              
         insert acc;         
         opportunity oppo = new opportunity();          
         oppo.accountid  =acc.id;     
         oppo.amount = 50000.00;                        
        update acc;    
        }  
 }
-----------------------------------------------------------------------CONTROLLER CLASS--------------------------------------------------------------------------------------------------
 
public class QuickBackgroundCheckOrderCl {
 
  public string sOrderId = ApexPages.currentPage().getParameters().get('tfa_2935');
  //public String sPackageId = ApexPages.currentPage().getParameters().get('tfa_3025');
  public String sServiceorder_employment_package {get;set;}
  public String sServiceorder_education_package  {get;set;}
  public String sServiceorder_license_package  {get;set;}
  public String sServiceorder_reference_package  {get;set;}
  public String sServiceorder_international_employment_package {get;set;}
  public String sServiceorder_international_degree_package {get;set;}
  public String sServiceorder_employment_a_la_carte {get;set;}
  public String sServiceorder_education_a_la_carte  {get;set;}
  public String sServiceorder_license_a_la_carte  {get;set;}
  public String sServiceorder_reference_a_la_carte  {get;set;}
  public String sServiceorder_international_employment_a_la_carte {get;set;}
  public String sServiceorder_international_degree_a_la_carte {get;set;}
  public integer intEmploymentPackageCount = 0;
  public integer intEducationPackageCount = 0;
  public integer intLicensePackageCount = 0;
  public integer intReferencePackageCount = 0;
  public integer intInternationalEmploymentPackageCount = 0;
  public integer intInternationalDegreePackageCount = 0;
 
  public string sAccountId = ApexPages.currentPage().getParameters().get('tfa_3012');
  public string sPartnerId = ApexPages.currentPage().getParameters().get('tfa_22');
  public string sAnnualSalary = ApexPages.currentPage().getParameters().get('tfa_21511');
  public string sOrderNumber = ApexPages.currentPage().getParameters().get('tfa_2998');
  public string bFCRAEmploymentRelatedChecks = ApexPages.currentPage().getParameters().get('tfa_21508');
  public string bFCRAInvestigativeConsumerReports = ApexPages.currentPage().getParameters().get('tfa_21509');
  public string bCertificationRegardingNoLegalAdvice = ApexPages.currentPage().getParameters().get('tfa_21510');
  public string bFCRAPermissble = ApexPages.currentPage().getParameters().get('tfa_21512');
  public string bCreditReport = ApexPages.currentPage().getParameters().get('tfa_21513');
  public string spackagename {get;set;}
  public boolean bLicCount {set;get;}
  public boolean bDegCount {set;get;}
  public boolean bEmpCount {set;get;}
  public boolean bRefCount {set;get;}
  public integer iDegCount {get;set;}
  public integer iEmpCount {get;set;}
  public integer iRefCount {get;set;}
  public integer iLicCount {get;set;}
  public integer iInternationalDegcount {get;set;}
  public Integer itotaldegree {get;set;}
  public Integer itotalemp {get;set;}
  public boolean bInternationalDegcount {set;get;}
  public integer iInternationalEmpCount {get;set;}
  public boolean bInternationalEmpCount {set;get;}
  public string scountry {get;set;}
  public string sState {get;set;}
  public string sDLState {get;set;}
  public string sDLNumber {get;set;}
  public List<BGC_Order__c> lstBGCOrder {get;set;}
  public string sFirstName {set;get;}
  public string sLastName {set;get;}
  public string sMiddleName {set;get;}
  public string sGovermentIdType {set;get;}
  public string sGovermentIdNumber {set;get;}
  public string sEmail {set;get;}
  public string sPhoneNumber{set;get;}
  public string sUnitNumber {get; set;}
  public string sAddress {set;get;}
  public string sCity {set;get;}
  public string sDegreestate {set;get;}
  public date dDateOfBirth {set;get;}
  public string sZipCode {set;get;}
  public string sService {set;get;}
  public List<Contact> lstContact {get;set;}
  public string sNotesPreEmlpoy {get;set;}
  public boolean bYes {get;set;}
  public string sFirstAlterName {get;set;}
  public string sCurrentEmployer {get;set;}
  public string sLastAlterName {get;set;}
  public string sEmploystate {get;set;}
  public string sEmployCountry {get;set;}
  public string sDegree {get;set;}
  public string sDegreeCountry {get;set;}
  public string sAttendance {get;set;}
  public string sRequestUpdate {get;set;}
  public string sCommonform {get;set;}
  public string sUnitNumberMailing {get;set;}
  public string sAddressMailing {get;set;}
  public string sCityMailing {get;set;}
  public string stateMailing {get;set;}
  public string sZipCodeMailing {get;set;}
  public string sCountryMailing {get;set;}
  public Integer iTotalInternationalLicense{get;set;}
  public List<BGC_Degree_Intake__c> lstBGCDegreeList {get; set;}
  public List<BGC_Employment_Intakes__c> lstBGCEmploymentList {get; set;}
  public List<BGC_Reference_Intake__c> lstBGCReferenceList {get; set;}
  public List<BGC_License_Intake__c> lstBGCLicenseList {get; set;}
  public BGC_S_O_Individual__c  bgindivisual {get;set;}
    
  public List<SelectOption> getGovIdType() {
    List<SelectOption> options = new List<SelectOption>();
    options.add(new SelectOption('Please Select','Please Select'));
    options.add(new SelectOption('Social Security Number','Social Security Number'));
    options.add(new SelectOption('Alien Number','Alien Number'));
    options.add(new SelectOption('I-94 Number','I-94 Number'));
    options.add(new SelectOption('Other','Other'));
    return options;
  }
 
  public List<SelectOption> getDegree() {
    List<SelectOption> options = new List<SelectOption>();
    options.add(new SelectOption('Please Select...','Please Select...'));
    options.add(new SelectOption('High School Diploma','High School Diploma'));
    options.add(new SelectOption('Associates','Associates'));
    options.add(new SelectOption('Bachelors','Bachelors'));
    options.add(new SelectOption('Certificate','Certificate'));
    options.add(new SelectOption('PHD','PHD'));
    options.add(new SelectOption('Other','Other'));
    return options;
  }
    
  public List<SelectOption> getItems() {
    List<SelectOption> options = new List<SelectOption>();
    options.add(new SelectOption('Yes','Yes'));
    options.add(new SelectOption('No','No'));
    return options;
  }
 
  public List<SelectOption> getItem() {
    List<SelectOption> options = new List<SelectOption>();
    options.add(new SelectOption('true','Yes'));
    options.add(new SelectOption('false','No'));
    return options;
  }
  public List<SelectOption> getitemcontact() {
    List<SelectOption> options = new List<SelectOption>();
    options.add(new SelectOption('true','Yes'));
    options.add(new SelectOption('false','No'));
    return options;
  }
    
  public QuickBackgroundCheckOrderCl(){
    spackagename = ApexPages.currentPage().getParameters().get('tfa_3026');
    if(!Test.IsRunningTest()){
      if(salesforcecl.IsClientCommunity()) {
        sRequestUpdate = Salesforcecl.getCommunityUrl +'/main/BGCRequestUpdate_community?';
        sCommonform = Salesforcecl.getCommunityUrl +'/main/015?fcf=00l80000001K9Gl';
      }
      else {
        sRequestUpdate = Salesforcecl.getPortalUrl +'main/BGCRequestUpdate?';
        sCommonform = Salesforcecl.getPortalUrl +'main/015?fcf=00l80000001K9Gl';
      }
    }
    if (sOrderId != null){
      bYes = false;
      sAttendance = 'No';
      sGovermentIdType = 'Social Security Number';
      iDegCount = integer.valueof(ApexPages.currentPage().getParameters().get('tfa_2181'));
      iEmpCount = integer.valueof(ApexPages.currentPage().getParameters().get('tfa_2187'));
      iRefCount = integer.valueof(ApexPages.currentPage().getParameters().get('tfa_2964'));
      iLicCount = integer.valueof(ApexPages.currentPage().getParameters().get('tfa_2920'));
      System.debug(integer.valueof(ApexPages.currentPage().getParameters().get('tfa_6793')));
      iInternationalDegcount = integer.valueof(ApexPages.currentPage().getParameters().get('tfa_6793'));
      iInternationalEmpCount = integer.valueof(ApexPages.currentPage().getParameters().get('tfa_6776'));
      itotaldegree = iDegCount+ iInternationalDegcount;
      itotalemp = iEmpCount+ iInternationalEmpCount;
      lstBGCDegreeList = new List<BGC_Degree_Intake__c>();
      lstBGCEmploymentList = new List<BGC_Employment_Intakes__c>();
      lstBGCReferenceList = new List<BGC_Reference_Intake__c>();
      lstBGCLicenseList = new List<BGC_License_Intake__c>();
      List<BGC_S_O_Individual__c> lstindivisual = new List<BGC_S_O_Individual__c>();
      List<BGC_S_O_Individual__c > lstbsoi = [SELECT Id, Name, Quantity__c,Package__c, Minimum_Quantity__c, Service_Name__c, Selected_Service__c FROM BGC_S_O_Individual__c WHERE BGC_Order__c = :sOrderId AND Service_Name__c != null AND BGC_Order__c != Null AND Selected_Service__c != NUll ];
      for(BGC_S_O_Individual__c oBGC_S_O_Individual: lstbsoi) {
        if(oBGC_S_O_Individual.Service_Name__c.tolowercase().contains('employment verification') && !oBGC_S_O_Individual.Service_Name__c.tolowercase().contains('international')){
          if(oBGC_S_O_Individual.package__c) {
             sServiceorder_employment_package = oBGC_S_O_Individual.Id;
             intEmploymentPackageCount = intEmploymentPackageCount + integer.valueof(oBGC_S_O_Individual.Minimum_Quantity__c);
           }
           else {
             sServiceorder_employment_a_la_carte = oBGC_S_O_Individual.Id;
           }
        }
        else if(oBGC_S_O_Individual.Service_Name__c.tolowercase().contains('education verification')){
          if(oBGC_S_O_Individual.package__c) {
            sServiceorder_education_package = oBGC_S_O_Individual.Id;
            intEducationPackageCount = intEducationPackageCount + integer.valueof(oBGC_S_O_Individual.Minimum_Quantity__c);
          }
          else {
            sServiceorder_education_a_la_carte = oBGC_S_O_Individual.Id;
          }
        }
        else if(oBGC_S_O_Individual.Service_Name__c.tolowercase().contains('license verification') || oBGC_S_O_Individual.Service_Name__c.tolowercase().contains('international license') || oBGC_S_O_Individual.Service_Name__c.tolowercase().contains('professional license') ){
          if(oBGC_S_O_Individual.package__c) {
            sServiceorder_license_package = oBGC_S_O_Individual.Id;
            intLicensePackageCount = intLicensePackageCount + integer.valueof(oBGC_S_O_Individual.Minimum_Quantity__c);
          }
          else {
            sServiceorder_license_a_la_carte = oBGC_S_O_Individual.Id;
          }
        }
        else if(oBGC_S_O_Individual.Service_Name__c.tolowercase().contains('professional reference') || oBGC_S_O_Individual.Service_Name__c.tolowercase().contains('international reference')){
          if(oBGC_S_O_Individual.package__c) {
            sServiceorder_reference_package = oBGC_S_O_Individual.Id;
            intReferencePackageCount = intReferencePackageCount + integer.valueof(oBGC_S_O_Individual.Minimum_Quantity__c);
          }
          else {
            sServiceorder_reference_a_la_carte = oBGC_S_O_Individual.Id;
          }
        }
        else if(oBGC_S_O_Individual.Service_Name__c.tolowercase().contains('international employment verification')) {
          if(oBGC_S_O_Individual.package__c) {
            sServiceorder_international_employment_package = oBGC_S_O_Individual.Id;
            intInternationalEmploymentPackageCount = intInternationalEmploymentPackageCount + integer.valueof(oBGC_S_O_Individual.Minimum_Quantity__c);
          }
          else {
            sServiceorder_international_employment_a_la_carte = oBGC_S_O_Individual.Id;
          }
        }
        else if(oBGC_S_O_Individual.Service_Name__c.tolowercase().contains('international degree verification')){
          if(oBGC_S_O_Individual.package__c) {
            sServiceorder_international_degree_package = oBGC_S_O_Individual.Id;
            intInternationalDegreePackageCount = intInternationalDegreePackageCount + integer.valueof(oBGC_S_O_Individual.Minimum_Quantity__c);
          }
          else {
            sServiceorder_international_degree_a_la_carte = oBGC_S_O_Individual.Id;
          }
        }
      }
      if(iDegCount != null && iDegCount != 0){
        bDegCount = true;
        for(Integer i = 1; i <= iDegCount; i++){
          if(intEducationPackageCount > 0) {
            lstBGCDegreeList.add(new BGC_Degree_Intake__c(Provided_Degree_Earned__c = '', Provided_Major_Minor__c = '', Provided_School_End__c = null, Provided_Degree_Awarded_Date__c = null, School_Name__c = '', School_Phone__c = '', School_Fax__c = '', School_Address__c = '', School_City__c = '', School_Country__c = null, Provided_School_Start__c = null, School_State_Providence__c = null, Background_Check_Order__c = sOrderId, Classification__c = '', Attendance_Only__c =false, Service_Ordered__c = sServiceorder_education_package));
            intEducationPackageCount = intEducationPackageCount - 1;
          }
          else {
            lstBGCDegreeList.add(new BGC_Degree_Intake__c(Provided_Degree_Earned__c = '', Provided_Major_Minor__c = '', Provided_School_End__c = null, Provided_Degree_Awarded_Date__c = null, School_Name__c = '', School_Phone__c = '', School_Fax__c = '', School_Address__c = '', School_City__c = '', School_Country__c = null, Provided_School_Start__c = null, School_State_Providence__c = null, Background_Check_Order__c = sOrderId, Classification__c = '', Attendance_Only__c =false, Service_Ordered__c = sServiceorder_education_a_la_carte));
          }
        }
      }
      else {
        bDegCount = false;
      }
      if(iInternationalDegcount != null && iInternationalDegcount != 0){
        bDegCount = true;
        for(Integer i = 1; i <= iInternationalDegcount; i++){
          if(intInternationalDegreePackageCount > 0) {
            lstBGCDegreeList.add(new BGC_Degree_Intake__c(Provided_Degree_Earned__c = '', Provided_Major_Minor__c = '', Provided_School_End__c = null, Provided_Degree_Awarded_Date__c = null, School_Name__c = '', School_Phone__c = '', School_Fax__c = '', School_Address__c = '', School_City__c = '', School_Country__c = null, Provided_School_Start__c = null, School_State_Providence__c = null, Background_Check_Order__c = sOrderId, Classification__c = '', Attendance_Only__c =false, Service_Ordered__c = sServiceorder_international_degree_package));
            intInternationalDegreePackageCount = intInternationalDegreePackageCount - 1;
          }
          else {
            lstBGCDegreeList.add(new BGC_Degree_Intake__c(Provided_Degree_Earned__c = '', Provided_Major_Minor__c = '', Provided_School_End__c = null, Provided_Degree_Awarded_Date__c = null, School_Name__c = '', School_Phone__c = '', School_Fax__c = '', School_Address__c = '', School_City__c = '', School_Country__c = null, Provided_School_Start__c = null, School_State_Providence__c = null, Background_Check_Order__c = sOrderId, Classification__c = '', Attendance_Only__c =false, Service_Ordered__c = sServiceorder_international_degree_a_la_carte));
          }
        }
      }
      else {
        bInternationalDegcount = false;
      }
     
I want regex for this format and filter out 123456 if match the current format
PO # 123456
PO# 123456
PO #123456
P.O. # 123456
P.O.# 123456
P.O. #123456

We have to filter substring from string notes__c field. my regex is only working for PO #123456 and P.O. #123456
tried PO# (\\S+)\\s not working
Matcher rm = r.matcher(oOrder.Notes__c); 
Pattern r = Pattern.compile('PO #(\\S+)\\s'); 

if(rm.find()) {
 string res2 = rm.group(1); 
oOrder.test__c = res2; 
}

 
Product  AND Inventory_Change__c HAVE LOOKUP RELATIONSHIP.PRODUCT IS THE PARENT OF Inventory_Change__c .TRIGGER IS UPDATEING In_Stock__c FIELD ON THE BASIS OF RECORD TYPE CHANGE.
____________________________________________________________________________________________________________________
_____________________________________TRIGGER_______________________________________________________________________
trigger InventoryChangeTrigger on Inventory_Change__c (after update) {
  if(Trigger.isAfter && Trigger.isUpdate) {
    for (Inventory_Change__c oIC : Trigger.new){
      Product2  oP = [SELECT Id, In_Stock__c  FROM Product2 WHERE Id = :oIC.Product__c];
      Id Rid = Schema.SObjectType.Inventory_Change__c.getRecordTypeInfosByName().get('Reduction').getRecordTypeId();
      Id Aid = Schema.SObjectType.Inventory_Change__c.getRecordTypeInfosByName().get('Addition').getRecordTypeId();
      if(trigger.oldmap.get(oIC.id).RecordTypeid != trigger.newmap.get(oIC.id).RecordTypeid){
        if(oIC.RecordTypeid == Rid ){
          oP.In_Stock__c = oP.In_Stock__c - oIC.Quantity__c;
        }
        if(oIC.RecordTypeid == Aid ){
          oP.In_Stock__c = oP.In_Stock__c + oIC.Quantity__c;
        }
      }
    update oP;
    }
  }
}
PRODUCT IS A STANDARD OBJECT AND Inventory_Change__c IS A CUSTOM OBJECT WITH ONLY ONE FIELD REQUIRED THAT IS "RECORD TYPE"

__________________________________________________________________________________________________________________________
                                                                                           TEST CLASS
____________________________________________________________________________________________________________________________


@isTest
public class InventoryChangeTrigger_Test{
  static testMethod void test_Inventory_ChangeTrigger(){
    test.startTest();
    product2 product2_Obj  = new product2(Name = 'Name735', IsActive = true, In_Stock__c = 19, Out_of_Stock__c = false);
    insert product2_Obj;
    Inventory_Change__c inventory_change_Obj = new Inventory_Change__c(RecordTypeId = '01236000000STHgAAO',Quantity__c = 16,product__c = product2_Obj.id );
    Insert inventory_change_Obj;
    product2 product2_Obj1 = [select id,Name,In_Stock__c from product2 where Name = 'Name735'  LIMIT 1];
    product2_Obj1.name= 'xyz';
    product2_Obj1.In_Stock__c = 3;
    update product2_Obj1;
     
    test.stopTest();
  }
}
PLZ HELP ME HOW GET ConvertedAccountid TO WHICH LEAD IS GEETING CONVERTED
IT IS SHOWING NULL IN SYSTEM DEBUG.
trigger converted on Lead (after insert)
{
set<id> s= new set<id>();
list<account> acc = new list<account>();
list<contact> cs = new list<contact>();
list<task> tsk = new list<task>();
list<opportunity> ops = new list<opportunity>();
for (lead ls:trigger.new)
{

s.add(ls.id);

}
for(lead l:[select id,ConvertedAccountId,company from lead where id in:s])
{
 system.debug('*************ConvertedAccountId************'+l.ConvertedAccountId);
account a = new account();
a.id = l.ConvertedAccountId;
a.name = l.company;

acc.add(a);
system.debug('@@@@@@'+a);
opportunity o = new opportunity();
o.name = l.company;
o.accountid = l.ConvertedAccountId;
o.StageName = 'Prospecting';
o.CloseDate = system.today();

ops.add(o);
system.debug('@@@@@@'+o);
task t = new task();
t.subject = 'converted lead task';
t.whatid = l.ConvertedAccountId;
t.priority = 'Normal';
t.status = 'Not Started';

tsk.add(t);
system.debug('@@@@@@'+t);
contact c = new contact();
c.lastname = l.company;
c.accountid = l.ConvertedAccountId;

cs.add(c);
system.debug('@@@@@@'+c);
}
insert acc;
insert cs;
insert tsk;
insert ops;


}
trigger trigger52 on India__c (after insert) {
  list<san_francisco__c> con =new list<san_francisco__c>();  

    for(India__c h : trigger.new){
     san_francisco__c s = new san_francisco__c();
      s.Name=h.Name;
        s.Company__c=h.Company__c;
        s.Mobile__c=h.Mobile__c;
           s.Email__c=h.Email__c;
        con.add(s);
        
        
    }
    insert con;
}
latest__c is rollup summary field = max(opportunity).This trigger is mapping latest opportunity amount into account field (acc.opty_amount__c).
trigger latest on Account (after update)  {    
  if(checkRecursive.runOnce())  
  {    set<id> acctid =new set<id>();    
  list<account> accnt=new list<account>();  
  for(account acc:trigger.new)  
  {       acctid.add(acc.id);           }          
  for(account acc : [select id,name,opty_amount__c,latest__c(select id,amount,CreatedDate from opportunities) from account where id  in:acctid])    {    list <opportunity> oppo = acc.opportunities;    
for(opportunity op:oppo)   
 {    if(acc.latest__c == op.CreatedDate)    
      {    acc.opty_amount__c=op.amount;  
      }
 
  }          
    accnt.add(acc);    
  }    
 update accnt;  
}
THIS TEST CLASS IS GIVING 80% COVERAGE PLZ HELP ME TO CONVERT IT TO 100%.
@isTest
private class UpdateAccount_Test
{  public static testMethod void TestUpdateAccount() 
  {        Account acc = new Account();           
         acc.Name = 'Test';              
         insert acc;         
         opportunity oppo = new opportunity();          
         oppo.accountid  =acc.id;     
         oppo.amount = 50000.00;                        
        update acc;    
        }  
 }
Hi
I have created an apex trigger to update contact address when the account address is changed. The code worked fine for already created accounts, but when I have created a new account the following error was thrown and I was not able to save the account. Please help me.

Error: updateContact: execution of AfterInsert caused by: System.NullPointerException: Attempt to de-reference a null object Trigger.updateContact: line 33, column 1​
 
trigger updateContact on Account (after insert, after update) {
    List<Contact> contactsForUpsert = New List<Contact>();

    Map<Id, Contact> contactsByAccountId = new Map<Id, Contact>();
    List<Contact> contacts = [SELECT Id,
                                     AccountId,
                                     mailingstreet,
                                     mailingcity,
                                     mailingstate,
                                     mailingpostalcode
                            FROM Contact WHERE AccountId IN: Trigger.newMap.keySet()];
    for (Contact cont: contacts) {
        contactsByAccountId.put(cont.accountId, cont);
    }

    for (Account account: Trigger.new) {

        Account old;
        if (Trigger.isUpdate) {
            old = Trigger.oldMap.get(account.Id);
        }

        Boolean isShippingAddressChangedOrNew = Trigger.isInsert ? true :
                                                (   account.ShippingStreet != old.ShippingStreet
                                                 || account.ShippingCity != old.ShippingCity
                                                 || account.ShippingState != old.ShippingState
                                                 || account.ShippingPostalCode != old.ShippingPostalCode
                                                 || account.ShippingCountry != old.ShippingCountry) ? true : false;

        if (isShippingAddressChangedOrNew) {
            Contact relatedContact = contactsByAccountId.get(account.Id);
           
            relatedContact.mailingstreet     = account.Shippingstreet;
            relatedContact.mailingcity       = account.Shippingcity;
            relatedContact.mailingstate      = account.Shippingstate;
            relatedContact.mailingpostalcode = account.shippingpostalcode;
            contactsForUpsert.add(relatedContact);
        

    }

    try {
        upsert contactsForUpsert;
    } catch(Dmlexception e) {
        System.debug(LoggingLevel.ERROR, 'Contact insert from createopp.trigger has failed with message:' + e.getMessage());
    }
}
}

 
  • January 23, 2018
  • Like
  • 0