+ Start a Discussion
SankeshReddy NallamilliSankeshReddy Nallamilli 

Write a VisualForce page to meet the below requirement. If Lead status is not contacted then comments field should be enabled and it should be mandatory.

Best Answer chosen by SankeshReddy Nallamilli
Varun SinghVarun Singh

Hi SankeshReddy Nallamilli 

i have  created a vf  page  with name "LeadcommentRequired"

pass the  id  of the record in url like '00Q7F000001pN1y '

https://varun007-dev-ed--c.ap5.visual.force.com/apex/LeadcommentRequired?id=00Q7F000001pN1y


try  this code  its  working fine for  your requirement.
 
<apex:page standardController="lead" >
    <apex:form>
    <apex:pageBlock>
        <apex:pageBlockSection>
           <apex:inputfield value="{!lead.status}"/>
        </apex:pageBlockSection>
        <apex:pageBlockSection rendered="{!lead.status=='Open - Not Contacted'}">
          <apex:inputField value="{!lead.comments__c}" required="true" /> </apex:pageBlockSection>
        <apex:pageBlockButtons >
        <apex:commandButton action="{!save}" title="save" value="save"/>
        </apex:pageBlockButtons>
    </apex:pageBlock>
    </apex:form>
</apex:page>



Make my answer as best if it is helpful.

Thanks
Varun
 

All Answers

srlawr uksrlawr uk
Is this an Interview/Exam question or something? That's a very strange way to phrase a question otherwise!

Unfortunately, it doesn't really contain enough information to actually help you really.


Here's two lines for free though
<apex:page standardController="Lead">

    // whole bunch of <apex:input> fields here to build the input, with some logic about whether comments is enabled or not

</apex:page>

I mean, looking at it - with what you've given us to read, I wouldn't even want to do this in Visualforce anyway.. I'd suggest looking into whether you can just do this with page layouts and permissions etc. doesn't seem too hard. Writing a custom page is just going to be coding yourself into a maintanence headache (and I never say that!)



 
Varun SinghVarun Singh

Hi SankeshReddy Nallamilli 

i have  created a vf  page  with name "LeadcommentRequired"

pass the  id  of the record in url like '00Q7F000001pN1y '

https://varun007-dev-ed--c.ap5.visual.force.com/apex/LeadcommentRequired?id=00Q7F000001pN1y


try  this code  its  working fine for  your requirement.
 
<apex:page standardController="lead" >
    <apex:form>
    <apex:pageBlock>
        <apex:pageBlockSection>
           <apex:inputfield value="{!lead.status}"/>
        </apex:pageBlockSection>
        <apex:pageBlockSection rendered="{!lead.status=='Open - Not Contacted'}">
          <apex:inputField value="{!lead.comments__c}" required="true" /> </apex:pageBlockSection>
        <apex:pageBlockButtons >
        <apex:commandButton action="{!save}" title="save" value="save"/>
        </apex:pageBlockButtons>
    </apex:pageBlock>
    </apex:form>
</apex:page>



Make my answer as best if it is helpful.

Thanks
Varun
 
This was selected as the best answer
SankeshReddy NallamilliSankeshReddy Nallamilli
thank you very much
Varun SinghVarun Singh
your  welcome !