function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
amar joshiamar joshi 

i cant nevigate my page its say u must have to enter a data even i click cancle result is same

hi all

in my page its combination of lead and task object

i have some lead fields and some task fields
some task's fields are required
when i click to cancel button to cancel that  operation it cant navigate it says u must have to enter data

please advise if i m doing wrong..

Code:
page code

<apex:page controller="convertdemo11" tabstyle="lead">
<apex:sectionHeader title="Convert Lead"subtitle="{!lead.owner.name}"/>
Leads can be converted to accounts, contacts, opportunities, and followup tasks.
<br>You should only convert a lead once you have identified it as qualified.</br>
<br>After this lead has been converted, it can no longer be viewed or edited as a lead, but can be viewed in lead reports.</br>
<br> </br>
<apex:form >
<apex:pageBlock mode="edit">
<apex:pageblockButtons >
<apex:commandButton action="{!convertLead}" value="convert"/>
<apex:commandButton action="{!cancle}" value="cancle"/>
</apex:pageblockButtons>
<apex:pageBlockSection title="Convert Lead">
<apex:inputfield value="{!lead.Record_Owner__c}"/>
<apex:pageblockSectionItem ></apex:pageblockSectionItem>
<apex:pageBlockSectionItem >
</apex:pageblocksection>
<apex:pageblocksection title="Task Information">
<apex:inputfield value="{!task.subject}"/>
<apex:inputfield value="{!task.Branch_Name__c}" required="True"/>
<apex:inputfield value="{!task.ActivityDate}"/>
<br><apex:inputfield value="{!task.Description}"/></br>
</apex:pageblocksection>
<apex:pageBlockSection title="Other Information">
<apex:inputfield value="{!task.Priority}"/>
<br><apex:inputfield value="{!task.Status}"/></br>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>

 
 controller

Code:
///////////controller/////////////

public class convertdemo11 {

    Task task;      
         public Task gettask()
          {
            if (task == null)
            task = new Task();
            return task;
          }


     public PageReference cancle()
    {
      String m2 = '/'+ApexPages.currentPage().getParameters().get('id');
      PageReference pageref = new Pagereference(m2);
      return pageref;
    }


    public PageReference convertLead() {
        return null;
    }


   public Lead getLead() 
          {
             Lead a;
             a= [select owner.id,owner.type,owner.name,Record_Owner__c,company,Group_Company__c from Lead 
                           where id = :ApexPages.currentPage().getParameters().get('id')]; 
             a.Record_Owner__c=a.owner.id;
             return a;
         }

}
 

well it can done if i put like
<apex:inputfield value="{!task.Branch_Name__c}" required="false"/>

but i want to add functionality that when we click convert button we must have to enter tasks required field
but when click cancel button it can navigate to pagereference page without showing error.


thanks & regards
Amar Joshi
 




Message Edited by amar joshi on 09-26-2008 04:55 PM
XactiumBenXactiumBen
Use immediate="true" in your cancel button, this will skip all validation checks when this button is clicked.

Code:
<apex:commandButton action="{!cancle}" value="cancle" immediate="true" />