You need to sign in to do that
Don't have an account?
Test Method - System.NullPointerException: Attempt to de-reference a null object
My test method fails due to a null pointer exception but this does no hapen in the UI runtime.
I get this both on the Save Method and Save Override. If I can fix the Save then I'm sure I can apply it to the override.
This is a custom Lookup with a New/Add function.
The Test Method - the error is noted in a comment above the line. I also had trouble with the runsearch at the end.
Any ideas? Thanks.
/**
* Purpose : This class contains unit tests for the Trip Report controller extension.
*/
@isTest(seeAllData=true)
private class Test_CustomCampaignLkpCtrl{
private static ApexPages.StandardController ctl;
private static CustomCampaignLookupController ext;
private static ApexPages.StandardController ctlWithRecord;
private static CustomCampaignLookupController extWithRecord;
private static User mockAdminUser;
private static Campaign r;
static{
TripRptTestDataUtilityLib.getActiveAdminUserId();
//Build mock data
// setup With Item();
//Instantiate and empty controller.
ctl = new ApexPages.StandardController(new Campaign());
//Instantiate a full controller.
ctlWithRecord = new ApexPages.StandardController(r);
extWithRecord = new CustomCampaignLookupController(ctlWithRecord);
extWithrecord.isNew = true;
ext = new CustomCampaignLookupController(ctlWithRecord);
system.debug('**********************************');
system.debug('ctlWithRecord: ' + ctlWithRecord);
system.debug('extWithRecord: ' + extWithRecord);
system.debug('**********************************');
} // End
public Campaign campaign {get;set;} // new campaign to create
public List<Campaign> results{get;set;} // search results
public string searchString{get;set;} // search keyword
static testMethod void CanTestSaveOverride(){
String saveUrl = ext.SaveCampaign().getUrl();
}
static testMethod void CanTestSave(){
// Campaign c = new Campaign();
//Run the save() and verify:
//1: modified Report and Items
//2: Redirect URL matches the detail page for new report.
// Populate record.
Campaign extRecord = new Campaign();
extRecord = [select id, name from Campaign LIMIT 1];
extRecord.Name = 'Test Method Name';
extRecord.Description = 'Test Meth Desc';
//ERROR System.NullPointerException: Attempt to de-reference a null object Class.Test_CustomCampaignLkpCtrl.CanTestSave: line 67, column 1
extWithRecord.SaveCampaign();
//Verify the Url after the save() method occurred. chg from .Save()
String saveUrl = ext.SaveCampaign().getUrl();
system.debug( 'Save URL: ' + saveUrl );
// system.debug( 'Detail URL: ' + extWithRecord.controller.view().getURL() );
//ERROR not visible ext.runSearch();
}
} // End Class
The Controller:
/**
* Purpose : This class contains unit tests for the Custom Lookup.
*/
@isTest(seeAllData=true)
private class Test_CustomCampaignLkpCtrl{
private static ApexPages.StandardController ctl;
private static CustomCampaignLookupController ext;
private static ApexPages.StandardController ctlWithRecord;
private static CustomCampaignLookupController extWithRecord;
private static User mockAdminUser;
private static Campaign r;
static{
TripRptTestDataUtilityLib.getActiveAdminUserId();
//Build mock data
// setup With Item();
//Instantiate and empty controller.
ctl = new ApexPages.StandardController(new Campaign());
//Instantiate a full controller.
ctlWithRecord = new ApexPages.StandardController(r);
extWithRecord = new CustomCampaignLookupController(ctlWithRecord);
extWithrecord.isNew = true;
ext = new CustomCampaignLookupController(ctlWithRecord);
system.debug('**********************************');
system.debug('ctlWithRecord: ' + ctlWithRecord);
system.debug('extWithRecord: ' + extWithRecord);
system.debug('**********************************');
} // End
public Campaign campaign {get;set;} // new campaign to create
public List<Campaign> results{get;set;} // search results
public string searchString{get;set;} // search keyword
static testMethod void CanTestSaveOverride(){
String saveUrl = ext.SaveCampaign().getUrl();
}
static testMethod void CanTestSave(){
// Campaign c = new Campaign();
//Run the save() and verify:
//1: modified
//2: Redirect URL matches the detail page for new report.
// Populate record.
Campaign extRecord = new Campaign();
extRecord = [select id, name from Campaign LIMIT 1];
extRecord.Name = 'Test Method Name';
extRecord.Description = 'Test Meth Desc';
//ERROR System.NullPointerException: Attempt to de-reference a null object Class.Test_CustomCampaignLkpCtrl.CanTestSave: line 67, column 1
extWithRecord.SaveCampaign();
//Verify the Url after the save() method occurred. chg from .Save()
String saveUrl = ext.SaveCampaign().getUrl();
system.debug( 'Save URL: ' + saveUrl );
// system.debug( 'Detail URL: ' + extWithRecord.controller.view().getURL() );
//ERROR not visible ext.runSearch();
}
} // End Class
The Page:
<apex:page controller="CustomCampaignLookupController"
title="Search"
showHeader="false"
sideBar="false"
tabStyle="campaign"
id="pg">
<apex:form >
<apex:pageMessages />
<apex:outputPanel id="page" layout="block" style="margin:5px;padding:10px;padding-top:2px;">
<apex:tabPanel switchType="client" selectedTab="name1" id="tabbedPanel">
<!-- SEARCH TAB -->
<apex:tab label="Search" name="tab1" id="tabOne">
<apex:actionRegion >
<apex:outputPanel id="top" layout="block" style="margin:5px;padding:10px;padding-top:2px;">
<apex:outputLabel value="Search" style="font-weight:Bold;padding-right:10px;" for="txtSearch"/>
<apex:inputText id="txtSearch" value="{!searchString}" />
<span style="padding-left:5px"><apex:commandButton id="btnGo" value="Go" action="{!Search}" rerender="searchResults"></apex:commandButton></span>
</apex:outputPanel>
<apex:outputPanel id="pnlSearchResults" style="margin:10px;height:350px;overflow-Y:auto;" layout="block">
<apex:pageBlock id="searchResults">
<apex:pageBlockTable value="{!results}" var="a" id="tblResults">
<apex:column >
<apex:facet name="header">
<apex:outputPanel >Name</apex:outputPanel>
</apex:facet>
<apex:outputLink value="javascript:top.window.opener.lookupPick2('{!FormTag}','{!TextBox}_lkid','{!TextBox}','{!a.Id}','{!a.Name}', false)" rendered="{!NOT(ISNULL(a.Id))}">{!a.Name}</apex:outputLink>
</apex:column>
<apex:column >
<apex:facet name="header">
<apex:outputPanel >Active</apex:outputPanel>
</apex:facet>
<apex:outputLink disabled="true" value="javascript:top.window.opener.lookupPick2('{!FormTag}','{!TextBox}_lkid','{!TextBox}','{!a.isActive}','{!a.Id}', false)" rendered="{!NOT(ISNULL(a.Id))}">{!a.isActive}</apex:outputLink>
</apex:column>
<apex:column >
<apex:facet name="header">
<apex:outputPanel >Type</apex:outputPanel>
</apex:facet>
<apex:outputLink disabled="true" value="javascript:top.window.opener.lookupPick2('{!FormTag}','{!TextBox}_lkid','{!TextBox}','{!a.Type}','{!a.Id}', false)" rendered="{!NOT(ISNULL(a.Id))}">{!a.Type}</apex:outputLink>
</apex:column>
<apex:column >
<apex:facet name="header">
<apex:outputPanel >Description</apex:outputPanel>
</apex:facet>
<apex:outputLink disabled="true" value="javascript:top.window.opener.lookupPick2('{!FormTag}','{!TextBox}_lkid','{!TextBox}','{!a.Description}','{!a.Id}', false)" rendered="{!NOT(ISNULL(a.Id))}">{!a.Description}</apex:outputLink>
</apex:column>
<apex:column >
<apex:facet name="header">
<apex:outputPanel >Expected Revenue</apex:outputPanel>
</apex:facet>
<apex:outputLink disabled="true" value="javascript:top.window.opener.lookupPick2('{!FormTag}','{!TextBox}_lkid','{!TextBox}','{!a.ExpectedRevenue}','{!a.Id}', false)" rendered="{!NOT(ISNULL(a.Id))}">{!a.ExpectedRevenue}</apex:outputLink>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:outputPanel>
</apex:actionRegion>
</apex:tab>
<!-- NEW campaign TAB -->
<apex:tab label="New campaign" name="tab2" id="tabTwo" onclick="rerender">
<apex:pageBlock id="newcampaign" title="{!NewTitle}" >
<apex:pageBlockButtons location="top" >
<apex:commandButton action="{!savecampaign}" value="Save"/>
</apex:pageBlockButtons>
<apex:pageBlockSection title="Campaign Information" columns="2">
<apex:inputField value="{!campaign.Name}" required="true" rendered="{!IsNew}"/>
<apex:outputField value="{!Campaign.Name}" rendered="{!NOT(IsNew)}"/>
<apex:inputField value="{!campaign.Status}"/>
<apex:inputField value="{!campaign.isActive}"/>
<apex:inputField value="{!campaign.Type}"/>
<apex:inputField value="{!campaign.Description}"/>
</apex:pageBlockSection>
<apex:pageBlockSection title="Planning" columns="2" >
<apex:inputField value="{!campaign.StartDate}"/>
<apex:inputField value="{!campaign.ExpectedRevenue}"/>
<apex:inputField value="{!campaign.EndDate}"/>
<apex:inputField value="{!campaign.BudgetedCost}"/>
<apex:inputField value="{!campaign.NumberSent}"/>
<apex:inputField value="{!campaign.ActualCost}"/>
<apex:inputField value="{!campaign.ExpectedResponse}"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:tab>
</apex:tabPanel>
</apex:outputPanel>
</apex:form>
</apex:page>
You'll probably have to post your CustomCampaignLookupController for us to see what is wrong - looks like the error is occurring in there either during SaveCampaign(), or else SaveCampaign() is returning null.
You should also post the full stack trace if you can, instead of just the line the blew up.
Thanks! But its kinda hard to read right now - could you repost it using the 'Insert Code' tool? It's the clipboard icon with a 'C' on it. It preserves code formatting and makes it a lot easier to read.
26.0 APEX_CODE,FINEST;APEX_PROFILING,INFO;CALLOUT,INFO;DB,INFO;SYSTEM,DEBUG;VALIDATION,INFO;VISUALFORCE,INFO;WORKFLOW,INFO 07:17:25.242 (242884000)|EXECUTION_STARTED 07:17:25.242 (242951000)|CODE_UNIT_STARTED|[EXTERNAL]|01pJ00000004u6c|Test_CampaignLkp_Ext.CanTestSave 07:17:25.243 (243972000)|VARIABLE_SCOPE_BEGIN|[7]|Test_CampaignLkp_Ext.ctl|ApexPages.StandardController|true|true 07:17:25.250 (250579000)|VARIABLE_SCOPE_BEGIN|[8]|Test_CampaignLkp_Ext.ext|CustomCampaignLookupController|true|true 07:17:25.250 (250639000)|VARIABLE_SCOPE_BEGIN|[17]|Test_CampaignLkp_Ext.mockAdminUser|User|true|true 07:17:25.250 (250674000)|VARIABLE_SCOPE_BEGIN|[19]|Test_CampaignLkp_Ext.r|Campaign|true|true 07:17:25.251 (251369000)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:5 07:17:25.251 (251384000)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:556 07:17:25.251 (251390000)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:23 07:17:25.251 (251409000)|METHOD_ENTRY|[5]|01pJ00000004u6c|Test_CampaignLkp_Ext.Test_CampaignLkp_Ext() 07:17:25.251 (251416000)|STATEMENT_EXECUTE|[5] 07:17:25.251 (251592000)|HEAP_ALLOCATE|[23]|Bytes:5 07:17:25.251 (251606000)|STATEMENT_EXECUTE|[5] 07:17:25.251 (251610000)|STATEMENT_EXECUTE|[21] 07:17:25.251 (251613000)|STATEMENT_EXECUTE|[23] 07:17:25.284 (284719000)|VARIABLE_SCOPE_BEGIN|[6]|TripRptTestDataUtilityLib.ADMIN_PROFILE_ID|Id|false|true 07:17:25.284 (284745000)|VARIABLE_SCOPE_BEGIN|[11]|TripRptTestDataUtilityLib.AttendeeItemFieldmap|MAP|true|true 07:17:25.284 (284760000)|VARIABLE_SCOPE_BEGIN|[8]|TripRptTestDataUtilityLib.TRIP_REPORT_COUNT|Integer|false|true 07:17:25.284 (284771000)|VARIABLE_SCOPE_BEGIN|[10]|TripRptTestDataUtilityLib.profiles|MAP|true|true 07:17:25.284 (284790000)|HEAP_ALLOCATE|[23]|Bytes:24 07:17:25.284 (284837000)|METHOD_ENTRY|[3]|01pU0000001AYFe|TripRptTestDataUtilityLib.TripRptTestDataUtilityLib() 07:17:25.284 (284845000)|STATEMENT_EXECUTE|[3] 07:17:25.284 (284858000)|HEAP_ALLOCATE|[8]|Bytes:5 07:17:25.284 (284865000)|STATEMENT_EXECUTE|[3] 07:17:25.284 (284869000)|STATEMENT_EXECUTE|[8] 07:17:25.284 (284882000)|HEAP_ALLOCATE|[8]|Bytes:4 07:17:25.284 (284912000)|VARIABLE_ASSIGNMENT|[8]|TripRptTestDataUtilityLib.TRIP_REPORT_COUNT|0 07:17:25.284 (284919000)|STATEMENT_EXECUTE|[10] 07:17:25.284 (284932000)|HEAP_ALLOCATE|[10]|Bytes:4 07:17:25.284 (284976000)|VARIABLE_ASSIGNMENT|[10]|TripRptTestDataUtilityLib.profiles|{"serId":1,"value":{}}|0x611e73a4 07:17:25.284 (284985000)|STATEMENT_EXECUTE|[11] 07:17:25.284 (284992000)|HEAP_ALLOCATE|[11]|Bytes:25 07:17:25.285 (285077000)|SYSTEM_METHOD_ENTRY|[11]|Schema.SObjectType.getDescribe() 07:17:25.286 (286167000)|HEAP_ALLOCATE|[11]|Bytes:4 07:17:25.286 (286189000)|SYSTEM_METHOD_EXIT|[11]|Schema.SObjectType.getDescribe() 07:17:25.286 (286546000)|SYSTEM_METHOD_ENTRY|[11]|Schema.DescribeSObjectResult.getFields() 07:17:25.286 (286614000)|SYSTEM_METHOD_EXIT|[11]|Schema.DescribeSObjectResult.getFields() 07:17:25.286 (286633000)|SYSTEM_METHOD_ENTRY|[11]|Schema.SObjectTypeFields.getMap() 07:17:25.286 (286893000)|HEAP_ALLOCATE|[11]|Bytes:44 07:17:25.286 (286910000)|SYSTEM_METHOD_EXIT|[11]|Schema.SObjectTypeFields.getMap() 07:17:25.287 (287028000)|VARIABLE_ASSIGNMENT|[11]|TripRptTestDataUtilityLib.AttendeeItemFieldmap|"common.apex.runtime.impl.MapValue$FqnMap@a28832e5"|0x67bbd315 07:17:25.287 (287043000)|STATEMENT_EXECUTE|[14] 07:17:25.287 (287047000)|STATEMENT_EXECUTE|[16] 07:17:25.287 (287055000)|HEAP_ALLOCATE|[16]|Bytes:64 07:17:25.287 (287068000)|HEAP_ALLOCATE|[16]|Bytes:4 07:17:25.287 (287301000)|SOQL_EXECUTE_BEGIN|[16]|Aggregations:0|select id, name from Profile where name = 'System Administrator' 07:17:25.290 (290345000)|SOQL_EXECUTE_END|[16]|Rows:1 07:17:25.290 (290362000)|HEAP_ALLOCATE|[16]|Bytes:8 07:17:25.290 (290376000)|HEAP_ALLOCATE|[16]|Bytes:57 07:17:25.290 (290489000)|HEAP_ALLOCATE|[16]|Bytes:8 07:17:25.290 (290509000)|VARIABLE_SCOPE_BEGIN|[16]|ps|LIST|true|false 07:17:25.290 (290557000)|VARIABLE_ASSIGNMENT|[16]|ps|{"serId":1,"value":[{"serId":2,"value":{"Name":"System Administrator","Id":"00eU0000000o1LvIAI"}}]}|0x5d34adec 07:17:25.290 (290620000)|SYSTEM_METHOD_ENTRY|[19]|LIST.iterator() 07:17:25.290 (290856000)|SYSTEM_METHOD_EXIT|[19]|LIST.iterator() 07:17:25.290 (290888000)|SYSTEM_METHOD_ENTRY|[19]|system.ListIterator.hasNext() 07:17:25.290 (290905000)|HEAP_ALLOCATE|[19]|Bytes:5 07:17:25.290 (290916000)|SYSTEM_METHOD_EXIT|[19]|system.ListIterator.hasNext() 07:17:25.290 (290951000)|HEAP_ALLOCATE|[19]|Bytes:12 07:17:25.290 (290967000)|VARIABLE_SCOPE_BEGIN|[19]|p|Profile|true|false 07:17:25.290 (290991000)|VARIABLE_ASSIGNMENT|[19]|p|{"serId":1,"value":{"Name":"System Administrator","Id":"00eU0000000o1LvIAI"}}|0x2d8690c2 07:17:25.291 (291000000)|STATEMENT_EXECUTE|[19] 07:17:25.291 (291005000)|STATEMENT_EXECUTE|[20] 07:17:25.291 (291085000)|SYSTEM_METHOD_ENTRY|[20]|MAP.put(Object, Object) 07:17:25.291 (291114000)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:-4 07:17:25.291 (291132000)|SYSTEM_METHOD_EXIT|[20]|MAP.put(Object, Object) 07:17:25.291 (291146000)|SYSTEM_METHOD_ENTRY|[19]|system.ListIterator.hasNext() 07:17:25.291 (291158000)|HEAP_ALLOCATE|[19]|Bytes:5 07:17:25.291 (291170000)|SYSTEM_METHOD_EXIT|[19]|system.ListIterator.hasNext() 07:17:25.291 (291187000)|VARIABLE_ASSIGNMENT|[19]|p|null| 07:17:25.291 (291196000)|STATEMENT_EXECUTE|[23] 07:17:25.291 (291208000)|HEAP_ALLOCATE|[23]|Bytes:20 07:17:25.291 (291229000)|SYSTEM_METHOD_ENTRY|[23]|MAP.get(Object) 07:17:25.291 (291259000)|SYSTEM_METHOD_EXIT|[23]|MAP.get(Object) 07:17:25.291 (291328000)|VARIABLE_ASSIGNMENT|[23]|TripRptTestDataUtilityLib.ADMIN_PROFILE_ID|"00eU0000000o1LvIAI" 07:17:25.291 (291344000)|METHOD_EXIT|[3]|TripRptTestDataUtilityLib 07:17:25.291 (291380000)|METHOD_ENTRY|[23]|01pU0000001AYFe|TripRptTestDataUtilityLib.getActiveAdminUserId() 07:17:25.291 (291424000)|HEAP_ALLOCATE|[50]|Bytes:5 07:17:25.291 (291433000)|STATEMENT_EXECUTE|[48] 07:17:25.291 (291436000)|STATEMENT_EXECUTE|[50] 07:17:25.291 (291443000)|HEAP_ALLOCATE|[50]|Bytes:80 07:17:25.291 (291452000)|HEAP_ALLOCATE|[50]|Bytes:4 07:17:25.291 (291465000)|HEAP_ALLOCATE|[50]|Bytes:7 07:17:25.291 (291767000)|SOQL_EXECUTE_BEGIN|[50]|Aggregations:0|select Id from User u where (u.ProfileId = :tmpVar1 and IsActive = true) limit 1 07:17:25.295 (295004000)|SOQL_EXECUTE_END|[50]|Rows:1 07:17:25.295 (295021000)|HEAP_ALLOCATE|[50]|Bytes:8 07:17:25.295 (295033000)|HEAP_ALLOCATE|[50]|Bytes:29 07:17:25.295 (295083000)|HEAP_ALLOCATE|[50]|Bytes:8 07:17:25.295 (295098000)|HEAP_ALLOCATE|[50]|Bytes:30 07:17:25.295 (295156000)|HEAP_ALLOCATE|[50]|Bytes:8 07:17:25.295 (295202000)|METHOD_EXIT|[23]|01pU0000001AYFe|TripRptTestDataUtilityLib.getActiveAdminUserId() 07:17:25.295 (295212000)|STATEMENT_EXECUTE|[27] 07:17:25.295 (295241000)|HEAP_ALLOCATE|[27]|Bytes:4 07:17:25.295 (295546000)|VARIABLE_ASSIGNMENT|[27]|Test_CampaignLkp_Ext.ctl|"StandardController [{}]"|0x3cf1cf99 07:17:25.295 (295560000)|STATEMENT_EXECUTE|[30] 07:17:25.295 (295620000)|EXCEPTION_THROWN|[30]|System.NullPointerException: Argument cannot be null 07:17:25.295 (295703000)|HEAP_ALLOCATE|[30]|Bytes:27 07:17:25.295 (295729000)|METHOD_EXIT|[5]|Test_CampaignLkp_Ext 07:17:25.295 (295788000)|HEAP_ALLOCATE|[45]|Bytes:5 07:17:25.295 (295797000)|STATEMENT_EXECUTE|[44] 07:17:25.295 (295801000)|STATEMENT_EXECUTE|[45] 07:17:25.295 (295813000)|HEAP_ALLOCATE|[45]|Bytes:4 07:17:25.295 (295836000)|VARIABLE_SCOPE_BEGIN|[45]|c|Campaign|true|false 07:17:25.295 (295856000)|VARIABLE_ASSIGNMENT|[45]|c|{}|0x4a975353 07:17:25.295 (295862000)|STATEMENT_EXECUTE|[50] 07:17:25.295 (295870000)|HEAP_ALLOCATE|[50]|Bytes:16 07:17:25.299 (299418000)|VARIABLE_ASSIGNMENT|[50]|this.Name|"Test Method Name"|0x4a975353 07:17:25.299 (299431000)|STATEMENT_EXECUTE|[51] 07:17:25.299 (299442000)|HEAP_ALLOCATE|[51]|Bytes:14 07:17:25.299 (299488000)|VARIABLE_ASSIGNMENT|[51]|this.Description|"Test Meth Desc"|0x4a975353 07:17:25.299 (299496000)|STATEMENT_EXECUTE|[57] 07:17:25.299 (299543000)|HEAP_ALLOCATE|[57]|Bytes:41 07:17:25.299 (299620000)|FATAL_ERROR|System.NullPointerException: Attempt to de-reference a null object Class.Test_CampaignLkp_Ext.CanTestSave: line 57, column 1 07:17:25.299 (299638000)|FATAL_ERROR|System.NullPointerException: Attempt to de-reference a null object Class.Test_CampaignLkp_Ext.CanTestSave: line 57, column 1 07:17:25.388 (299658000)|CUMULATIVE_LIMIT_USAGE 07:17:25.388|LIMIT_USAGE_FOR_NS|(default)| Number of SOQL queries: 2 out of 100 Number of query rows: 2 out of 50000 Number of SOSL queries: 0 out of 20 Number of DML statements: 0 out of 150 Number of DML rows: 0 out of 10000 Number of script statements: 14 out of 200000 Maximum heap size: 0 out of 6000000 Number of callouts: 0 out of 10 Number of Email Invocations: 0 out of 10 Number of fields describes: 1 out of 100 Number of record type describes: 0 out of 100 Number of child relationships describes: 0 out of 100 Number of picklist describes: 0 out of 100 Number of future calls: 0 out of 10 07:17:25.388|CUMULATIVE_LIMIT_USAGE_END 07:17:25.299 (299692000)|CODE_UNIT_FINISHED|Test_CampaignLkp_Ext.CanTestSave 07:17:25.299 (299702000)|EXECUTION_FINISHED 07:17:25.367 (367257000)|EXECUTION_STARTED 07:17:25.367 (367277000)|CODE_UNIT_STARTED|[EXTERNAL]|01pJ00000004u6c|Test_CampaignLkp_Ext.CanTestSearch 07:17:25.367 (367363000)|VARIABLE_SCOPE_BEGIN|[7]|Test_CampaignLkp_Ext.ctl|ApexPages.StandardController|true|true 07:17:25.367 (367372000)|VARIABLE_SCOPE_BEGIN|[8]|Test_CampaignLkp_Ext.ext|CustomCampaignLookupController|true|true 07:17:25.367 (367380000)|VARIABLE_SCOPE_BEGIN|[17]|Test_CampaignLkp_Ext.mockAdminUser|User|true|true 07:17:25.367 (367386000)|VARIABLE_SCOPE_BEGIN|[19]|Test_CampaignLkp_Ext.r|Campaign|true|true 07:17:25.368 (368030000)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:5 07:17:25.368 (368046000)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:556 07:17:25.368 (368052000)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:23 07:17:25.368 (368087000)|METHOD_ENTRY|[5]|01pJ00000004u6c|Test_CampaignLkp_Ext.Test_CampaignLkp_Ext() 07:17:25.368 (368095000)|STATEMENT_EXECUTE|[5] 07:17:25.368 (368244000)|HEAP_ALLOCATE|[23]|Bytes:5 07:17:25.368 (368256000)|STATEMENT_EXECUTE|[5] 07:17:25.368 (368260000)|STATEMENT_EXECUTE|[21] 07:17:25.368 (368263000)|STATEMENT_EXECUTE|[23] 07:17:25.368 (368284000)|VARIABLE_SCOPE_BEGIN|[6]|TripRptTestDataUtilityLib.ADMIN_PROFILE_ID|Id|false|true 07:17:25.368 (368293000)|VARIABLE_SCOPE_BEGIN|[11]|TripRptTestDataUtilityLib.AttendeeItemFieldmap|MAP|true|true 07:17:25.368 (368300000)|VARIABLE_SCOPE_BEGIN|[8]|TripRptTestDataUtilityLib.TRIP_REPORT_COUNT|Integer|false|true 07:17:25.368 (368312000)|VARIABLE_SCOPE_BEGIN|[10]|TripRptTestDataUtilityLib.profiles|MAP|true|true 07:17:25.368 (368325000)|HEAP_ALLOCATE|[23]|Bytes:24 07:17:25.368 (368350000)|HEAP_ALLOCATE|[8]|Bytes:5 07:17:25.368 (368357000)|STATEMENT_EXECUTE|[3] 07:17:25.368 (368361000)|STATEMENT_EXECUTE|[8] 07:17:25.368 (368370000)|HEAP_ALLOCATE|[8]|Bytes:4 07:17:25.368 (368396000)|VARIABLE_ASSIGNMENT|[8]|TripRptTestDataUtilityLib.TRIP_REPORT_COUNT|0 07:17:25.368 (368403000)|STATEMENT_EXECUTE|[10] 07:17:25.368 (368414000)|HEAP_ALLOCATE|[10]|Bytes:4 07:17:25.368 (368464000)|VARIABLE_ASSIGNMENT|[10]|TripRptTestDataUtilityLib.profiles|{"serId":1,"value":{}}|0x13c68812 07:17:25.368 (368474000)|STATEMENT_EXECUTE|[11] 07:17:25.368 (368481000)|HEAP_ALLOCATE|[11]|Bytes:25 07:17:25.368 (368574000)|SYSTEM_METHOD_ENTRY|[11]|Schema.SObjectType.getDescribe() 07:17:25.368 (368612000)|HEAP_ALLOCATE|[11]|Bytes:4 07:17:25.368 (368624000)|SYSTEM_METHOD_EXIT|[11]|Schema.SObjectType.getDescribe() 07:17:25.368 (368646000)|SYSTEM_METHOD_ENTRY|[11]|Schema.DescribeSObjectResult.getFields() 07:17:25.368 (368706000)|SYSTEM_METHOD_EXIT|[11]|Schema.DescribeSObjectResult.getFields() 07:17:25.368 (368726000)|SYSTEM_METHOD_ENTRY|[11]|Schema.SObjectTypeFields.getMap() 07:17:25.368 (368866000)|HEAP_ALLOCATE|[11]|Bytes:44 07:17:25.368 (368880000)|SYSTEM_METHOD_EXIT|[11]|Schema.SObjectTypeFields.getMap() 07:17:25.369 (369008000)|VARIABLE_ASSIGNMENT|[11]|TripRptTestDataUtilityLib.AttendeeItemFieldmap|"common.apex.runtime.impl.MapValue$FqnMap@a28832e5"|0x4f0f5fe2 07:17:25.369 (369023000)|STATEMENT_EXECUTE|[14] 07:17:25.369 (369027000)|STATEMENT_EXECUTE|[16] 07:17:25.369 (369034000)|HEAP_ALLOCATE|[16]|Bytes:64 07:17:25.369 (369049000)|HEAP_ALLOCATE|[16]|Bytes:4 07:17:25.369 (369279000)|SOQL_EXECUTE_BEGIN|[16]|Aggregations:0|select id, name from Profile where name = 'System Administrator' 07:17:25.372 (372974000)|SOQL_EXECUTE_END|[16]|Rows:1 07:17:25.372 (372991000)|HEAP_ALLOCATE|[16]|Bytes:8 07:17:25.373 (373007000)|HEAP_ALLOCATE|[16]|Bytes:57 07:17:25.373 (373033000)|HEAP_ALLOCATE|[16]|Bytes:8 07:17:25.373 (373050000)|VARIABLE_SCOPE_BEGIN|[16]|ps|LIST|true|false 07:17:25.373 (373099000)|VARIABLE_ASSIGNMENT|[16]|ps|{"serId":1,"value":[{"serId":2,"value":{"Name":"System Administrator","Id":"00eU0000000o1LvIAI"}}]}|0x58f45346 07:17:25.373
Can you post the controller class in a readable format using the 'Insert Code' tool that is available when you post? It should end up looking like this.
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
public CustomCampaignLookupController(ApexPages.StandardController controller) {
}
public Campaign campaign {get;set;} // new campaign to create
public List<Campaign> results{get;set;} // search results
public string searchString{get;set;} // search keyword
public Boolean IsNew { get; set; }
public String NewTitle { get; set; }
public CustomCampaignLookupController() {
campaign = new Campaign();
IsNew = true;
NewTitle = 'Add';
// get the current search string
// chgd to below searchString = System.currentPageReference().getParameters().get('lksrch');
searchString = '';
runSearch();
// chgd to below for full search - searchString = System.currentPageReference().getParameters().get('lksrch');
searchString = '';
runSearch();
}
// performs the keyword search
public PageReference search() {
runSearch();
return null;
}
// prepare the query and issue the search command
private void runSearch() {
// TODO prepare query string for complex serarches & prevent injections
results = performSearch(searchString);
}
// run the search and return the records found.
private List<Campaign> performSearch(string searchString) {
String soql = 'select id, Name, isActive, Type, Description, ExpectedRevenue from campaign';
if(searchString != '' && searchString != null)
soql = soql + ' where name LIKE \'%' + searchString +'%\'';
soql = soql + ' limit 100';
System.debug(soql);
return database.query(soql);
}
// save the new campaign record
public PageReference saveCampaign() {
if (IsNew == true)
{
insert campaign;
IsNew = false;
NewTitle = '* EDIT New Campaign *';
}
else
{
upsert campaign;
}
// reset the campaign
//campaign = new Campaign();
//return null;
// jmc return to calling page
searchString = Campaign.Name;
runSearch();
return Page.CustomCampaignLookup;
}
// used by the visualforce page to send the link to the right dom element
public string getFormTag() {
return System.currentPageReference().getParameters().get('frm');
}
// used by the visualforce page to send the link to the right dom element for the text box
public string getTextBox() {
return System.currentPageReference().getParameters().get('txt');
}
}
From what I can see you never properly constructed your List<Campaign> results... a couple places you could put it...
Line 38 add the following:
results = new List<Campaign>();
Line 19 or somewhere in your constructor
results = new List<Campaign>();