• Tugce Sirin
  • NEWBIE
  • 125 Points
  • Member since 2014
  • Developer
  • Inspark


  • Chatter
    Feed
  • 4
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 22
    Replies
I've written this class called createExpense, and I use the Process Builder to pass parameters to a static void method. My test class only covers 25%.  And I'm trying to get this higher. So, my first thought is that I need to write some system.asserts. This is where my problem/confusion starts. it seems the only way to test a static method is to give it the parameters it expects within a test class and the rest should be taken care of. This has worked great for me in the past...resulting in 100% coverage, but not this time. So, in order to write some system.asserts I tried to instatiate the class so that I would have a variable to reference and write assets with, but the platform won't let you do that. 

So, looking for some ideas out there. I have posted the class, test class and screenshot of coverage.
 
global class createExpense {
    @InvocableMethod
    public static void createExpense(List<String> InvId) {
    List<Expense__c> newExps = new List<Expense__c>();
    List<Expense_Line_Item__c> newExpLIs = new List<Expense_Line_Item__c>();
    Map<ID,Set<Invoice_Line_Item__c>> invLIs = new Map<ID,Set<Invoice_Line_Item__c>>();
    Set<Id> usedAccounts = new Set<Id>();  
    Expense__c newExp = new Expense__c(); 
   

  for(Invoice_Line_Item__c invLI : [select Id, CurrencyIsoCode, Product__r.Id, Invoicing__r.Id, Invoicing__r.Project__r.Id, Product__r.Account__r.Id, Product_Platform__c, Product_Family__c,Line_Item_Description__c, Quantity__c, Payment_Per_Complete__c, Top_up_Reason__c from Invoice_Line_Item__C where Invoicing__c IN :InvId AND Product__r.Direct_Expense__c = True]) {
    Set<Invoice_Line_Item__c> invLIsList = invLIs.get(invLI.Product__r.Account__r.Id);
    if(invLIsList == null) {
        invLIsList = new Set<Invoice_Line_Item__c>();
        invLIs.put(invLI.Product__r.Account__r.Id,invLIsList);
    }
    invLIsList.add(invLI);
  }
    System.debug('=============invLIs.keySet():'+invLIs.keySet());
    for(Id mapKey : invLIs.keySet()) {
        System.debug('---------------mapKey:'+mapKey);
        System.debug('======usedAccounts0:'+usedAccounts);
        if(!usedAccounts.contains(mapKey)) {
             usedAccounts.add(mapKey);
            for(Invoice_Line_Item__c inv1: invLIs.get(mapKey)) {
                System.debug('======usedAccounts1:'+usedAccounts);
                    System.debug('======usedAccounts2:'+usedAccounts);
                    System.debug('======inv1.Product__r.Account__r.Id:'+inv1.Product__r.Account__r.Id);
                     newExp = new Expense__c(
                        Project__c = inv1.Invoicing__r.Project__r.Id,
                        Account__c = inv1.Product__r.Account__r.Id,
                        Invoice__c = inv1.Invoicing__r.Id,
                        Top_up_Reason__c = inv1.Top_up_Reason__c,
                        Target_Group__c = inv1.Line_Item_Description__c,
                        Top_up_Type__c = 'At quoting',
                        Expense_Type__c = inv1.Product_Platform__c == 'Survey Tool' ? 'Survey Tool' : 
                         				  inv1.Product_Family__c == 'Survey Respondents' && inv1.Product_Platform__c == 'External' ? 'AH Fee: Top-Up' :
                         				  inv1.Product_Family__c == 'Survey Respondents' && inv1.Product_Platform__c == 'Pureprofile' ? 'AH Fee: PP' :
                         				  inv1.Product_Family__c == 'Survey Respondents' && inv1.Product_Platform__c == 'NEWS' ? 'AH Fee: NEWS' :
                         				  inv1.Product_Family__c == 'Survey Respondents' && inv1.Product_Platform__c == 'AA Smartfuel' ? 'AH Fee: Smartfuel' :
                         				  'Unknown',
                        CurrencyIsoCode = inv1.CurrencyIsoCode 
                    );
                    
                }  
            newExps.add(newExp);
        }
        System.debug('---------------------End of the for loop.');
    }  
    insert newExps;

    for(Expense__c exp : newExps) {
        for(Invoice_Line_Item__c invLi2 : invLis.get(exp.Account__c)) {
            Expense_Line_Item__c eli = new Expense_Line_Item__c(
                Expense__c = exp.Id,
                Product__c = invLI2.Product__c,
                Expense_Type__c = invLI2.Product_Family__c,
                Quantity__c = invLI2.Quantity__c,
                Amount__c = invLI2.Payment_Per_Complete__c,
                CurrencyIsoCode = invLi2.CurrencyIsoCode
        );
        newExpLIs.add(eli);
        }
    }
    insert newExpLIs;
   }
}
 
@isTest
public class testCreateExpense {

    static testMethod void expenseTest() {
        Id opptyRecordType1 = Schema.SObjectType.Opportunity.getRecordTypeInfosByName().get('Opportunity - Research').getRecordTypeId();
        Account a1 = (Account)TestFactory.createSObject(new Account(), true);
        List<Product2> prodList1 = (List<Product2>)TestFactory.createSObjectList(new Product2(),5,true);
        List<PriceBookEntry> standardPBEList1 = new List<PriceBookEntry>();
        Id standardPBEId1 = Test.getStandardPricebookId();
        Contact c1 = (Contact)TestFactory.createSObject(new Contact(AccountId = a1.Id),true);
        Opportunity o1 = (Opportunity)TestFactory.createSObject(new Opportunity(AccountId = a1.Id, RecordTypeId = opptyRecordType1),true);
        Quote q1 = (Quote)TestFactory.createSObject(new Quote(OpportunityId = o1.Id),true);
        List<QuoteLineItem> qliList = new List<QuoteLineItem>();
        Project__c prj1 = (Project__c)TestFactory.createSObject(new Project__c(Opportunity__c = o1.Id),true);
        Invoicing__c inv1 = (Invoicing__c)TestFactory.createSObject(new Invoicing__c(Project__c = prj1.Id, Price_Book__c = standardPBEId1),true);
        List<String> InvId1 = new List<String>();
        List<Invoice_Line_Item__c> invLIList = new List<Invoice_Line_Item__c>();
        List<String> ILIIDs = new List<String>();
        
        o1.SyncedQuoteId = q1.Id;
        Update o1;
        
        Product2 prod1a = prodList1.get(0);
        prod1a.Platform__c = 'External';
        Prod1a.Family = 'Research - Survey Respondents';
        Product2 prod2a = prodList1.get(1);
        prod2a.Platform__c = 'Survey Tool';
        prod2a.Family = 'Research - Hosting Fee';
        Product2 prod3a = prodList1.get(2);
        prod3a.Platform__c = 'Pureprofile';
        prod3a.Family = 'Research - Survey Respondents';
        update prodList1;
        
        for(Product2 prod1 : prodList1) {
            PriceBookEntry pbe = new PriceBookEntry(
                Product2Id = prod1.Id,
                PriceBook2Id = standardPBEId1,
                CurrencyIsoCode = 'AUD',
                UnitPrice = 1,
                Payment_Per_Complete__c = .5,
                IsActive = True
            );
            standardPBEList1.add(pbe);
        }
        insert standardPBEList1;
    

        for(PriceBookEntry pbe1 : standardPBEList1) {
            QuoteLineItem qli = (QuoteLineItem)TestFactory.createSObject(new QuoteLineItem(QuoteId = q1.Id, PriceBookEntryId = pbe1.Id));
            qliList.add(qli);
            Invoice_Line_Item__c invli = (Invoice_Line_Item__c)TestFactory.createSObject(new Invoice_Line_Item__c(Invoicing__c = inv1.Id,Product__c = pbe1.Product2Id));
            invLILIst.add(invli);
            ILIIDs.add(invli.Id);
        }
        insert qliList;
        insert invLIList;
        
        InvId1.add(inv1.Id);
        createExpense.createExpense(InvId1); 
        createInvoiceLineItem.addListPrice(ILIIDs);
       
       
    }
    
   
    

}

User-added image
I have a trigger on a custom object (before insert and before update) that is looking at the Account object.  The custom object GWU40__c has an email address which is looking at the Account.PersonEmail (person-enabled accounts in Salesforce).

Every time it executes this line:
g.Nominee_Profile_ID__c = AccountMapNominees.get(g.Nominee_Email__c).FIMS_ID__c

it tells me de-referencing a null object (i'm sure it's becasue there isn't an Account with that email address).  
How can I check to see if the Map.get() is returning null?   

-------------------------------
trigger X_GWU40_LookupProfileIDs on GWU40__c (before insert,before update) {
    Set<String> noms = new Set<String>(); //Dedupe the email addresses in case of multiple nominations for the same person (email address)
    
    for(GWU40__c recordsToProcess : Trigger.New)
    {
        if(recordsToProcess.Nominee_EMail__c != null) {
            noms.add(recordsToProcess.Nominee_Email__c);
        }
        
    }
    
    Map<String,Account> AccountMapNominees = New Map<String,Account>();
        For(Account a : [SELECT PersonEmail,Name,FIMS_ID__c from Account where PersonEmail IN: noms]){
            AccountMapNominees.put(a.PersonEmail,a);
        }
      IF((!AccountMapNominees.isEmpty()) && (AccountMapNominees.size() > 0)){

      FOR(GWU40__c g : Trigger.New)
      {
          if (g.Nominee_Email__c != null)
          {            
             g.Nominee_Profile_ID__c = AccountMapNominees.get(g.Nominee_Email__c).FIMS_ID__c;                                 
          }
      }
     } //if 
   
}

------------------------------------
I created a Custom Object called SD_Member__c and on that object is a field Enrollment_Progress_Status__c which gets updated based on the result of a corresponding  Task.  I thought I did everything right, but periodically, I am getting a System.LimitException: Too many DML statements error.  Any ideas where my code may be causing this issue?
trigger Update_SD_Member_Enrollment_Progress_Status on Task (after update) {
/*
Automatically update the "Enrollment Progress Status" field, based upon the "Status" field 
of the last Member Task
*/

// Tasks that meet criteria, and new tasks to create
Task[] qualifiedTasks = new Task[0], newTasks = new Task[0];

Date dt=DateTime.now().addDays(1).date();
Date rt=DateTime.now().addDays(1).date();
    
// Map of SD Members
   Map<Id,SD_Member__c> members = new Map<Id,SD_Member__c>();

Map<id,Task> TaskMap = new Map<id,Task>([select id,RecordType.Name from Task 
                                         where id in : Trigger.newmap.keyset()]);
// Find qualifying tasks
for(Task record:Trigger.new)
        if(TaskMap.get(Record.id).RecordType.Name =='Member Outreach' &&
           record.isclosed == True)
           qualifiedtasks.add(record);
    
    // Obtain member ID values
    for(Task record:qualifiedtasks)
        members.put(record.whatid,null);
   
    // If there are any members to query, do so.
    if(!members.isempty())
        members.putall([select id, Enrollment_Progress_Status__c from SD_Member__c where id in :members.keyset()]);


 // For each qualifying task, check the current Enrollment_Progress_Status__c from SD_Member__c and assign
 // to the strStatus variable.  That way if the Task Status does not meet the critera below, the status 
 // will reamin it's current value 
for(Task record:qualifiedtasks) {
    String strStatus = members.get(record.whatid).Enrollment_Progress_Status__c;    

    // Set the strStatus based on the current Task Status value
      If (record.Status == 'Not Started' ){
          StrStatus = 'Attempting to Contact';}
      If (record.Status == 'Left Message w/ Person' ){
          StrStatus = 'Successful Contact';}
      If (record.Status == 'Member Hung Up' ){
          StrStatus = 'Successful Contact';}
      If (record.Status == 'Phone # Invalid' ){
          StrStatus = 'Phone # Invalid';}
      If (record.Status == 'Reached Recording - No Msg Left' ){
          StrStatus = 'Attempting to Contact';}
      If (record.Status == 'Reached Target - Call Later' ){
          StrStatus = 'Successful Contact';} 
      If (record.Status == 'Reached Recording - No Msg Left' ){
          StrStatus = 'Attempting to Contact';}              
      If (record.Status == 'Reached Target - Call Later' ){
          StrStatus = 'Successful Contact';}
      If (record.Status == 'Reached Target - Declined - Copay' ){
          StrStatus = 'Declined - Copay';}
      If (record.Status == 'Reached Target - Declined - Other' ){
          StrStatus = 'Declined - Other';}
      If (record.Status == 'Reached Target - Declined - Transport' ){
          StrStatus = 'Declined - Transportation';}
      If (record.Status == 'Reached Target - Requested Info' ){
          StrStatus = 'Decision Pending';}
      If (record.Status == 'Reached Target - Sent to Care Coach' ){
          StrStatus = 'Referred to Care Coach';}
      If (record.Status == 'Reached Target - Thinking About It' ){
          StrStatus = 'Decision Pending';}
          
    SD_Member__C SD1 = new SD_Member__C(ID=record.WhatId,Enrollment_Progress_Status__c=strStatus);
    update SD1; 
    
    }  }
Thanks, 

Todd B.
Hello,

I am looking to create a cutom button, like below but i get below error. I have few visualforce pages but i cant see them.
User-added image
  • July 24, 2015
  • Like
  • 0
Hi Developers
I am facing this error
Please help me to solve this problem and my code are
Class# consolewrap 
public class consolewrap {

public String class_id{get;set;}

public String class_time{get;set;}

public String tutor_id{get;set;}

public String tutor_name{get;set;}

public String tutor_email{get;set;} 

public String tutor_phone{get;set;}

}

Class # Calloutcontroller 
public class Calloutcontroller {

public List<consolewrap> ConsoleWrapperList{get;set;}

public List<consolewrap> getperformcallout(){

ConsoleWrapperList = new List<consolewrap>();

HttpRequest req = new HttpRequest();

HttpResponse res = new HttpResponse();

Http http = new Http();

req.setEndpoint('http://www.itutorindia.com/angularjs/api/smallWidget/tutorHourSalesForce');

req.setMethod('GET');

res = http.send(req);

if(res.getstatusCode() == 200 && res.getbody() != null){

ConsoleWrapperList=(List<consolewrap>)json.deserialize(res.getbody(),List<consolewrap>.class);
}
return consolewrapperlist;
}
}

VF PAGE #
<apex:page controller="Calloutcontroller" title="JSON table" >
<apex:form > <apex:pageBlock >
<apex:pageBlockTable value="{!performcallout}" var="wrap">
<apex:column headerValue="class id" value="{!wrap.class_id}"/>
<apex:column headerValue="class time" value="{!wrap.class_time}"/>
<apex:column headerValue="tutor id" value="{!wrap.tutor_id}"/>
<apex:column headerValue="tutor name" value="{!wrap.tutor_name}"/>
<apex:column headerValue="tutor email" value="{!wrap.tutor_email}"/>
<apex:column headerValue="tutor phone" value="{!wrap.tutor_phone}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>

I had made the remote site also
here i am generating xml file.proviously it was working fine now i am getting error too many soql queries.
here i am generating XML file.it was working fine till now. but now iam facing this exception.
my code is

public class OutBoundListingData {
    
    public static string genratedXML{get;set;}
    
    public OutBoundListingData()
    {
        GenerateListingXML();
    }
    
    public static List<pba__Listing__c> getListingRecords()
    {
        List<pba__Listing__c> objListListing=[select Id,ListingId__c,pba__Property__c,Common_Charges__c,pba__Address_pb__c,
                                              of_Units__c,pba__City_pb__c,pba__State_pb__c,pba__PostalCode_pb__c,
                                              pba__Latitude_pb__c,pba__Longitude_pb__c,pba__Country_pb__c
                                              ,Street_Intersection__c,Display_Address__c,pba__Status__c,
                                              Listing_Status__c,pba__ListingType__c,pba__ListingPrice_pb__c,
                                              pba__Listing_Website__c,Listed_Date__c,Listing_Email__c,Move_in_Date__c,
                                              HasGarden__c,HasBackyard__c,HasBalcony__c,HasTerrace__c,HasPrivateRoofDeck__c,
                                              HasPrivateCourtyard__c,HasStorageSpace__c,HasGarage__c,HasRoofGarden__c,
                                              HasHealthClub__c,HasCourtyard__c,UtilitiesIncluded__c,HasWasherDryer__c,
                                              Pets_Allowed__c,Commission__c,OPPaidToCobroker__c,Lease_Term_Type__c,
                                              Lease_Type__c,Move_In_Fee__c,Move_Out_Fee__c,Pet_Security_Amount__c,
                                              Security_Deposit__c,Fee_Type__c,Name,pba__Description_pb__c,pba__Bedrooms_pb__c,
                                              pba__FullBathrooms_pb__c,Rooms__c,pba__LotSize_pb__c,pba__YearBuilt_pb__c,
                                              Prepost__c,pba__PropertyType__c,Building_Description__c,Condition__c,
                                              Exposures__c,Showing_Instructions__c,View__c,NewDevelopment__c,
                                              Construction_Era__c,Building_Type__c,Lobby_Attendance__c,Block__c,
                                              Management_Company__c,pba__Listing_Agent_Firstname__c,
                                              pba__Listing_Agent_Lastname__c,pba__Listing_Agent_Email__c,
                                              pba__Listing_Agent_Photo__c,pba__Listing_Agent_Mobil_Phone__c,
                                              pba__Listing_Agent_Phone__c,Listing_Agent_Brokerage_Name__c,
                                              pba__Listing_Agent_Street__c,pba__Listing_Agent_City__c,pba__Listing_Agent_Zip__c,
                                              Neighborhood__c,Neighborhood_Description__c,Appliances__c,Cooling_Systems__c,
                                              Elevator__c,Exterior_Types__c,Floor_Coverings__c,of_Floors__c,NewConstruction__c ,
                                              Listing_Secondary_Agent_Firstname__c,Listing_Secondary_Agent_Lastname__c,
                                              Listing_Secondary_Agent_Email__c,Listing_Secondary_Agent_Photo__c,
                                              Listing_Secondary_Agent_Mobil_Phone__c,Listing_Secondary_Agent_Phone__c,
                                              Listing_Secondary_Agent_Brokerage_Name__c,Listing_Secondary_Agent_Street__c,
                                              Listing_Secondary_Agent_City__c,Listing_Secondary_Agent_Zip__c ,
                                              Floorplan_URL__c,Listing_URL__c from pba__Listing__c where RLSListingKey__c=null];
        return objListListing;
    }
    public static void GenerateListingXML()
    {
        XmlStreamWriter w =new XmlStreamWriter();  
        w.writeStartElement(null,'Listings',null);            
            for(pba__Listing__c Item : getListingRecords()){               
                w.writeStartElement(null,'Listing',null);               
                w.writeStartElement(null, 'Type', null);
                w.writeCharacters(Item.pba__ListingType__c);  
                w.writeEndElement();
                w.writeStartElement(null, 'WebID', null);
                w.writeCharacters(Item.Id);
                w.writeEndElement();
                w.writeStartElement(null,'ListingId', null);
                w.writeCharacters(Item.ListingId__c);
                w.writeEndElement();
                w.writeStartElement(null, 'CommonCharges', null);
                if(Item.Common_Charges__c!=null)
                    w.writeCharacters(String.valueOf(Item.Common_Charges__c));  
                w.writeEndElement();              
                w.writeStartElement(null, 'Floorplans', null);               
                w.writeStartElement(null, 'Floorplan', null);
                w.writeStartElement(null, 'PictureUrl', null);
                if(Item.Floorplan_URL__c!=null)
                    w.writeCharacters(String.valueOf(Item.Floorplan_URL__c));  
                w.writeEndElement();   
                w.writeEndElement();                 
                w.writeEndElement();                 
                w.writeStartElement(null, 'Commission', null);
                if(Item.Commission__c!=null)
                    w.writeCharacters(String.valueOf(Item.Commission__c));  
                w.writeEndElement();              
                w.writeStartElement(null, 'UnitNumber', null);
                if(Item.of_Units__c!=null)
                    w.writeCharacters(String.valueOf(Item.of_Units__c));  
                w.writeEndElement();    
                w.writeStartElement(null, 'City', null);
                if(Item.pba__City_pb__c!=null)
                    w.writeCharacters(String.valueOf(Item.pba__City_pb__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'State', null);
                if(Item.pba__State_pb__c!=null)
                    w.writeCharacters(String.valueOf(Item.pba__State_pb__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'Zip', null);
                if(Item.pba__PostalCode_pb__c!=null)
                    w.writeCharacters(String.valueOf(Item.pba__PostalCode_pb__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'Lat', null);
                if(Item.pba__Latitude_pb__c!=null)
                    w.writeCharacters(String.valueOf(Item.pba__Latitude_pb__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'Long', null);
                if(Item.pba__Longitude_pb__c!=null)
                    w.writeCharacters(String.valueOf(Item.pba__Longitude_pb__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'County', null);
                if(Item.pba__Country_pb__c!=null)
                    w.writeCharacters(String.valueOf(Item.pba__Country_pb__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'StreetIntersection', null);
                if(Item.Street_Intersection__c!=null)
                    w.writeCharacters(String.valueOf(Item.Street_Intersection__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'DisplayAddress', null);
                if(Item.Display_Address__c!=null)
                    w.writeCharacters(String.valueOf(Item.Display_Address__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'Neighborhood', null);
                if(Item.Neighborhood__c!=null)
                    w.writeCharacters(String.valueOf(Item.Neighborhood__c));  
                w.writeEndElement();               
                w.writeEndElement();
                w.writeStartElement(null, 'ListingDetails', null);               
                w.writeStartElement(null, 'Status', null);
                if(Item.pba__Status__c!=null)
                    w.writeCharacters(String.valueOf(Item.pba__Status__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'ListingStatus', null);
                if(Item.pba__Status__c!=null)
                    w.writeCharacters(String.valueOf(Item.pba__Status__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'ListingType', null);
                if(Item.pba__ListingType__c!=null)
                    w.writeCharacters(String.valueOf(Item.pba__ListingType__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'Price', null);
                if(Item.pba__ListingPrice_pb__c!=null)
                    w.writeCharacters(String.valueOf(Item.pba__ListingPrice_pb__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'ListingUrl', null);
                if(Item.pba__Listing_Website__c!=null)
                    w.writeCharacters(String.valueOf(Item.pba__Listing_Website__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'DateListed', null);
                if(Item.Listed_Date__c!=null)
                    w.writeCharacters(String.valueOf(Item.Listed_Date__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'ListingEmail', null);
                if(Item.Listing_Email__c!=null)
                    w.writeCharacters(String.valueOf(Item.Listing_Email__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'DateAvailable', null);
                if(Item.Move_in_Date__c!=null)
                    w.writeCharacters(String.valueOf(Item.Move_in_Date__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'HasGarden', null);
                if(Item.HasGarden__c!=null)
                    w.writeCharacters(String.valueOf(Item.HasGarden__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'HasBackyard', null);
                if(Item.HasBackyard__c!=null)
                    w.writeCharacters(String.valueOf(Item.HasBackyard__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'HasBalcony', null);
                if(Item.HasBalcony__c!=null)
                    w.writeCharacters(String.valueOf(Item.HasBalcony__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'HasTerrace', null);
                if(Item.HasTerrace__c!=null)
                    w.writeCharacters(String.valueOf(Item.HasTerrace__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'HasPrivateRoofDeck', null);
                if(Item.HasPrivateRoofDeck__c!=null)
                    w.writeCharacters(String.valueOf(Item.HasPrivateRoofDeck__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'HasPrivateCourtyard', null);
                if(Item.HasPrivateCourtyard__c!=null)
                    w.writeCharacters(String.valueOf(Item.HasPrivateCourtyard__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'HasStorageSpace', null);
                if(Item.HasStorageSpace__c!=null)
                    w.writeCharacters(String.valueOf(Item.HasStorageSpace__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'HasGarage', null);
                if(Item.HasGarage__c!=null)
                    w.writeCharacters(String.valueOf(Item.HasGarage__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'HasRoofGarden', null);
                if(Item.HasRoofGarden__c!=null)
                    w.writeCharacters(String.valueOf(Item.HasRoofGarden__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'HasHealthClub', null);
                if(Item.HasHealthClub__c!=null)
                    w.writeCharacters(String.valueOf(Item.HasHealthClub__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'HasCourtyard', null);
                if(Item.HasCourtyard__c!=null)
                    w.writeCharacters(String.valueOf(Item.HasCourtyard__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'UtilitiesIncluded', null);
                if(Item.UtilitiesIncluded__c!=null)
                    w.writeCharacters(String.valueOf(Item.UtilitiesIncluded__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'HasWasherDryer', null);
                if(Item.HasWasherDryer__c!=null)
                    w.writeCharacters(String.valueOf(Item.HasWasherDryer__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'AllowsPets', null);
                if(Item.Pets_Allowed__c!=null)
                    w.writeCharacters(String.valueOf(Item.Pets_Allowed__c));  
                w.writeEndElement();                                 
                w.writeStartElement(null, 'PetSecurityAmount', null);
                if(Item.Pet_Security_Amount__c!=null)
                    w.writeCharacters(String.valueOf(Item.Pet_Security_Amount__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'SecurityDeposit', null);
                if(Item.Security_Deposit__c!=null)
                    w.writeCharacters(String.valueOf(Item.Security_Deposit__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'FeeType', null);
                if(Item.Fee_Type__c!=null)
                    w.writeCharacters(String.valueOf(Item.Fee_Type__c));  
                w.writeEndElement();                
                w.writeEndElement();
                w.writeStartElement(null, 'BasicDetails', null);                
                w.writeStartElement(null, 'Title', null);
                if(Item.Name!=null)
                    w.writeCharacters(String.valueOf(Item.Name));  
                w.writeEndElement();
                w.writeStartElement(null, 'Description', null);
                if(Item.pba__Description_pb__c!=null)
                    w.writeCharacters(String.valueOf(Item.pba__Description_pb__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'Bedrooms', null);
                if(Item.pba__Bedrooms_pb__c!=null)
                    w.writeCharacters(String.valueOf(Item.pba__Bedrooms_pb__c));  
                w.writeEndElement();                  
                w.writeStartElement(null, 'Prepost', null);
                if(Item.Prepost__c!=null)
                    w.writeCharacters(String.valueOf(Item.Prepost__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'PropertyType', null);
                if(Item.pba__PropertyType__c!=null)
                    w.writeCharacters(String.valueOf(Item.pba__PropertyType__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'BuildingType', null);
                if(Item.Building_Type__c!=null)
                    w.writeCharacters(String.valueOf(Item.Building_Type__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'BuildingDescription', null);
                if(Item.Building_Description__c!=null)
                    w.writeCharacters(String.valueOf(Item.Building_Description__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'Condition', null);
                if(Item.Condition__c!=null)
                    w.writeCharacters(String.valueOf(Item.Condition__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'Exposures', null);
                if(Item.Exposures__c!=null)
                    w.writeCharacters(String.valueOf(Item.Exposures__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'ShowingInstructions', null);
                if(Item.Showing_Instructions__c!=null)
                    w.writeCharacters(String.valueOf(Item.Showing_Instructions__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'Views', null);
                if(Item.View__c!=null)
                    w.writeCharacters(String.valueOf(Item.View__c));  
                w.writeEndElement();                          
                w.writeEndElement();            
                w.writeStartElement(null, 'Building', null);               
                w.writeStartElement(null, 'NewDevelopment', null);
                if(Item.NewDevelopment__c!=null)
                    w.writeCharacters(String.valueOf(Item.NewDevelopment__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'ConstructionEra', null);
                if(Item.Construction_Era__c!=null)
                    w.writeCharacters(String.valueOf(Item.Construction_Era__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'BuildingType', null);
                if(Item.Building_Type__c!=null)
                    w.writeCharacters(String.valueOf(Item.Building_Type__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'LobbyAttendance', null);
                if(Item.Lobby_Attendance__c!=null)
                    w.writeCharacters(String.valueOf(Item.Lobby_Attendance__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'Block', null);
                if(Item.Block__c!=null)
                    w.writeCharacters(String.valueOf(Item.Block__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'Lot', null);
                if(Item.pba__LotSize_pb__c!=null)
                    w.writeCharacters(String.valueOf(Item.pba__LotSize_pb__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'ManagementCompany', null);
                if(Item.Management_Company__c!=null)
                    w.writeCharacters(String.valueOf(Item.Management_Company__c));  
                w.writeEndElement();               
                w.writeEndElement();             
                w.writeStartElement(null, 'Pictures', null);
                List<pba__PropertyMedia__c> ListImages= [select id,pba__URL__c from pba__PropertyMedia__c where pba__Property__c=:Item.pba__Property__c ];               
                for(pba__PropertyMedia__c objImages: ListImages)
                {
                    w.writeStartElement(null, 'Picture', null);                   
                    w.writeStartElement(null, 'PictureUrl', null);  
                    if(objImages.pba__URL__c != null)
                        w.writeCharacters(String.valueOf(objImages.pba__URL__c));  
                    w.writeEndElement();                    
                    w.writeEndElement();
                }
                w.writeEndElement();            
                w.writeStartElement(null, 'Videos', null);
                w.writeEndElement();
                w.writeStartElement(null, 'SecondaryAgent', null);               
                w.writeStartElement(null, 'FirstName', null);
                if(Item.Listing_Secondary_Agent_Firstname__c !=null)
                    w.writeCharacters(String.valueOf(Item.Listing_Secondary_Agent_Firstname__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'LastName', null);
                if(Item.Listing_Secondary_Agent_Lastname__c!=null)
                    w.writeCharacters(String.valueOf(Item.Listing_Secondary_Agent_Lastname__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'EmailAddress', null);
                if(Item.Listing_Secondary_Agent_Email__c!=null)
                    w.writeCharacters(String.valueOf(Item.Listing_Secondary_Agent_Email__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'PictureUrl', null);
                if(Item.Listing_Secondary_Agent_Photo__c!=null)
                    w.writeCharacters(String.valueOf(Item.Listing_Secondary_Agent_Photo__c));  
                w.writeEndElement();
                w.writeStartElement(null, 'MobilePhoneLineNumber', null);
                if(Item.Listing_Secondary_Agent_Mobil_Phone__c!=null)
                    w.writeCharacters(String.valueOf(Item.Listing_Secondary_Agent_Mobil_Phone__c));  
                w.writeEndElement();
               
              
               
          w.writeEndElement();
        string xml = w.getXmlString();
        w.close();
        genratedXML='<?xml version="1.0"?>'+xml;
    }
}

 
I've written this class called createExpense, and I use the Process Builder to pass parameters to a static void method. My test class only covers 25%.  And I'm trying to get this higher. So, my first thought is that I need to write some system.asserts. This is where my problem/confusion starts. it seems the only way to test a static method is to give it the parameters it expects within a test class and the rest should be taken care of. This has worked great for me in the past...resulting in 100% coverage, but not this time. So, in order to write some system.asserts I tried to instatiate the class so that I would have a variable to reference and write assets with, but the platform won't let you do that. 

So, looking for some ideas out there. I have posted the class, test class and screenshot of coverage.
 
global class createExpense {
    @InvocableMethod
    public static void createExpense(List<String> InvId) {
    List<Expense__c> newExps = new List<Expense__c>();
    List<Expense_Line_Item__c> newExpLIs = new List<Expense_Line_Item__c>();
    Map<ID,Set<Invoice_Line_Item__c>> invLIs = new Map<ID,Set<Invoice_Line_Item__c>>();
    Set<Id> usedAccounts = new Set<Id>();  
    Expense__c newExp = new Expense__c(); 
   

  for(Invoice_Line_Item__c invLI : [select Id, CurrencyIsoCode, Product__r.Id, Invoicing__r.Id, Invoicing__r.Project__r.Id, Product__r.Account__r.Id, Product_Platform__c, Product_Family__c,Line_Item_Description__c, Quantity__c, Payment_Per_Complete__c, Top_up_Reason__c from Invoice_Line_Item__C where Invoicing__c IN :InvId AND Product__r.Direct_Expense__c = True]) {
    Set<Invoice_Line_Item__c> invLIsList = invLIs.get(invLI.Product__r.Account__r.Id);
    if(invLIsList == null) {
        invLIsList = new Set<Invoice_Line_Item__c>();
        invLIs.put(invLI.Product__r.Account__r.Id,invLIsList);
    }
    invLIsList.add(invLI);
  }
    System.debug('=============invLIs.keySet():'+invLIs.keySet());
    for(Id mapKey : invLIs.keySet()) {
        System.debug('---------------mapKey:'+mapKey);
        System.debug('======usedAccounts0:'+usedAccounts);
        if(!usedAccounts.contains(mapKey)) {
             usedAccounts.add(mapKey);
            for(Invoice_Line_Item__c inv1: invLIs.get(mapKey)) {
                System.debug('======usedAccounts1:'+usedAccounts);
                    System.debug('======usedAccounts2:'+usedAccounts);
                    System.debug('======inv1.Product__r.Account__r.Id:'+inv1.Product__r.Account__r.Id);
                     newExp = new Expense__c(
                        Project__c = inv1.Invoicing__r.Project__r.Id,
                        Account__c = inv1.Product__r.Account__r.Id,
                        Invoice__c = inv1.Invoicing__r.Id,
                        Top_up_Reason__c = inv1.Top_up_Reason__c,
                        Target_Group__c = inv1.Line_Item_Description__c,
                        Top_up_Type__c = 'At quoting',
                        Expense_Type__c = inv1.Product_Platform__c == 'Survey Tool' ? 'Survey Tool' : 
                         				  inv1.Product_Family__c == 'Survey Respondents' && inv1.Product_Platform__c == 'External' ? 'AH Fee: Top-Up' :
                         				  inv1.Product_Family__c == 'Survey Respondents' && inv1.Product_Platform__c == 'Pureprofile' ? 'AH Fee: PP' :
                         				  inv1.Product_Family__c == 'Survey Respondents' && inv1.Product_Platform__c == 'NEWS' ? 'AH Fee: NEWS' :
                         				  inv1.Product_Family__c == 'Survey Respondents' && inv1.Product_Platform__c == 'AA Smartfuel' ? 'AH Fee: Smartfuel' :
                         				  'Unknown',
                        CurrencyIsoCode = inv1.CurrencyIsoCode 
                    );
                    
                }  
            newExps.add(newExp);
        }
        System.debug('---------------------End of the for loop.');
    }  
    insert newExps;

    for(Expense__c exp : newExps) {
        for(Invoice_Line_Item__c invLi2 : invLis.get(exp.Account__c)) {
            Expense_Line_Item__c eli = new Expense_Line_Item__c(
                Expense__c = exp.Id,
                Product__c = invLI2.Product__c,
                Expense_Type__c = invLI2.Product_Family__c,
                Quantity__c = invLI2.Quantity__c,
                Amount__c = invLI2.Payment_Per_Complete__c,
                CurrencyIsoCode = invLi2.CurrencyIsoCode
        );
        newExpLIs.add(eli);
        }
    }
    insert newExpLIs;
   }
}
 
@isTest
public class testCreateExpense {

    static testMethod void expenseTest() {
        Id opptyRecordType1 = Schema.SObjectType.Opportunity.getRecordTypeInfosByName().get('Opportunity - Research').getRecordTypeId();
        Account a1 = (Account)TestFactory.createSObject(new Account(), true);
        List<Product2> prodList1 = (List<Product2>)TestFactory.createSObjectList(new Product2(),5,true);
        List<PriceBookEntry> standardPBEList1 = new List<PriceBookEntry>();
        Id standardPBEId1 = Test.getStandardPricebookId();
        Contact c1 = (Contact)TestFactory.createSObject(new Contact(AccountId = a1.Id),true);
        Opportunity o1 = (Opportunity)TestFactory.createSObject(new Opportunity(AccountId = a1.Id, RecordTypeId = opptyRecordType1),true);
        Quote q1 = (Quote)TestFactory.createSObject(new Quote(OpportunityId = o1.Id),true);
        List<QuoteLineItem> qliList = new List<QuoteLineItem>();
        Project__c prj1 = (Project__c)TestFactory.createSObject(new Project__c(Opportunity__c = o1.Id),true);
        Invoicing__c inv1 = (Invoicing__c)TestFactory.createSObject(new Invoicing__c(Project__c = prj1.Id, Price_Book__c = standardPBEId1),true);
        List<String> InvId1 = new List<String>();
        List<Invoice_Line_Item__c> invLIList = new List<Invoice_Line_Item__c>();
        List<String> ILIIDs = new List<String>();
        
        o1.SyncedQuoteId = q1.Id;
        Update o1;
        
        Product2 prod1a = prodList1.get(0);
        prod1a.Platform__c = 'External';
        Prod1a.Family = 'Research - Survey Respondents';
        Product2 prod2a = prodList1.get(1);
        prod2a.Platform__c = 'Survey Tool';
        prod2a.Family = 'Research - Hosting Fee';
        Product2 prod3a = prodList1.get(2);
        prod3a.Platform__c = 'Pureprofile';
        prod3a.Family = 'Research - Survey Respondents';
        update prodList1;
        
        for(Product2 prod1 : prodList1) {
            PriceBookEntry pbe = new PriceBookEntry(
                Product2Id = prod1.Id,
                PriceBook2Id = standardPBEId1,
                CurrencyIsoCode = 'AUD',
                UnitPrice = 1,
                Payment_Per_Complete__c = .5,
                IsActive = True
            );
            standardPBEList1.add(pbe);
        }
        insert standardPBEList1;
    

        for(PriceBookEntry pbe1 : standardPBEList1) {
            QuoteLineItem qli = (QuoteLineItem)TestFactory.createSObject(new QuoteLineItem(QuoteId = q1.Id, PriceBookEntryId = pbe1.Id));
            qliList.add(qli);
            Invoice_Line_Item__c invli = (Invoice_Line_Item__c)TestFactory.createSObject(new Invoice_Line_Item__c(Invoicing__c = inv1.Id,Product__c = pbe1.Product2Id));
            invLILIst.add(invli);
            ILIIDs.add(invli.Id);
        }
        insert qliList;
        insert invLIList;
        
        InvId1.add(inv1.Id);
        createExpense.createExpense(InvId1); 
        createInvoiceLineItem.addListPrice(ILIIDs);
       
       
    }
    
   
    

}

User-added image

What is mean by this error: how can I handle. we already doing null checking,

 For example:

Apex script unhandled exception by user/organization: 00*************TE/00************gRb4
 
Visualforce Page: /apex/ppaccountsummary
 
 
 
caused by: System.NullPointerException: Attempt to de-reference a null object
 
Class.PPOrdersController.<init>: line 17, column 1 
 

Hi,
I have an error in Apex Class:clsOpportunityTeamLayout.
error message: "List has more than 1 row for assignment to SObject Error is in expression '{!DeleteTeamMember}' in page opportunityteamlayout: Class.clsOpportunityTeamLayout.DeleteTeamMember: line 41, column 1 An unexpected error has occurred. Your development organization has been notified."

Apex Class:clsOpportunityTeamLayout:

public class clsOpportunityTeamLayout {
    Id oppid {get;set;}
     public Boolean flag{get;set;}
  List<OpportunityTeamMember__c> oppTeam ;
    ApexPages.StandardController stdCtrl;
    public string SelectedOppTeamId { get; set; }
    
    public clsOpportunityTeamLayout(ApexPages.StandardController controller) {
        //this.accTeam = (AccountTeamMember__c)controller.getRecord();
        stdCtrl = controller;
         
    }
    
       public List<OpportunityTeamMember__c> getoppTeam() {
           
           List<Opportunity> recOpp = [Select Id, Owner.Id, Name from Opportunity WHERE Id = :ApexPages.currentPage().getParameters().get('id') AND Owner.Id = :userinfo.getUserId()];
        if(recOpp.size()>0 && recOpp[0].Owner.Id == userinfo.getUserId()) {
            flag=false;
        }else {
            flag=true;
        }
           oppid = ApexPages.currentPage().getParameters().get('id');
          // system.debug('IDDDDDDDDDD'+oppid);
        oppTeam = [SELECT Opportunity_Access__c, Opportunity__r.Id, 
                   User__r.Name,Notes_Attachments_Access__c,OpportunityTeamMemberRole__c 
                   from OpportunityTeamMember__c WHERE Opportunity__r.Id  = :oppid];

          // system.debug('accTEammmmmmmmmmmmmmmm'+oppTeam);
           stdCtrl.save();
           return oppTeam;
        }
    
     public PageReference DeleteTeamMember() {
         oppid = ApexPages.currentPage().getParameters().get('id');
   // system.debug('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'+SelectedOppTeamId);
        OpportunityTeamMember__c tobeDeleted = null;
        OpportunityShare oppShare;
      for(OpportunityTeamMember__c a : oppTeam)
       if (a.Id == SelectedOppTeamId) {
          tobeDeleted = a;
           oppShare = [select id,OpportunityId, UserOrGroupId from OpportunityShare where OpportunityId = :oppid and UserOrGroupId = :a.User__c];
           //system.debug('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@'+tobeDeleted);
          //break;
       }
      
      //if opportunity record found delete it
      if (tobeDeleted != null) {
      Delete oppShare;
       Delete tobeDeleted;
          
      }
      PageReference retPage = new PageReference('/apex/OpportunityTeamLayout?id='+oppid);
        retPage.setRedirect(true);
             return retPage;
    }
    
    public PageReference DeleteAll() {
    
        Delete oppTeam;
        PageReference retPage = new PageReference('/apex/OpportunityTeamLayout?id='+oppid);
        retPage.setRedirect(true);
         return retPage;
    }
    
    public pagereference DefaultOppTeam()
    {
        Opportunity recOpp=[select OwnerId from Opportunity where id=:ApexPages.currentPage().getParameters().get('id')];
        List<UserTeamMember> listUTM=[Select Id, OwnerId, UserId, OpportunityAccessLevel, TeamMemberRole FROM UserTeamMember where OwnerId=:recOpp.OwnerId];
        List<OpportunityTeamMember__c> listOTM=new List<OpportunityTeamMember__c>();
        List<OpportunityTeamMember__c> listExistOTM=[select id,User__c from OpportunityTeamMember__c where Opportunity__c=:ApexPages.currentPage().getParameters().get('id')];
        Set<Id> setUsrIds=new Set<Id>();
            if(listExistOTM!=null && listExistOTM.size()>0)
            for(OpportunityTeamMember__c recOTM:listExistOTM)
                setUsrIds.add(recOTM.User__c);
        if(listUTM!=null && listUTM.size()>0)
        {
            for(UserTeamMember recUTM:listUTM)  
            {
                if(setUsrIds!=null && setUsrIds.contains(recUTM.UserId))
                {
                    // if user is already present dont add the user in the list
                }
                else
                {
                    OpportunityTeamMember__c recOTM=new OpportunityTeamMember__c(Opportunity__c=ApexPages.currentPage().getParameters().get('id'));
                    recOTM.User__c=recUTM.UserId;
                                      
                    if(recUTM.OpportunityAccessLevel=='Read' )
                    { recOTM.Opportunity_Access__c='Read Only';}
                    else
                    {recOTM.Opportunity_Access__c='Read/Write';}
                    
                    
                    recOTM.OpportunityTeamMemberRole__c =recUTM.TeamMemberRole;
                    recOTM.Notes_Attachments_Access__c='Read Only';
                    listOTM.add(recOTM);
                }
            }
            if(listOTM!=null && listOTM.size()>0)
                    insert listOTM;
        }
        pagereference par=new Pagereference('/apex/OpportunityTeamLayout?id='+oppid);
        return par;
    }

    
    static testmethod void testTeamMember() {
       Boolean flag = true;
        List<Account> accnts = new List<Account>();
         Account account2 = new Account(Name='Test Account 3', Region__c = 'Asia', Country__c = 'CHINA', OWCODE__c = '13');
        accnts.add(account2);
        insert accnts;
        
        List<Opportunity> opps = new List<Opportunity>();
        Opportunity opp1 = new Opportunity(Name='Test opp 1', accountId = account2.Id, StageName = 'Qualifying', CloseDate =Date.Today());
        opps.add(opp1);
        insert opps;
        
        List<OpportunityTeamMember__c> otms = new List<OpportunityTeamMember__c>();
        OpportunityTeamMember__c otm = new OpportunityTeamMember__c(Opportunity__c=opps[0].Id,Opportunity_Access__c = 'Read Write');
        otms.add(otm);
        insert otms;
        
        List<OpportunityShare> oss = new List<OpportunityShare>();
        OpportunityShare oss1 = new OpportunityShare(OpportunityAccessLevel = 'Edit',OpportunityId=opps[0].Id,UserOrGroupId=UserInfo.getUserId()); 
        oss.add(oss1);
       // insert oss;
        
     /*     if(accnts[0].Owner.Id == UserInfo.getUserId() && accnts.size() > 0) {
            flag=false;
        }else{
            flag = true;
        }*/
        
        ApexPages.currentPage().getParameters().put('id',opps[0].Id);
         ApexPages.StandardController stdContrlr= new ApexPages.StandardController(otm);
        clsOpportunityTeamLayout ObjRef=new clsOpportunityTeamLayout (stdContrlr);
        
        ObjRef.getoppTeam();
        ObjRef.DeleteTeamMember();
        ObjRef.DeleteAll();
        ObjRef.DefaultOppTeam();
        
    }

}

Any help would be appreciated.

Thanks
What type of code represents the controller in MVC architecture on the force.com platform?
Choose 2 answers
1. Javascript that is used to make a menu item display itself
2. Standardcontroller system methods that are reference by Visualforce
3. Customer Apex and Javascript code that is used to manipulate data
4. A Static resrouce that contains CSS and images

one of the answer is (2), but for another pick I am confused between (1) and (2).
are standardcontroller system methods part of Controller of MVC architecture.

Please help.
Hi guys/gals,

Do you have any idea on how to obtain the Cloak of Adventure sweatshirt after completing 5 badges on trailheads?

Source: http://go.pardot.com/l/27572/2016-01-06/4wy4tn?utm_campaign=newyear-trailhead-sweatshirt

I haven't received any email address or notification about the completion after I had received 5 new badges on my profile. 

The sweetshirt looks really cool and I want to get it :D  Ty
 
I have a String dtme = "20150901174244"(YYYYMMDDHHMMSS)  I need to convert it to a DateTime in APEX like 01/09/2015 5:42 PM.   Would someone be able to show me the code to do this properly?

 any help is much appreciated.
 
I have a trigger on a custom object (before insert and before update) that is looking at the Account object.  The custom object GWU40__c has an email address which is looking at the Account.PersonEmail (person-enabled accounts in Salesforce).

Every time it executes this line:
g.Nominee_Profile_ID__c = AccountMapNominees.get(g.Nominee_Email__c).FIMS_ID__c

it tells me de-referencing a null object (i'm sure it's becasue there isn't an Account with that email address).  
How can I check to see if the Map.get() is returning null?   

-------------------------------
trigger X_GWU40_LookupProfileIDs on GWU40__c (before insert,before update) {
    Set<String> noms = new Set<String>(); //Dedupe the email addresses in case of multiple nominations for the same person (email address)
    
    for(GWU40__c recordsToProcess : Trigger.New)
    {
        if(recordsToProcess.Nominee_EMail__c != null) {
            noms.add(recordsToProcess.Nominee_Email__c);
        }
        
    }
    
    Map<String,Account> AccountMapNominees = New Map<String,Account>();
        For(Account a : [SELECT PersonEmail,Name,FIMS_ID__c from Account where PersonEmail IN: noms]){
            AccountMapNominees.put(a.PersonEmail,a);
        }
      IF((!AccountMapNominees.isEmpty()) && (AccountMapNominees.size() > 0)){

      FOR(GWU40__c g : Trigger.New)
      {
          if (g.Nominee_Email__c != null)
          {            
             g.Nominee_Profile_ID__c = AccountMapNominees.get(g.Nominee_Email__c).FIMS_ID__c;                                 
          }
      }
     } //if 
   
}

------------------------------------
Hi all,
I am writing Test class for apex class and am getting 70% code coverage but the following lines are not covered.
How to write a testclass class for covering this codes.
Highlighted lines are not coverdUser-added image

Thanks
Hello,

Does anyone know if it;s possible to pull in Approval Process fields into a custom Visualforce page?  Specifically, I am trying to find the syntax for displaying the Approval Status.  I don't want to include the related list.  Thanks,
I created a Custom Object called SD_Member__c and on that object is a field Enrollment_Progress_Status__c which gets updated based on the result of a corresponding  Task.  I thought I did everything right, but periodically, I am getting a System.LimitException: Too many DML statements error.  Any ideas where my code may be causing this issue?
trigger Update_SD_Member_Enrollment_Progress_Status on Task (after update) {
/*
Automatically update the "Enrollment Progress Status" field, based upon the "Status" field 
of the last Member Task
*/

// Tasks that meet criteria, and new tasks to create
Task[] qualifiedTasks = new Task[0], newTasks = new Task[0];

Date dt=DateTime.now().addDays(1).date();
Date rt=DateTime.now().addDays(1).date();
    
// Map of SD Members
   Map<Id,SD_Member__c> members = new Map<Id,SD_Member__c>();

Map<id,Task> TaskMap = new Map<id,Task>([select id,RecordType.Name from Task 
                                         where id in : Trigger.newmap.keyset()]);
// Find qualifying tasks
for(Task record:Trigger.new)
        if(TaskMap.get(Record.id).RecordType.Name =='Member Outreach' &&
           record.isclosed == True)
           qualifiedtasks.add(record);
    
    // Obtain member ID values
    for(Task record:qualifiedtasks)
        members.put(record.whatid,null);
   
    // If there are any members to query, do so.
    if(!members.isempty())
        members.putall([select id, Enrollment_Progress_Status__c from SD_Member__c where id in :members.keyset()]);


 // For each qualifying task, check the current Enrollment_Progress_Status__c from SD_Member__c and assign
 // to the strStatus variable.  That way if the Task Status does not meet the critera below, the status 
 // will reamin it's current value 
for(Task record:qualifiedtasks) {
    String strStatus = members.get(record.whatid).Enrollment_Progress_Status__c;    

    // Set the strStatus based on the current Task Status value
      If (record.Status == 'Not Started' ){
          StrStatus = 'Attempting to Contact';}
      If (record.Status == 'Left Message w/ Person' ){
          StrStatus = 'Successful Contact';}
      If (record.Status == 'Member Hung Up' ){
          StrStatus = 'Successful Contact';}
      If (record.Status == 'Phone # Invalid' ){
          StrStatus = 'Phone # Invalid';}
      If (record.Status == 'Reached Recording - No Msg Left' ){
          StrStatus = 'Attempting to Contact';}
      If (record.Status == 'Reached Target - Call Later' ){
          StrStatus = 'Successful Contact';} 
      If (record.Status == 'Reached Recording - No Msg Left' ){
          StrStatus = 'Attempting to Contact';}              
      If (record.Status == 'Reached Target - Call Later' ){
          StrStatus = 'Successful Contact';}
      If (record.Status == 'Reached Target - Declined - Copay' ){
          StrStatus = 'Declined - Copay';}
      If (record.Status == 'Reached Target - Declined - Other' ){
          StrStatus = 'Declined - Other';}
      If (record.Status == 'Reached Target - Declined - Transport' ){
          StrStatus = 'Declined - Transportation';}
      If (record.Status == 'Reached Target - Requested Info' ){
          StrStatus = 'Decision Pending';}
      If (record.Status == 'Reached Target - Sent to Care Coach' ){
          StrStatus = 'Referred to Care Coach';}
      If (record.Status == 'Reached Target - Thinking About It' ){
          StrStatus = 'Decision Pending';}
          
    SD_Member__C SD1 = new SD_Member__C(ID=record.WhatId,Enrollment_Progress_Status__c=strStatus);
    update SD1; 
    
    }  }
Thanks, 

Todd B.
Hello Everyone,

I was having hard time to build the Valiadtion rule on Case status field.

User creates a record with status "New and they save records and again they can come over and change the status to Ready"  from interface the fields get updated to "Sent" once the status has values sent i am not supposed to allow the user to chnage the status values from case deatil page

Thanks

Regards,
Jyo
Exception System.InvalidParameterValueException: Invalid ID.
6:31:23.257 (257944442)|USER_DEBUG|[196]|DEBUG|Deleted Successfulyka1m00000008cObAAI
16:31:23.257 (257949254)|SYSTEM_METHOD_EXIT|[196]|System.debug(ANY)
16:31:23.257 (257961641)|SYSTEM_METHOD_ENTRY|[197]|KM_DisplayArticleDataviewController.__sfdc_selectedKnowledgeId()
16:31:23.257 (257989994)|SYSTEM_METHOD_EXIT|[197]|KM_DisplayArticleDataviewController.__sfdc_selectedKnowledgeId()
16:31:23.258 (258004532)|SYSTEM_METHOD_ENTRY|[197]|System.debug(ANY)
16:31:23.258 (258010574)|USER_DEBUG|[197]|DEBUG|Deleted SuccessfulykA1m00000008aKGCAY
16:31:23.258 (258014979)|SYSTEM_METHOD_EXIT|[197]|System.debug(ANY)
16:31:23.258 (258024951)|SYSTEM_METHOD_ENTRY|[199]|KM_DisplayArticleDataviewController.__sfdc_rejectedValidationStatus()
16:31:23.258 (258051279)|SYSTEM_METHOD_EXIT|[199]|KM_DisplayArticleDataviewController.__sfdc_rejectedValidationStatus()
16:31:23.258 (258087213)|SYSTEM_METHOD_ENTRY|[201]|KM_DisplayArticleDataviewController.__sfdc_selectedArchived()
16:31:23.258 (258107462)|SYSTEM_METHOD_EXIT|[201]|KM_DisplayArticleDataviewController.__sfdc_selectedArchived()
16:31:23.258 (258253700)|SYSTEM_METHOD_ENTRY|[202]|KbManagement.PublishingService.publishArticle(String, Boolean)
16:31:23.265 (265281002)|SYSTEM_METHOD_EXIT|[202]|KbManagement.PublishingService.publishArticle(String, Boolean)
16:31:23.265 (265344845)|SYSTEM_METHOD_ENTRY|[215]|String.valueOf(Object)
16:31:23.265 (265387566)|SYSTEM_METHOD_EXIT|[215]|String.valueOf(Object)
16:31:23.265 (265403723)|SYSTEM_METHOD_ENTRY|[215]|System.debug(ANY)
16:31:23.265 (265409661)|USER_DEBUG|[215]|DEBUG|Exception System.InvalidParameterValueException: Invalid ID.
After Lead Consultant is chosen from the picklist, the task can not be saved without a Completed Date. I am getting 

Error: Field Final_Review_Lead_Consultant__c is a picklist field. Picklist fields are only supported in certain functions.

What am I missing? 

AND( 
 Completed_Date__c = TODAY(),
ISPICKVAL (Final_Review_Lead_Consultant__c=TRUE 
))

User-added image
My organization has some products that only the customer uses and some that are only used internally within the organization. Now, since the form for both types of tickets (external and internal) is the same, one product field (Multi-select Picklist) has all the products in it. But I cannot put this field on the Self-Service portal as I do not want my customers to see the tools that we use internally. Also, I cannot divide the page into external or internal. My only option here is to create a new Multi-select Picklist field with only the external products and put that field on the self service portal. What I want to achieve is that the value from the field in the SSP should be replicated on the product field with all the products.

So, How do I copy the values present in one Multi-select Picklist to another Multi-select Picklist field?

I think maybe an apex code could be of use here.

Any help in the matter would be appreciated.
I made some major changes to a handler class that references custom objects from a managed package and it no longer passes 75% coverage so I needed to add a lot of test coverage to handle it. In my test coverage I created a new account, new opportunity linked to that account, new zuora quote (managed package) linked to the opp and account, and new quote charges (managed package) linked to the zuora quote.

However, the test class fails with an error on attempting to de-refernce a null object on the line that is supposed to insert the quote charges (last object). Coincidentally, that is the object that I need to insert to increase coverage. While investigating, I went into SFDC and manually created a quote charge and saved it. After I press save, it immediately tries to load the newly saved record but instead brings me to the page that says:

"The record you attempted to access has been deleted. The user who deleted this record may be able to recover it from the Recycle Bin. Deleted data is stored in the Recycle Bin for 15 days."

What is the easiest/best way for me to determine how/why these records are being deleted immediately after creation?
Hello,

I am looking to create a cutom button, like below but i get below error. I have few visualforce pages but i cant see them.
User-added image
  • July 24, 2015
  • Like
  • 0