You need to sign in to do that
Don't have an account?

visualforce page help redirecting
Hi,
I am having a crack at creating a very simply visualforce page where a user can Set a reason for Recycling a lead or Disqualifying a lead..
The user would click a button on the lead object which redirects them to a simple page which shows two fields (dependant picklist) of the Stage and then a reason of that lead.
They only see one option from the picklist and select a reason then click save where thery are redirected back to the lead which is updated.
A bit like closing a lead...
Here is the page; -
<apex:page standardController="Lead">
<apex:form >
<apex:pageBlock title="Recycled Reason">
<apex:pageblockbuttons >
<apex:commandbutton action="{!save}" value="Save"></apex:commandbutton>
<apex:commandbutton action="{!cancel}" value="Cancel"></apex:commandbutton>
</apex:pageblockbuttons>
<apex:pageBlockSection columns="1">
<apex:inputField value="{!Lead.Lead_Lifecycle_Stage__c}" required="true"/>
<apex:inputField value="{!Lead.Recycle_Reasons__c}" required="true"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
So far I just have two fields on a page which are the picklist and the picklist reason....
I am having a crack at creating a very simply visualforce page where a user can Set a reason for Recycling a lead or Disqualifying a lead..
The user would click a button on the lead object which redirects them to a simple page which shows two fields (dependant picklist) of the Stage and then a reason of that lead.
They only see one option from the picklist and select a reason then click save where thery are redirected back to the lead which is updated.
A bit like closing a lead...
Here is the page; -
<apex:page standardController="Lead">
<apex:form >
<apex:pageBlock title="Recycled Reason">
<apex:pageblockbuttons >
<apex:commandbutton action="{!save}" value="Save"></apex:commandbutton>
<apex:commandbutton action="{!cancel}" value="Cancel"></apex:commandbutton>
</apex:pageblockbuttons>
<apex:pageBlockSection columns="1">
<apex:inputField value="{!Lead.Lead_Lifecycle_Stage__c}" required="true"/>
<apex:inputField value="{!Lead.Recycle_Reasons__c}" required="true"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
So far I just have two fields on a page which are the picklist and the picklist reason....
You need an extension controller to setup Page redirect.
Here is the class file and modified VF page for you.
APEX Controller
VF Page
You have to setup a Custom link or button in your page layout to reach this page. I guess you can manage that.
Hope this helps.
All Answers
You need an extension controller to setup Page redirect.
Here is the class file and modified VF page for you.
APEX Controller
VF Page
You have to setup a Custom link or button in your page layout to reach this page. I guess you can manage that.
Hope this helps.
Thanks for this worked well!
I made the button which directs you to the page which works ok. Is it possible to restrict the picklist to only show one of the options?
I can suggest a better option.
If you want to restrict the user to have only one value for the Pick List, do not show the pick list to the user at all.
Instead you manually assign the value inside your extension controller, just before calling UPSERT.
hope this helps.
Mark it as Best Answer, if it does.
The user doesn't update a picklist field which is the leads status and was read only, instead they can only close the lead (select one opition from the picklist) and add a reason for the closure (dependant picklist of status).
Using validation rules to stop the user selecting the wrong options seemed a bit messy so I tried this way where the click of a button loads the visualforce page where the user only gets the single option to select closed and then select their reason and save. However this will not work if the lead status field is read only.
do you think its still possible to keep the field as read only and then when the visualforce page is loaded show only one option or would it be better to use record types to restrict the picklist otions here?
If you just want to show the field to the user you can do that.
Otherwise, just allow the user to edit the comments and take care of the status in the controller.
How do I amend the status via the controller so that if the user saves its updated to recycled otherwise cancel it does not
Replace YOUR_STAUS_HERE with your actual Close status.
I've created a reason field which is not a dependant and this workd for just what I need it. thanks