You need to sign in to do that
Don't have an account?
Varun Annadata
Help with functionality of button
Apex Class:
public with sharing class SkipMilestone{
public List<Program_Member_Stage_MVN__c>Pms{get;set;}
public List<ProgramWrapper>PmsWrapper{get;set;}
public Program_Member_MVN__c Pm;
public SkipMilestone(ApexPages.StandardController controller) {
Pm = (Program_Member_MVN__c)controller.getRecord();
List<Program_Member_Stage_MVN__c>Pms =[select id,Name,Program_Stage_MVN__c,Status_MVN__c,Program_Stage_Name_MVN__c from Program_Member_Stage_MVN__c where Program_Member_MVN__c=:Pm.id and Status_MVN__c='Not Started'];
if(Pms != null && Pms .size() > 0){
displayStages(Pms);
system.debug('Pms:'+Pms);
}
}
public void displayStages(List<Program_Member_Stage_MVN__c>Pms)
{
PmsWrapper=new List<ProgramWrapper>();
for(Program_Member_Stage_MVN__c PmObj : Pms){
PmsWrapper.add(new ProgramWrapper(PmObj));
}
}
public void complete(){
PmsWrapper=new List<ProgramWrapper>();
for(ProgramWrapper ow : PmsWrapper){
if(ow.isChecked){
ow.PmStatus='Started';
// PmsWrapper.add(new ProgramWrapper(ow));
}
// update PmsWrapper;
}
}
public class ProgramWrapper{
public string PmId{get;set;}
public String PmName{get;set;}
public String Pmstage{get;set;}
public Boolean isChecked {get;set;}
public String PmStatus{get;set;}
public ProgramWrapper(Program_Member_Stage_MVN__c PmObj){
this.PmId=PmObj.id;
this.PmName= PmObj.Name;
this.Pmstage= PmObj.Program_Stage_Name_MVN__c;
this.isChecked = false;
this.PmStatus= PmObj.Status_MVN__c ;
}
}
}
Visual force Page:
<apex:page standardcontroller="Program_Member_MVN__c" extensions="SkipMilestone" >
<apex:form >
<apex:pageBlock >
<apex:pageblocktable value="{!PmsWrapper}" var="Pm">
<apex:column ><apex:inputCheckbox value="{!Pm.isChecked}" /></apex:column>
<apex:column headervalue="Name" value="{!Pm.PmName}"/>
<apex:column headervalue="Stage Name" value="{!Pm.Pmstage}"/>
<apex:column headervalue="Status" value="{!Pm.PmStatus}"/>
<apex:column headerValue="Action">
<apex:commandButton value="Complete" onclick="complete" />
</apex:column>
</apex:pageblocktable>
</apex:pageBlock>
</apex:form>
</apex:page>
The functionality i want is when i click the button which is displayed at the end of records it should update the status field of that particular record to completed.
How should i write the logic in:
public void complete(){
PmsWrapper=new List<ProgramWrapper>();
for(ProgramWrapper ow : PmsWrapper){
if(ow.isChecked){
ow.PmStatus='Started';
// PmsWrapper.add(new ProgramWrapper(ow));
}
// update PmsWrapper;
}
}
To update the status field of that record to "completed"?
Visual force page will look like:
public with sharing class SkipMilestone{
public List<Program_Member_Stage_MVN__c>Pms{get;set;}
public List<ProgramWrapper>PmsWrapper{get;set;}
public Program_Member_MVN__c Pm;
public SkipMilestone(ApexPages.StandardController controller) {
Pm = (Program_Member_MVN__c)controller.getRecord();
List<Program_Member_Stage_MVN__c>Pms =[select id,Name,Program_Stage_MVN__c,Status_MVN__c,Program_Stage_Name_MVN__c from Program_Member_Stage_MVN__c where Program_Member_MVN__c=:Pm.id and Status_MVN__c='Not Started'];
if(Pms != null && Pms .size() > 0){
displayStages(Pms);
system.debug('Pms:'+Pms);
}
}
public void displayStages(List<Program_Member_Stage_MVN__c>Pms)
{
PmsWrapper=new List<ProgramWrapper>();
for(Program_Member_Stage_MVN__c PmObj : Pms){
PmsWrapper.add(new ProgramWrapper(PmObj));
}
}
public void complete(){
PmsWrapper=new List<ProgramWrapper>();
for(ProgramWrapper ow : PmsWrapper){
if(ow.isChecked){
ow.PmStatus='Started';
// PmsWrapper.add(new ProgramWrapper(ow));
}
// update PmsWrapper;
}
}
public class ProgramWrapper{
public string PmId{get;set;}
public String PmName{get;set;}
public String Pmstage{get;set;}
public Boolean isChecked {get;set;}
public String PmStatus{get;set;}
public ProgramWrapper(Program_Member_Stage_MVN__c PmObj){
this.PmId=PmObj.id;
this.PmName= PmObj.Name;
this.Pmstage= PmObj.Program_Stage_Name_MVN__c;
this.isChecked = false;
this.PmStatus= PmObj.Status_MVN__c ;
}
}
}
Visual force Page:
<apex:page standardcontroller="Program_Member_MVN__c" extensions="SkipMilestone" >
<apex:form >
<apex:pageBlock >
<apex:pageblocktable value="{!PmsWrapper}" var="Pm">
<apex:column ><apex:inputCheckbox value="{!Pm.isChecked}" /></apex:column>
<apex:column headervalue="Name" value="{!Pm.PmName}"/>
<apex:column headervalue="Stage Name" value="{!Pm.Pmstage}"/>
<apex:column headervalue="Status" value="{!Pm.PmStatus}"/>
<apex:column headerValue="Action">
<apex:commandButton value="Complete" onclick="complete" />
</apex:column>
</apex:pageblocktable>
</apex:pageBlock>
</apex:form>
</apex:page>
The functionality i want is when i click the button which is displayed at the end of records it should update the status field of that particular record to completed.
How should i write the logic in:
public void complete(){
PmsWrapper=new List<ProgramWrapper>();
for(ProgramWrapper ow : PmsWrapper){
if(ow.isChecked){
ow.PmStatus='Started';
// PmsWrapper.add(new ProgramWrapper(ow));
}
// update PmsWrapper;
}
}
To update the status field of that record to "completed"?
Visual force page will look like:
You can pass a parameter to the command button to achieve this.
Your Commandbutton code will look like this. And the APEX method will be like this. As you can see, I have defined a public property named paramValue before the method. You can move it to the top of your class.
And, replace YOUR_VF_PAGE_NAME with your actual Visualforce page name, so that the page refresh will happen automatically after saving.
Let me know how it goes.