You need to sign in to do that
Don't have an account?
Waqas Ali
Show Contracts in VF and change status in VF through Picklist
I have button in opportunity page , When that button is pressed, I want to show my pending contracts in Visual force page and want o Expire or Laspe through VF page. Here is my class
Here is my VF page.
How to fix this ?
Now how to change the status of these contracts ? I mean how to return the value "Expired or Lapse" and update crosponding Contract ?
Guys any help ?
public class myclass { String theId = ApexPages.currentPage().getParameters().get('id'); public List<WrapperSObject> records {get; set;} public Contract con {get; set;} public myclass(ApexPages.StandardController stdController) { this.o = (Opportunity)stdController.getRecord(); } public PageReference autoRun() { records = new List<WrapperSObject>(); for (Contract c : [select Name, AccountId, StartDate, Status, ContractNumber from Contract where Status='Pending']) { records.add(new WrapperSObject(c)); records.add(new WrapperSObject(getOptions(), '--None--')); } return null; } public class WrapperSObject { public Contract con {get; set;} public List < SelectOption > options {get; set;} public String selectedValue {get; set;} public WrapperSObject( List < SelectOption > options, String selectedValue) { this.options = options; this.selectedValue = selectedValue; } public WrapperSObject(Contract c) { con=c; } } public List < SelectOption > getOptions() { List<SelectOption> options = new List<SelectOption>(); options.add(new SelectOption('Expired','Expired')); options.add(new SelectOption('LAPSE','Lapse')); return options; } }
Here is my VF page.
<apex:page standardController="Opportunity" extensions="myclass" action="{!autoRun}"> <apex:form > <apex:pageBlock title="My Pending Contracts"> <apex:pageBlockTable value="{!records}" var="wrapper"> <apex:column > <apex:facet name="header">Contract Number</apex:facet> <apex:outputText value="{!wrapper.con.ContractNumber}"/> </apex:column> <apex:column > <apex:facet name="header">Contract Name</apex:facet> <apex:outputText value="{!wrapper.con.Status}"/> </apex:column> <apex:column > <apex:facet name="header">Change Status</apex:facet> <apex:selectList value="{!wrapper.selectedValue}" size="1" > <apex:selectOptions value="{!wrapper.options}" /> </apex:selectList> </apex:column> </apex:pageBlockTable> </apex:pageBlock> </apex:form> </apex:page>Why this small blank Dropdown menu is showing ?
How to fix this ?
Now how to change the status of these contracts ? I mean how to return the value "Expired or Lapse" and update crosponding Contract ?
Guys any help ?
In your class line numer 19 and 20 is the root cause of your problem. Actually you have created 2 constructors in your wrapper class. Always keep in mind if you have more than one consutructor in your class you can call only one at a time but in your code you are creating 2 records each time that is why you are always geeting just double records on your page. I have modified your class could you please test it with updated code. Let my know if it's not work.
Thanks.
Kapil
Thanks a lot, Through your answer have solved my issue. Here is new code
NOw i want to know that how to get selected value in picklist and update contract status through SOQL query??
One again Thank's a lot KapilC.
yeah i'll mark but still i need to about
how to get selected value in picklist and update contract status through SOQL query??
You can help ? KapilC
As you are having status field in your contract object so you can directly use that field on vf page by <apex:inputfield> tag. You don't have use slectoptionlist. Save the update contract list at last.
Thanks.
Kapil