• shse aset
  • NEWBIE
  • 0 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 2
    Replies
A question on a lighter note. I am new to Salesforce and to this forum. What is the criteria that is followed to award points in the forum. Are there any benefits for the peole who accrue more? :)

Hi All,

 

Anyone able to help me fill a gap.

 

I have the below VF page and Apex code that allow me to filter current information within a custom object.

 

What I need and I can't find an example of how to do this is the ability to press my clone button and have it clone any records that I have checked.

 

At the moment the below will display a list that match the criteria as well as provide 3 additional columns - one for year & term and checkbox for you to select. Once you have done this I would like to be able to press the clone button then all the records checked will be cloned and the year and term updated based on what I've selected.

 

VF Page:

<apex:page controller="DESCloningController">
 <apex:form > 
  <apex:pageBlock >
  <apex:pageBlockSection >
          <apex:inputField value="{!SearchCriteria.Sheet_Type__c}"/>   
          <apex:inputField value="{!SearchCriteria.Year__c}"/>
          <apex:inputField value="{!SearchCriteria.Term__c}"/>
          <apex:commandButton value="Search" action="{!Des}" reRender="applicantTbl,error"/>
          <apex:commandButton value="Clone" action="{!cloneDes}" />
  </apex:pageBlockSection>
  <apex:pageBlockSection id="applicantTbl"  >
            <apex:pageBlockTable value="{!DESs}" var="des" columns="7">
                <apex:column headerValue="Clone">
                    <apex:inputCheckbox value="{!clone}"/>
                </apex:column>
                <apex:column headerValue="Year"> 
                    <apex:selectList size="1" value="{!termoptions}" >
                        <apex:selectOptions value="{!items1}"/>
                    </apex:selectList>
                </apex:column>
                <apex:column headerValue="Term"> 
                    <apex:selectList size="1" value="{!yearoptions}" >
                        <apex:selectOptions value="{!items}"/>
                    </apex:selectList>
                </apex:column>
                <apex:column value="{!des.District__c}" headerValue="District"></apex:column>
                <apex:column value="{!des.Year__c}" headerValue="Year"></apex:column>
                <apex:column value="{!des.Term__c}" headerValue="Term"></apex:column>
                <apex:column value="{!des.Sheet_Type__c}" headerValue="Sheet Type"></apex:column>
            </apex:pageBlockTable>
        </apex:pageBlockSection>
      <apex:pageMessages id="error"></apex:pageMessages>
  </apex:pageBlock>
  
    </apex:form>
</apex:page>

 Apex Class

 

public with sharing class DESCloningController {

    public PageReference cloneDes() {
        return null;
    }

    public String termoptions { get; set; }
    public String clone { get; set; }
    public String yearoptions { get; set;}
    public List<District_Entitlement_Sheet__c> DESs{get;set;}
    public String SelectedValue1{get;set;}
    public String SelectedValue2{get;set;}
    public String SelectedValue3{get;set;}
    public District_Entitlement_Sheet__c SearchCriteria{get;set;}
    
    public DESCloningController ()
    {
        SearchCriteria = new District_Entitlement_Sheet__c();
    }
    public List<SelectOption> getItems() {
                List<SelectOption> yearoptions = new List<SelectOption>();
                    yearoptions.add(new SelectOption('2013','2013'));
                    yearoptions.add(new SelectOption('2014','2014'));
                    yearoptions.add(new SelectOption('2015','2015'));
        return yearoptions;
    }
    public List<SelectOption> getItems1() {
                List<SelectOption> termoptions = new List<SelectOption>();
                    termoptions.add(new SelectOption('Term 1','Term 1'));
                    termoptions.add(new SelectOption('Term 2','Term 2'));
                    termoptions.add(new SelectOption('Term 3','Term 3'));
        return termoptions;
    } 
    public void DES()    
    {
        DESs = new List<District_Entitlement_Sheet__c>();
        DESs = [SELECT Id,
                                     Country__c,
                                     District__c,
                                     Year__c,
                                     Term__c,
                                     Sheet_Type__c,
                                     Form_1_Bata_shoes__c,
                                     Form_1_Bed_Sheets__c,
                                     Form_1_Blanket__c,
                                     Form_1_Blouse__c,
                                     Form_1_Calculator__c,
                                     Form_1_Counter_Books__c,
                                     Form_1_Dress__c,
                                     Form_1_Exercise_Books__c,
                                     Form_1_Hardcover_books__c,
                                     Form_1_Maths_set__c,
                                     Form_1_Pens__c,
                                     Form_1_Pocket_money__c,
                                     Form_1_Safe_Term_Time_Accommodation__c,
                                     Form_1_Sanitary_Wear__c,
                                     Form_1_School_Bag__c,
                                     Form_1_Shoes__c,
                                     Form_1_Skirt__c,
                                     Form_1_Soap__c,
                                     Form_1_Socks__c,
                                     Form_1_Sugar__c,
                                     Form_1_Sweater__c,
                                     Form_1_Washing_powder__c,
                                     Form_2_Bata_shoes__c,
                                     Form_2_Bed_Sheets__c,
                                     Form_2_Blanket__c,
                                     Form_2_Blouse__c,
                                     Form_2_Calculator__c,
                                     Form_2_Counter_Books__c,
                                     Form_2_Dress__c,
                                     Form_2_Exercise_Books__c,
                                     Form_2_Hardcover_books__c,
                                     Form_2_Maths_set__c,
                                     Form_2_Pens__c,
                                     Form_2_Pocket_money__c,
                                     Form_2_Safe_Term_Time_Accommodation__c,
                                     Form_2_Sanitary_Wear__c,
                                     Form_2_School_Bag__c,
                                     Form_2_Shoes__c,
                                     Form_2_Skirt__c,
                                     Form_2_Soap__c,
                                     Form_2_Socks__c,
                                     Form_2_Sugar__c,
                                     Form_2_Sweater__c,
                                     Form_2_Washing_powder__c,
                                     Form_3_Bata_shoes__c,
                                     Form_3_Bed_Sheets__c,
                                     Form_3_Blanket__c,
                                     Form_3_Blouse__c,
                                     Form_3_Calculator__c,
                                     Form_3_Counter_Books__c,
                                     Form_3_Dress__c,
                                     Form_3_Exercise_Books__c,
                                     Form_3_Hardcover_books__c,
                                     Form_3_Maths_set__c,
                                     Form_3_Pens__c,
                                     Form_3_Pocket_money__c,
                                     Form_3_Safe_Term_Time_Accommodation__c,
                                     Form_3_Sanitary_Wear__c,
                                     Form_3_School_Bag__c,
                                     Form_3_Shoes__c,
                                     Form_3_Skirt__c,
                                     Form_3_Soap__c,
                                     Form_3_Socks__c,
                                     Form_3_Sugar__c,
                                     Form_3_Sweater__c,
                                     Form_3_Washing_powder__c,
                                     Form_4_Bata_shoes__c,
                                     Form_4_Bed_Sheets__c,
                                     Form_4_Blanket__c,
                                     Form_4_Blouse__c,
                                     Form_4_Calculator__c,
                                     Form_4_Counter_Books__c,
                                     Form_4_Dress__c,
                                     Form_4_Exercise_Books__c,
                                     Form_4_Hardcover_books__c,
                                     Form_4_Maths_set__c,
                                     Form_4_Pens__c,
                                     Form_4_Pocket_money__c,
                                     Form_4_Safe_Term_Time_Accommodation__c,
                                     Form_4_Sanitary_Wear__c,
                                     Form_4_School_Bag__c,
                                     Form_4_Shoes__c,
                                     Form_4_Skirt__c,
                                     Form_4_Soap__c,
                                     Form_4_Socks__c,
                                     Form_4_Sugar__c,
                                     Form_4_Sweater__c,
                                     Form_4_Washing_powder__c,
                                     Form_5_Blouse__c,
                                     Form_5_Counter_Books__c,
                                     Form_5_Dress__c,
                                     Form_5_Exercise_Books__c,
                                     Form_5_Safe_Term_Time_Accommodation__c,
                                     Form_5_Sanitary_Wear__c,
                                     Form_5_Shoes__c,
                                     Form_5_Skirt__c,
                                     Form_6_Blouse__c,
                                     Form_6_Counter_Books__c,
                                     Form_6_Dress__c,
                                     Form_6_Exercise_Books__c,
                                     Form_6_Safe_Term_Time_Accommodation__c,
                                     Form_6_Sanitary_Wear__c,
                                     Form_6_Shoes__c,
                                     Form_6_Skirt__c
                              FROM District_Entitlement_Sheet__c
                              WHERE Year__c =: SearchCriteria.Year__c
                              AND Term__c =: SearchCriteria.Term__c
                              AND Sheet_Type__c =: SearchCriteria.Sheet_Type__c];
         if(DESs.size() == 0)
         {
            Apexpages.addMessage(new ApexPages.Message(ApexPages.Severity.INFO,''+'No records to Display')); 
         }
        
      } 
}

Hope someone can help or just give me an example I've searched and can't find an example of something like this.

 

Cheers

Dan