I have a case entry wizard, duped and revised from the Visualforce in Practice workbook. My second page asks the users if they want to add Case Team Members. If they put a user in the name box, they can add a user, and this works fine. But I can't seem to get them to be able to bypass this if they don't want to add anyone. It sees the name as required. I tried to skip the insert Case Team Member section of the code on my "Complete Entry" button but it doesn't seem to matter. How can I get it to navigate to the new Case without entering info. Please assist! thanks.
Extension:
public class CasewithCaseTeamExtension {
private ApexPages.StandardController sc;
public CaseTeamMember CTM {get; set;}
public List<CaseTeamMember> CTMS {get; set;}
public String selectedCaseTeamMember {get; set;}
public string Username {
get {
return [
select Name
from User
where Id = :Userinfo.getUserId()
].Name;
}
set;
}
public CasewithCaseTeamExtension (ApexPages.StandardController StandardController) {
//Store a reference to the standard controller
sc = standardController;
//create a new sprint instance to collect user input
CTM = new CaseTeamMember();
//create a new list to store the sprints added by the user
CTMS = new List<CaseTeamMember>();
}
public PageReference ToPage2() {
if(ApexPages.CurrentPage().GetURL().ToLowerCase().StartsWith('/apex/CaseCreateCTM1')){
//Save code will go here
}
sc.save();
return Page.CaseCreateCTM2;
}
public PageReference SaveCTM() {
Case Case1 = (Case)sc.GetRecord();
CaseTeamRole CTRole = [select id from CaseTeamRole where name =:'Support'];
CTM.ParentId = Case1.Id;
CTM.TeamRoleId = CTRole.Id;
insert CTM;
CTMS.Add(CTM);
CTM = new CaseTeamMember();
return null;
}
public PageReference SaveAndFinish() {
Case Case1 = (Case)sc.GetRecord();
CaseTeamRole CTRole = [select id from CaseTeamRole where name =:'KCG'];
CTM.ParentId = Case1.Id;
CTM.TeamRoleId = CTRole.Id;
CTMS.Add(CTM);
CTM = new CaseTeamMember();
PageReference redirecturl = new PageReference('/'+Case1.id);
return redirecturl;
}
public PageReference FinishEntry() {
Case Case1 = (Case)sc.GetRecord();
PageReference redirecturl = new PageReference('/'+Case1.id);
return redirecturl;
}
}
Page:
<apex:page standardController="Case" extensions="CasewithCaseTeamExtension" >
<apex:form >
<apex:pageBlock title="Add Interested Parties to the Case Team Members List Here">
Case Team Members will be included in email notifications about the Case.
<apex:pageBlockButtons location="bottom">
<apex:commandButton action="{!SaveCTM}" value="Add Person to Case" />
<apex:commandButton action="{!FinishEntry}" value="Complete Case Entry" />
</apex:pageBlockButtons>
<apex:pageBlockSection columns="1">
<apex:inputField value="{!ctm.MemberId}" label="Name" />
</apex:pageBlockSection>
</apex:pageBlock>
<apex:pageBlock title="Added">
<apex:pageBlockTable value="{!CTMS}" var="s">
<apex:column value="{!s.MemberId}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
I want it to go to the new Case page when the User clicks the Complete Case Entry button, which calls FinishEntry, shown again right below, but I get the "You must enter a value" error. Thanks!
public PageReference FinishEntry() {
Case Case1 = (Case)sc.GetRecord();
PageReference redirecturl = new PageReference('/'+Case1.id);
return redirecturl;
}