You need to sign in to do that
Don't have an account?
How do I clear values from page?
I have 2 buttons on a page: Save and Clear.
How do I clear values from the page if the Clear button is clicked?
Help would be greatly appreciated
My page:
<apex:page standardController="Case" showHeader="true" sidebar="true" extensions="RequestNewExtension" tabStyle="New_Request__tab">
<apex:form >
<apex:sectionHeader subtitle="Create a Request">
<div style="float:right">
<span class="requiredExample"> </span>
<span class="requiredMark">*</span>
<span class="requiredText"> = Required Information</span>
</div>
</apex:sectionHeader>
<apex:pageMessages />
<apex:pageBlock >
<apex:pageBlockButtons location="both">
<apex:commandButton value="Save" action="{!Save}" />
<apex:commandButton value="Clear" action="{!Cancel}" />
</apex:pageBlockButtons>
<apex:pageBlockSection id="cas14" title="Request Subject/Description" collapsible="false" columns="2">
<apex:pageBlockSectionItem >
<apex:outputLabel >Subject</apex:outputLabel>
<apex:inputField id="caseSubject" value="{!case.Subject}" style="width:90%" required="true" />
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem > </apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputLabel >Description</apex:outputLabel>
<apex:inputField id="caseDescription" value="{!case.Description}" style="width:90%; height: 75px" required="true" />
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem ></apex:pageBlockSectionItem>
</apex:pageBlockSection>
<apex:pageBlockSection id="cas5" title="Request Detail:" collapsible="false" columns="2">
<apex:pageBlockSectionItem >
<apex:outputLabel >Request Type</apex:outputLabel>
<apex:inputField id="caseType" value="{!case.Type}" required="true" />
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem ></apex:pageBlockSectionItem>
<apex:pageBlockSectionItem ></apex:pageBlockSectionItem>
</apex:pageBlockSection>
<apex:inputHidden value="{!Comment}" id="theHiddenInput"/>
</apex:pageBlock>
</apex:form>
</apex:page>
My Extension:
public with sharing class RequestNewExtension {
public String Comment
{
get;
set;
}
public String Description
{
get;
set;
}
public String Subject
{
get;
set;
}
public Boolean UseAssignmentRules
{
get;set;
}
public Case cs;
ApexPages.StandardController controller;
public RequestNewExtension (ApexPages.StandardController con)
{
controller = con;
this.cs = (Case) con.getRecord();
}
public PageReference Save()
{
CaseComment com = new CaseComment();
if(Comment.Length() > 0)
{
com.commentBody = Comment;
com.ParentId = cs.Id;
if(UseAssignmentRules == true)
{
AssignmentRule AR = new AssignmentRule();
AR = [select id from AssignmentRule where SobjectType = 'Case' and Active = true limit 1];
//Creating the DMLOptions for "Assign using active assignment rules" checkbox
Database.DMLOptions dmlOpts = new Database.DMLOptions();
dmlOpts.assignmentRuleHeader.assignmentRuleId= AR.id;
controller.getRecord().setOptions(dmlOpts);
}
insert com;
}
String retURL = ApexPages.currentPage().getParameters().get('retURL');
String CurrentId = ApexPages.currentPage().getParameters().get('id');
PageReference redirectPG;
if(retURL != null)
redirectPG = new PageReference('/' + retURL);
else if(CurrentId != null)
redirectPG = new PageReference('/' + CurrentId);
controller.Save();
return Page.Request_Create_Thankyou;
}
public PageReference Cancel(){
return null;
}
}
Hi, you might want to try this:
All Answers
Hi,
try to use following code.
Visualforce Page:
Apex Class:
Hit Kudos if this provides you with useful information and if this is what you where looking for then please mark it as a solution for other benefits.
Thank You,
Hitesh Patel
SFDC Certified Developer & Administrator
My Blog:- http://mrjavascript.blogspot.in/
Thank you, Hitesh.
I made the changes you recommended but the values that were inputted to the form were not cleared.
Any other ideas?
Thank you again,
Haya
Hi, you might want to try this:
Thank you so much.
Haya