Friday, March 22, 2013

Sending Object Records using Salesforce to Salesforce

Introduction :- Salesforce to Salesforce enables you to share records among the business partners.
Step1:-
To establish connection from one organization to another salesforce organization ,we need to enable settings first in both organizations.
Set up--> AppSetup-->Customize-->Salesforce to Salesforce--> Settings.
After enabling settings we need to add another salesforce organization Name and it's Email as Contact in to parent salesforce organization.
Step2:-
Now you can find Tab 'Connections', add that Tab to Tabs bar.
Step3:-  Sending Invitation to another organization.
Now click on 'Connection Tab',click on New--> Select  the contact ,that we have created as per in earlier step--> Click on Save&Send Invite.
Then Email will send to Email,which is associated in that contact.
Step4:-
In that Email,we can get an Link,Click on link and give the login details of client (add contact  sales force organization login details).Now you can see the connection invitation in child salesforce organization.
Click on Accept,Now this allows you to share lead, opportunity, account, contact, task, product, opportunity product, case, case comment, attachment, or custom object records with your business partners. With Salesforce to Salesforce, you can share records with one or more connections, and each connection can accept records you share with them - even if other connections have accepted the same record.
Step 5:- I want to share Accounts
First publish this object from parent connection,for that
Click connection detail page,there you can find the Related list "Publish Object",there you can find button 'publish/unpublish'.Click on that button ,then in new window you can see all the available objects for connection.select Account click on Save.
Now goto business partner Organization,on Connection Detail page you can find related list for Subscribe object, click on button 'subscribe/unsubscribe',click on that button,select object from pick list and click on save. Now to share account records goto parent Salesforce organization ,select Account records from list view of Account records and click on 'Forward to Connections', there you can find list of  Available connections in your organization,select organization and click on save.
Then that Account record will be created in Account object of the business partner.
In this way we can share account records from parent org to business partner organization.
Step 5:- I want to share  contact and opportunities associated with an Account record
We can achieve this by publishing contacts and opportunity objects to business partner and he must subscribe to that objects also.Now send the account record which is associated with above contact and opportunity objects as we discuss in earlier step.

Questions
1. My organization Having 15000 records in Accounts object, can we transfer all the records in one step?
---> Yes, you can achieve this by writing  Apex class. I am giving code for this please go through once you can under stand easily.
Controller:-

global class SendOldRecord
{
        public void sendrec(list<Account> ls)
        {
            //This list declaration for PartnerNetworkrecords
            List<PartnerNetworkRecordConnection> lstShareRecords = new List<PartnerNetworkRecordConnection>();
            //This list declaration for the Connections with this Organization.
            List<PartnerNetworkConnection> connMap=[select Id, ConnectionStatus, ConnectionName from PartnerNetworkConnection
                    where ConnectionStatus = 'Accepted' and ConnectionName='Appshark Software Pvt Ltd'];
            //This for is to loop all the connections
                    for(PartnerNetworkConnection network : connMap) 
                    {    
                        for(Account acc:ls)
                        {
                        //object declaration for PartnerNetwork
                        PartnerNetworkRecordConnection newrecord = new PartnerNetworkRecordConnection();
                        system.debug('Second for loop');
                        newrecord.ConnectionId = network.Id;
                        newrecord.LocalRecordId = acc.id;  
                        newrecord.RelatedRecords = 'Contact';
                        newrecord.SendClosedTasks = true;
                        newrecord.SendOpenTasks = true;
                        newrecord.SendEmails = true;
                        //All the Records are added to the PartnerNetwork
                        lstShareRecords.add(newrecord);
                        }
                   }
              system.debug('List\n'+lstShareRecords);
             //These Records are inserted into Partnernetwork
             //using lstShareRecords.
              insert lstShareRecords;
        }
}
in the case of bulk records , we need to handle them in Batch process,for i have implemented following batch class and pass to list of accounts at every run,
Batch Controller:-
global class RecordBatchApex implements Database.Batchable<Account>
{
global list<Account> start(Database.BatchableContext bc)
{       
    list<account> lstAcc = [select Id from Account];
    return lstAcc;
}

global void execute(Database.BatchableContext bc,List<Account> lstAccount)
{        
system.debug('*******************Execute of Batch Apex***********');
system.debug(lstAccount);
sendoldrecord od=new sendoldrecord();
od.sendrec(lstAccount);
}
//BatchApex Completes
// execution with this finish method
global void finish(Database.BatchableContext BC)
{
system.debug('****Finished*****');
}
Once run that code even from System log,then you can find all the records in business partner login.

2. I want to  insert newly created Account in to partner's organization.
In this Scenario we will go for Apex trigger to create newly inserted account into partner's Organization.

Trigger autoforwardAccount on Account(after insert)
{
String UserName = UserInfo.getName();
String orgName = UserInfo.getOrganizationName();
List<PartnerNetworkConnection> connMap = new List<PartnerNetworkConnection>(
[select Id, ConnectionStatus, ConnectionName from PartnerNetworkConnection where ConnectionStatus = 'Accepted']
);
System.debug('Size of connection map: '+connMap.size());
List<PartnerNetworkRecordConnection> prncList = new List<PartnerNetworkRecordConnection>();
for(Integer i =0; i< Trigger.size; i++)
{
Account acc = Trigger.new[i];
String acId = acc.Id;
System.debug('Value of AccountId: '+acId);
for(PartnerNetworkConnection network : connMap)
{
String cid = network.Id;
String status = network.ConnectionStatus;
String connName = network.ConnectionName;
String AccountName = acc.Name;
System.debug('Connectin Details.......Cid:::'+cid+'Status:::'+Status+'ConnName:::'+connName+'AccountName:::'+AccountName);
if(AccountName !=Null)
{
PartnerNetworkRecordConnection newrecord = new PartnerNetworkRecordConnection();
newrecord.ConnectionId = cid;
newrecord.LocalRecordId = acId;
newrecord.SendClosedTasks = true;
newrecord.SendOpenTasks = true;
newrecord.SendEmails = true;
System.debug('Inserting New Record'+newrecord);
insert newrecord;
}
}
}
}

3. Can we insert Contact or Opportunity related for an account,while inserting contact or opportunity ?

Yes, We can, for that we need to trigger on Contact/Opportunity ,here we are inserting contact/opportunity related to an account for that we need to specify account Id also. 
            We PartnerNetworkRecordConnection object for sharing records between salesforce to salesforce.
It contains filed 'ParentRecordId',to that filed we need to assign that account id.I have written trigger on conatct , i am giving code for that,you can implement same thing for opportunity also.
               
 Trigger autoforwardContact on Contact(after Insert)
{  
String  UserName = UserInfo.getName(); 
 String orgName = UserInfo.getOrganizationName();  
List<PartnerNetworkConnection> connMap = new List<PartnerNetworkConnection>([select Id, ConnectionStatus, ConnectionName from 
PartnerNetworkConnection where ConnectionStatus = 'Accepted']); 
System.debug('Size of connection map: '+connMap.size());
 List<PartnerNetworkRecordConnection> prncList = new List<PartnerNetworkRecordConnection>(); 
for(Integer i =0; i< Trigger.size; i++) 

Contact con = Trigger.new[i]; 
String conId = con.Id; 
System.debug('Value of ContactId: '+conId);
for(PartnerNetworkConnection network : connMap)

String cid = network.Id;
String status = network.ConnectionStatus; 
String connName = network.ConnectionName;
String ContactName = con.LastName; 
String Accountid = con.Accountid; 
System.debug('Connectin Details.......Cid:::'+cid+'Status:::'+Status+'ConnName:::'+connName+'ContactName:::'+COntactName);
System.debug('Account ID************'+Accountid);
if(ContactName!= NULL)
{  
System.debug('INSIDE IF');  
 PartnerNetworkRecordConnection newrecord = new PartnerNetworkRecordConnection();  
 newrecord.ConnectionId = cid;  
 newrecord.LocalRecordId = ConId;  
 newrecord.ParentRecordId= Accountid; // here we are specifying Account ID  
 newrecord.SendClosedTasks = true;   
newrecord.SendOpenTasks = true; 
  newrecord.SendEmails = true;   
System.debug('Inserting New Record'+newrecord);
 insert newrecord; 
}


}        
Using Above Trigger we can Send newly inserted record in to Partner's organization.

Saturday, March 16, 2013

Displaying the records with required no.of columns


Visualforce Page:

<apex:page controller="dynamicColumns">
<apex:Form >
          <apex:pageBlock >
                <apex:pageBlockButtons location="top">
                    <apex:commandButton action="{!refreshTable}" value="Refresh Table"/>
                </apex:pageBlockButtons>
                
                <apex:pageBlockSection >
                    <apex:pageBlockSectionItem >
                        <apex:outputLabel value="No of Colums">
                        </apex:outputLabel>
                        <apex:inputText value="{!noOfColumns}" />
                    </apex:pageBlockSectionItem>
                </apex:pageBlockSection>
                
                <apex:pageBlockSection collapsible="true" title="Search Result" columns="1">
            
            <apex:PageBlockTable columns="{!listFieldToShow.size}" value="{!listTableResult}" var="rowItem">
               
                <apex:repeat value="{!listFieldToShow}" var="colItem">
                    <apex:column >
                        <apex:facet name="header" >{!mapFieldToShow[colItem]}</apex:facet>
                        <apex:outputLabel value="{!rowItem[mapFieldToShow[colItem]]}"></apex:outputLabel>
                    </apex:column>
                </apex:repeat>
                
            </apex:PageBlockTable>
            
        </apex:pageBlockSection>
          </apex:pageBlock>
     </apex:Form>
</apex:page>

Apex Class:


public with sharing class dynamicColumns {
    public map<String , String> mapFieldToShow{get;set;}
        
    public Integer noOfColumns 
        { 
            get; 
            set
                {
                    listFieldToShow = new List<String>(); 
                    if(value == 1)
                        {
                            listFieldToShow.add('FirstName');
                        }
                    else if(value == 2)
                        {
                            listFieldToShow.add('FirstName');
                            listFieldToShow.add('LastName');
                        }
                    else if(value != null && value > 2)
                        {
                            listFieldToShow.add('FirstName');
                            listFieldToShow.add('LastName');
                            listFieldToShow.add('Email');
                        }                       
                } 
        }
    
    public List<String> listFieldToShow {get;set;}
    
    public dynamicColumns()
        {
            listFieldToShow = new List<String>();
            listFieldToShow.add('FirstName');
            mapFieldToShow = new Map<String , String>();
            mapFieldToShow.put('FirstName' , 'FirstName');
            mapFieldToShow.put('LastName' , 'LastName');
            mapFieldToShow.put('Email' , 'Email');
            listTableResult = [Select FirstName, Lastname, Email from Contact limit 20];
        }
    public List<Contact> listTableResult {get;set;}

    public PageReference refreshTable() 
    {
        return ApexPages.currentpage();
    }
}

Friday, March 15, 2013

Inserting Account record in another Org from One Org using Trigger


Inserting account record in one organization then that record automatically added to other 
organization.
----------------------------------------------------------------------------
Trigger on Account

Trigger autoforwardAccount on Account(after insert)
{
String UserName = UserInfo.getName();
String orgName = UserInfo.getOrganizationName();
List<PartnerNetworkConnection> connMap = new List<PartnerNetworkConnection>(
[select Id, ConnectionStatus, ConnectionName from PartnerNetworkConnection where ConnectionStatus = 'Accepted']
);
System.debug('Size of connection map: '+connMap.size());
List<PartnerNetworkRecordConnection> prncList = new List<PartnerNetworkRecordConnection>();
for(Integer i =0; i< Trigger.size; i++)
{
Account acc = Trigger.new[i];
String acId = acc.Id;
System.debug('Value of AccountId: '+acId);
for(PartnerNetworkConnection network : connMap)
{
String cid = network.Id;
String status = network.ConnectionStatus;
String connName = network.ConnectionName;
String AccountName = acc.Name;
System.debug('Connectin Details.......Cid:::'+cid+'Status:::'+Status+'ConnName:::'+connName+'AccountName:::'+AccountName);
if(AccountName !=Null)
{
PartnerNetworkRecordConnection newrecord = new PartnerNetworkRecordConnection();
newrecord.ConnectionId = cid;
newrecord.LocalRecordId = acId;
newrecord.SendClosedTasks = true;
newrecord.SendOpenTasks = true;
newrecord.SendEmails = true;
System.debug('Inserting New Record'+newrecord);
insert newrecord;
}
}
}
}

Creating visualforce page as PDF and sending that PDF to Email


Visualforce Page:

<apex:page standardController="Account" recordSetVar="accs" extensions="pdfcls" >
    <apex:form >
        <apex:pageblock >        
            <apex:pageblockButtons >
                <apex:commandButton value="send PDF" action="{!pdfmethod}"/>
            </apex:pageblockButtons>        
            <apex:pageblockTable value="{!accs}" var="a">
                <apex:column value="{!a.name}"/>
                <apex:column value="{!a.type}"/>
                <apex:column value="{!a.rating}"/>
            </apex:pageblockTable>
        </apex:pageblock>
    </apex:form>
</apex:page>

Apex Class:

public with sharing class pdfcls {

    public pdfcls(ApexPages.StandardSetController controller) {

                                                                                              }
    public blob body;                                                          
    public PageReference pdfmethod(){
        PageReference ref=page.pdftomail;
        body=ref.getContentAsPDF();
        
        Messaging.EmailFileAttachment mefa=new Messaging.EmailFileAttachment();
        mefa.setContentType('application/pdf');
        mefa.setFileName('Narayana.Pdf');
        mefa.Body=body;
        
        Messaging.SingleEmailMessage msem=new Messaging.SingleEmailMessage();
        msem.setToAddresses(new String[] {'example@gmail.com'});
        msem.setSubject('Email PDF Demo');
        msem.setPlainTextBody('sending pdf to email from salesforce visualforce');
        msem.setFileAttachments(new Messaging.EmailFileAttachment[] {mefa});
        //send email
        Messaging.sendEmail(new Messaging.SingleEmailMessage[] {msem});
            return null;        
                                    }
}

Swapping of Two Records


Visualforce page:

<apex:page controller="swapcls" id="p">
    <apex:form id="f">
        <apex:pageBlock id="pb" >
            <div align="center">       
            <apex:commandButton value="Swap" action="{!swapmethod}"/>
            </div>
            <apex:pageMessage summary="Select any Two Records" severity="warning" strength="3" rendered="{!pgmsg}" />
            <apex:pageblocktable value="{!lw}" var="ll" id="pbt" >
                <apex:column headerValue="Action" width="80px" id="c">
                    <apex:inputCheckbox value="{!ll.selected}" id="icb"/>
                </apex:column>
                <apex:column value="{!ll.num}" headerValue="Index" width="100px"/>
                <apex:column value="{!ll.name.name}"/>
               <apex:column value="{!ll.name.rating}"/>
                <apex:column value="{!ll.name.phone}"/>
            </apex:pageblocktable>
        </apex:pageBlock>
    </apex:form>
</apex:page>

Apex Class:


global with sharing class swapcls {

    public boolean pgmsg { get; set; }
   
    public PageReference swapmethod() {
     List<Integer> li=new List<Integer>();
    List<Account> lstacc=new List<Account>();
     la=new List<Account>();
         for(integer i=0; lw.size()>i;i++){
            if(lw[i].selected==true){
            lstacc.add(lw[i].name);
            li.add(i);
                                    }
                                           }
            System.debug('--------------------'+lstacc);
            if(lstacc.size()>2||lstacc.size()<2){
                pgmsg=true;
                                       }
            else{
               lw.remove(li[0]);
               lw.remove(li[1]-1);
               lw.add(new wrapper(lstacc[0],li[1],false));
               lw.add(new wrapper(lstacc[1],li[0],false));
                 }  
                 lw.sort();           
                 return null;
                                             }
    
    List<Account> la;
    public List<wrapper> lw{get; set;}
    public swapcls(){
        lw=new List<wrapper>();
        la=[select id,name,rating,phone from Account limit 50];
        for(integer i=0; la.size()>i;i++){          
            lw.add(new wrapper(la[i],i,false));
            
                         }
                    }

    global class wrapper implements comparable{
        public Account name{get; set;}
        public boolean selected{get; set;}
        public integer num{get; set;}
        public wrapper(Account n,integer nbr,boolean c){
            name=n;
            num=nbr;
            selected=c;
                                             }
    global Integer compareTo(Object compareTo) {
        wrapper compareTolw = (wrapper)compareTo;
        if (num == compareTolw.num) return 0;
        if (num > compareTolw.num) return 1;
        return -1;        
                                                }                            
                                              }
                                  }

Adding Attachments to a Object


Ex:1

Visualforce Page:

<apex:page standardcontroller="Student1__c" extensions="studentcls">
    <apex:form >
        <apex:pageBlock >
            <apex:pageblockSection title="Student Details">
                <apex:inputField value="{!Student1__c.Name}"/>
                <apex:inputField value="{!Student1__c.Gender__c}"/>
                <apex:inputField value="{!Student1__c.Qualification__c}"/>
                <apex:inputField value="{!Student1__c.Skill_Set__c}"/>
                <apex:inputField value="{!Student1__c.Location__c}"/>
            </apex:pageblockSection>
            <apex:pageblockSection title="Upload Resume">
                <apex:pageblockSectionItem >
                    <apex:outputLabel value="Upload File" for="file"/>
                    <apex:inputFile value="{!attbody}" fileName="{!attname}"/>        
                </apex:pageblockSectionItem>       
            </apex:pageblockSection>
            <apex:pageblockButtons >
                <apex:commandButton value="Save" action="{!saverec}"/>
            </apex:pageblockButtons>
        </apex:pageBlock>
    </apex:form>
</apex:page>

Apex Class:

public with sharing class studentcls {
Student1__c s;
     public studentcls(ApexPages.StandardController controller) {
           s = (Student1__c)controller.getrecord(); 
     }
     public Blob attbody{get; set;}
     public String attname{get; set;}
     public Attachment attachment{get; set;}
     public PageReference saverec(){
         upsert s;
         if(attbody!=null)
         {
         List<attachment> la = [select id from attachment where parentid=:s.id];
         if(la.size()>0)
         delete la;
         Attachment a = new Attachment();
         a.body = attbody;
         a.name = attname;
         a.parentid = s.id;
         insert a;
         }
         return new pagereference('/'+s.id);
                                   }
}

Ex:2

Visualforce page:

<apex:page controller="clsstudent">
  <apex:form >
   
   <table >
   <tr>
    <td align="right">
     <apex:outputLabel style="font-size:18px">Student Name:</apex:outputLabel> 
    </td>
    
    <td>
     <apex:inputText value="{!sname}"/>
    </td>
   </tr>
   
   <tr>
    <td align="right">
     <apex:outputLabel style="font-size:18px">Qualification:</apex:outputLabel>
    </td>
    
    <td>
     <apex:inputText value="{!qua}"/>
    </td>
   </tr>
   
   <tr>
    <td align="right">
     <apex:outputLabel style="font-size:18px">Skills:</apex:outputLabel>
    </td>
    
    <td>
     <apex:inputTextarea value="{!sk}"/>
    </td>
   </tr>
   
   <tr>
    <td align="right">
     <apex:outputLabel style="font-size:18px">Gender:</apex:outputLabel>
    </td>
    
    <td>
     <apex:inputText value="{!gn}"/>
    </td>
   </tr>
   
   <tr>
    <td align="right">
     <apex:outputLabel style="font-size:18px">Location:</apex:outputLabel>
    </td>
    
    <td>
     <apex:inputText value="{!loc}"/>
    </td>
   </tr>
   
   <tr>
   <td align="right">
    <apex:inputFile value="{!filedata}" filename="{!filename}" />
    </td>
   </tr>
   </table>
   
    <apex:commandButton value="Save" action="{!save}"/>
   
  </apex:form>
</apex:page>

Apex Class:

public with sharing class clsstudent {

    public PageReference save() {
         Student1__c s=new Student1__c();
   
    s.Name=sname ;
    s.Qualification__c=qua ;
    s.Skill_Set__c=sk ;
    s.Gender__c=gn ;
    s.Location__c=loc ;
    insert s;
    attachment a=new attachment();
    a.Body=filedata;
    a.name=filename;
    a.parentid=s.id;
    insert a;
   
    pagereference ref=new pagereference('/'+s.id);
        return ref;
    }

    public blob filedata { get; set; }
    public String filename { get; set; }
    public String loc { get; set; }
    public String gn { get; set; }
    public String sk { get; set; }
    public String qua { get; set; }
    public String sname { get; set; }
}

Disable and Enable inputtext, copy Date and Text


1.Enabling and Disabling inputtext box through inputcheckbok

<apex:page controller="checkingcls" id="p">
     <apex:form id="f">
         <apex:actionFunction name="endis" action="{!checkmeth}"/>
             <apex:inputCheckbox onchange="endis()" id="icb" value="{!val}"/>
                    <apex:outputPanel >
                       <apex:inputtext disabled="{!tryonce}" id="it"/>
                    </apex:outputPanel>
        </apex:form>
</apex:page>

Apex Class:

public with sharing class checkingcls {
    public boolean val { get; set; }
    public PageReference checkmeth() {
        if(val==true)
            tryonce=false;
        if(val==false)
            tryonce=true;
        return null;
    }
    public boolean tryonce { get; set; }
        public checkingcls(){
            tryonce=true;
                             }    
}

2.dynamic copy of text from one inputtext to another inputtext

<apex:page id="p">
<script>
    function copycode(){
        var texts=document.getElementById('p:f:pb:it1').value;
        //alert(texts);
        var texts1=texts;
        //alert(texts1);
        document.getElementById('p:f:pb:it2').value=texts1;
                       }
</script>
  <apex:form id="f" >
      <apex:pageblock id="pb" >
          <apex:inputtext id="it1" onkeyup="copycode()" title="one"/><br/>
          <apex:inputtext id="it2" size="30"/><br/> 
      </apex:pageblock>
  </apex:form>
</apex:page>

3.copying date from inputfield to inputtext

<apex:page standardController="Account" id="p" >
<script>
    function copdate(){
       // alert('Hi');
        var cop=document.getElementById('p:f:pb:if').value;
        //alert(cop);
        document.getElementById('p:f:pb:it').value=cop;
                      }
</script>

    <apex:form id="f">   
        <apex:pageBlock id="pb">
            <apex:inputField value="{!Account.week__c}" id="if" onchange="copdate()" /><br/>
            <apex:inputtext id="it" />
        </apex:pageBlock>
    </apex:form>
</apex:page>

---------------------------------------------------------------------------------------------------
The above three tasks implemented in one VF page and Apex Class
---------------------------------------------------------------------------------------------------

Visualforce Page:


<apex:page standardcontroller="Account" extensions="checkingcls" id="p">
<script>
    function copdate(){
       // alert('Hi');
        var cop=document.getElementById('p:f:pb:pbs1:if').value;
        //alert(cop);
        document.getElementById('p:f:pb:pbs1:pbsi1:it').value=cop;
                      }
</script>
     <apex:form id="f">
     <apex:pageblock id="pb" >
     <apex:actionFunction name="endis" action="{!checkmeth}"/>
     <apex:pageblocksection title="EnDis" id="pbs">
         <apex:pageblocksectionitem id="pbsi">
             <apex:inputCheckbox onchange="endis()" id="icb" value="{!val}"/>
             <apex:inputtext disabled="{!tryonce}" id="it" value="{!var}"/>   
         </apex:pageblocksectionitem>                 
     </apex:pageblocksection>
     <apex:pageblocksection title="Date" id="pbs1">
         <apex:inputField value="{!Account.SLAExpirationDate__c}" id="if" onchange="copdate()"/><br/>
         <apex:actionFunction name="twodisab" action="{!disabmeth}"/>
             <apex:inputCheckbox id="icb" onchange="twodisab()" value="{!sval1}" />
         <apex:pageblockSectionItem id="pbsi1">
             <apex:inputtext id="it" disabled="{!itdisab}"/>
        
         <apex:selectList value="{!selected}" size="1" id="sl" disabled="{!sldisab}">
             <apex:selectOptions value="{!items}"/>
         </apex:selectList>
          </apex:pageblockSectionItem>
     </apex:pageblocksection>
     </apex:pageblock>
     </apex:form>
</apex:page>

Apex Class:

public with sharing class checkingcls {
        public boolean itdisab{get; set;}
        public boolean sldisab{get; set;}
        public boolean sval1{get; set;}
        public string selected{get; set;}
        public List<selectoption> items{get; set;}
    public checkingcls(ApexPages.StandardController controller) {
            sval1=true;                
            tryonce=true;
            var='Narayana Reddy';
            items=new List<selectoption>();
            items.add(new selectoption('1','08.00AM'));
            items.add(new selectoption('2','09.00AM'));
            items.add(new selectoption('3','10.00AM'));
            items.add(new selectoption('4','11.00AM'));
            items.add(new selectoption('5','12.00PM'));
            items.add(new selectoption('6','01.00PM'));
            items.add(new selectoption('7','02.00PM'));
            items.add(new selectoption('8','03.00PM'));
            items.add(new selectoption('9','04.00PM'));
            items.add(new selectoption('10','05.00PM'));
            items.add(new selectoption('11','06.00PM'));
            items.add(new selectoption('12','07.00PM'));
            items.add(new selectoption('13','08.00PM'));         
    }

    public String var { get; set; }
    public boolean val { get; set; }
    public PageReference checkmeth() {
        if(val==true)
            tryonce=false;
        if(val==false)
            tryonce=true;
        return null;
    }
    public boolean tryonce { get; set; }
    
    public PageReference disabmeth(){
            if(sval1==false)
            {
                itdisab=true;
                sldisab=true;
            }
            if(sval1==true)
            {
                itdisab=false;
                sldisab=false;
            }
        return null;
                                    }      
            }