• nikita dhamal
  • NEWBIE
  • 60 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 29
    Questions
  • 18
    Replies
I have a workflow rule to send email on creation of record. I made this on  developer edition  and made managed package and deployed it ti professional edition. It was working fine in developer edition but not working in professional edition.
 Can anyone tell me the reason??
Is it due to the fact that workflow does not work in PE.. 
I have brought content delivery related list on my account page layout and it is working fine on desktop but not on the salesforce 1 .Can anyone tell me what is the problem??
Does Content delivery work on salesforce1??
I have a requirement that the user will select some objects from a list of objects(on a vf page) he has on his org  and i want to fire same trigger on those selected objects individually. Is it possible??
Does anyone have a solution for this?

I want to show the accounts that arein particular radius of the   current location specified by latitudes and longitudes on a visualforce page.Can anyone help me with code for the same??

 

I have  a javascript on a vf page from which i want to pass value to the controller. but i am getting null in the controller.can anyone help me in this? my code:
VF page:

<apex:page controller="visitController" showHeader="false" sidebar="false" setup="true" standardStylesheets="false">
<apex:form > <style> body { padding: 20px; background-color:#ffffc9 } p { margin : 0; } </style>
<Script> function geoFindMe()
{ var output = document.getElementById("out");
if (!navigator.geolocation){
output.innerHTML = "<p>Geolocation is not supported by your browser</p>"; return;
}
function success(position)
{ var latitude = position.coords.latitude;
var longitude = position.coords.longitude;
echo(latitude,longitude );
output.innerHTML = '<p>Latitude is ' + latitude + '° <br>Longitude is ' + longitude + '°</p>'; var img = new Image();
img.src = "https://maps.googleapis.com/maps/api/staticmap?center=" + latitude + "," + longitude + "&zoom=13&size=300x300&sensor=false"; output.appendChild(img); };
function error() {
output.innerHTML = "Unable to retrieve your location"; };
output.innerHTML = "<p>Locating…</p>";
navigator.geolocation.getCurrentPosition(success, error); }
</script>
<body>
 <apex:pageBlock id="block"> Sales Visit Name: <br />
<apex:inputField value="{!visit.name}" /><br />
Sales Visit Description: <br /> <apex:inputField value="{!visit.Description__c}" /><br /> Longitude: <br /> <apex:inputField value="{!visit.Longitude__c}" id="longitude" /><br />
Latitude: <br /> <apex:inputField value="{!visit.Latitude__c}" id="latitude" /><br /> <br/> <br/>
<apex:commandButton onclick="geoFindMe()" action="{!save}" value="Show my location!" /> <div id="out"></div>
<apex:actionFunction name="echo" action="{!echoVal}" reRender="resultPanel" status="myStatus">
<apex:param name="latitude" assignTo="{!enteredText1}" value="" />
<apex:param name="longitude" assignTo="{!enteredText2}" value="" />
</apex:actionFunction> </apex:pageBlock>
</body>
</apex:form>
</apex:page>

Controller:
public class visitController { 
    public String save { get; set; }

  public String Latval ;
  public String Lonval ;
    public Sales_Visit__c visit {get;set;}
 
 public String latitude {get;set;} 
 public String longitude{get;set;} 
  
    public visitController() {
        visit = new Sales_Visit__c();
        
       
    }   
 public void echoVal() 
    { 
    //  Latval = Apexpages.currentPage().getParameters().get('latitude');
     // Lonval = Apexpages.currentPage().getParameters().get('longitude'); 
     
    //  System.debug('*********latitude echoValechoVal latitude*********'+Latval);
     //      System.debug('*********longitude echoValechoVal longitude*********'+Lonval);
    } 

    
    public PageReference save() {
     Latval = Apexpages.currentPage().getParameters().get('latitude');
   Lonval = Apexpages.currentPage().getParameters().get('longitude'); 
     
     System.debug('*********latitudelatitude*********'+Latval);
           System.debug('*********longitudelongitude*********'+Lonval);
    
        insert visit;
        
        visit = new Sales_Visit__c();
        return null;
    }
}
Hi all,
              I have a requirement to interate the ccavenue payment gateway with salesforce.. is it possible? if yes then can anyone provide me with the stepwise procedure to do so???
      Help its urgent!!!!!!!!!
I have a controller with wrapper class in it..can someone help to to write test class for it??
My controller is:
public class ContactSelectClassController{

  public String beforeblob1{get;set;}
    public String conid{get;set;}
    public String emailEncoded { get; set; }
    public String email { get; set; }
    public String phoneEncoded { get; set; }
    public String con_number { get; set; }
    public String fullname{get;set;}
     public String emailName{get;set;}
    public String fullnameEncoded{get;set;}
    @TestVisible public List<wrapAccount> wrapAccountList {get; set;}
    public List<Contact> selectedAccounts{get;set;}
    public String feedid;
    private  List<Id> contactids=new list<Id>();
    public List<Contact> conts;
      public List<Contact> cont;
  
    public List<Feedback_Contacts__c> feedcon{get;set;} 
    
      public ContactSelectClassController(ApexPages.StandardController controller) 
    {
      
    /*  conid = ApexPages.currentPage().getParameters().get('conid');
         system.debug('+++++++++CONID+++++++++'+conid);
         Contact con =[Select firstname,lastname,email,phone,id from contact where id=:conid];
         system.debug('+++++++++CON+++++++++'+con ); */
 
    }
    
    public ContactSelectClassController()
    {
        
        
 
         
     feedid= (ApexPages.currentPage().getParameters().get('fid'));
      emailName= (ApexPages.currentPage().getParameters().get('emailName'));
     fullnameEncoded = ApexPages.currentPage().getParameters().get('fullname');
       emailEncoded = ApexPages.currentPage().getParameters().get('email');
       phoneEncoded = ApexPages.currentPage().getParameters().get('con_number');
    system.debug('*********************Feedback id is :*********************************'+fullname+' '+email+' '+con_number+' '+feedid+' '+emailName);
     system.debug('*********************contactidscontactidscontactids:*********************************'+selectedAccounts);
           
        if(wrapAccountList == null)
         {
            wrapAccountList = new List<wrapAccount>();
            for(Contact a: [select Id, Name,Email,Phone from Contact])
             {
                wrapAccountList.add(new wrapAccount(a));
             }
         }
         
         
  
     }
   public pageReference CancelAction()
  {
    PageReference pr1 = new PageReference('/apex/FeedbackMainlist');
   
    pr1.setRedirect(true);
    return pr1;
  } 

    public void processSelected()
     {
     
     feedid= (ApexPages.currentPage().getParameters().get('id'));
     system.debug('+++++++FEEDID++++++++'+feedid);
        
          fullnameEncoded = ApexPages.currentPage().getParameters().get('fullname');
           system.debug('++++++++NAMEENCODED++++++'+fullnameEncoded );
              if(fullnameEncoded !=null || fullnameEncoded =='')
  {
  Blob bodyBlob1 =EncodingUtil.base64Decode(fullnameEncoded );
   fullname = bodyBlob1.toString();
   system.debug('++++++++fullname ++++++'+fullname);
  }
  else{
   fullname = ApexPages.currentPage().getParameters().get('fullname');
  }
  
    emailEncoded = ApexPages.currentPage().getParameters().get('email');
  
  if(emailEncoded !=null || emailEncoded =='')
  {
  Blob bodyBlob1 =EncodingUtil.base64Decode(emailEncoded );
  email = bodyBlob1.toString();
  }
  else{
   email = ApexPages.currentPage().getParameters().get('email');
  }
  
  phoneEncoded = ApexPages.currentPage().getParameters().get('con_number');
  if(phoneEncoded !=null )  
  { 
  Blob bodyBlob2 =EncodingUtil.base64Decode(phoneEncoded );
  con_number =bodyBlob2.toString();
  }
  else{
  con_number=ApexPages.currentPage().getParameters().get('con_number');
  } 
        
    selectedAccounts = new List<Contact>();
 
        for(wrapAccount wrapAccountObj : wrapAccountList)
         {
            if(wrapAccountObj.selected == true)
             {
                selectedAccounts.add(wrapAccountObj.acc);
                 
             }
         }
          
          for(Contact cont: selectedAccounts)
        {
           contactids.add(cont.Id);
        } 
        
        
       feedcon=new List<Feedback_Contacts__c>();
     
        for(Contact cont: selectedAccounts)
       {
       
        cont  =  [Select firstname,lastname,email,id,name,MobilePhone from Contact where id in :selectedAccounts  ];
     system.debug('+++++++++CONT++++++++++'+cont  );
        string fullname = cont.firstname + ' ' + cont.lastname; 
          if(fullname !=null && email!=null && con_number!=null )
       {
        Blob beforeblob = Blob.valueOf(fullname);
        EncodingUtil.urlEncode(fullname,'UTF-8');
     
        string email = cont.email;
        Blob beforeblob1 = Blob.valueOf(email); 
        EncodingUtil.urlEncode(email,'UTF-8');
   
           string con_number = cont.MobilePhone;
           Blob beforeblob2 = Blob.valueOf(con_number);
           EncodingUtil.urlEncode(con_number,'UTF-8'); 
        
        Feedback_Contacts__c fc=new Feedback_Contacts__c();
        fc.FeedbackContactName__c=cont.Id;
        fc.FeedBackNo__c=feedid;
        fc.test__c = EncodingUtil.base64Encode(beforeblob ) ;
        fc.Email__c = EncodingUtil.base64Encode(beforeblob1 ) ;
       fc.ConNumber__c= EncodingUtil.base64Encode(beforeblob2 ) ;
        
        feedcon.add(fc);
        
        }
         insert feedcon; 
         } 
        Messaging.MassEmailMessage mail = new Messaging.MassEmailMessage();
        mail.setTargetObjectIds(contactids);
        mail.setTemplateId('00X360000015j6P');
       Messaging.sendEmail(new Messaging.MassEmailMessage[] {mail});
     }
 
    public class wrapAccount {
        public Contact acc {get; set;}
        public Boolean selected {get; set;}
 
        public wrapAccount(Contact a) {
            acc = a;
            selected = false;
        }
    }
}
 

I have written a trigger and a test class for it.. But it is giving only 5 %code coverage.Can anyone help me to increase it..
Trigger:
trigger PopulateNewContact on Product_EntryStatus__c (after insert,after update) {
    for(Product_EntryStatus__c p : trigger.new)
    {
   if(p.Country__c!=null && p.Key_Opinion_Leader__c!=null)
     {
      system.debug('CONTACT INFO*************'+p.Name+'**************'+p.Key_Opinion_Leader__c);
    try{
   NewContact__c v = [select id,Awareness__c,Credibility__c,Connection__c,Convinced__c,Advocating__c,KOL_Title__c,Status__c,Product__c,Order__c,KOL_Name__c,Country__c from NewContact__c
   where KOL_Name__c =:p.Key_Opinion_Leader__c and Country__c=:p.Country__c and Product__c=:p.Product__c ];
           system.debug('KOL'+v);
             if(p.Process_Step__c == 'Awareness')
            {  
               v.Awareness__c = p.id;
            } 
             if(p.Process_Step__c == 'Credibility')
            {  v.Credibility__c = p.id;
            }
             if(p.Process_Step__c == 'Connection')
            {v.Connection__c = p.id;
  }
             if(p.Process_Step__c == 'Convinced')
            {
               
                v.Convinced__c = p.id;
                
          
            } if(p.Process_Step__c == 'Advocating')
            {
               
               v.Advocating__c = p.id;
          
            }
       
            if(p.Country__c != null)
            {
                v.Country__c = p.Country__c;
           
             } 
               if(p.KOL_Title__c != null)
            {
                v.KOL_Title__c = p.KOL_Title__c;
           
             }
   
            if(p.Status__c != null)
            {
                v.Status__c = p.Status__c;
           
             } 
              if(p.Product__c != null)
            {
                v.Product__c = p.Product__c;
           
             }
            if(p.Order__c != null)
            {
                v.Order__c = p.Order__c;
           
             } 
               if(p.Key_Opinion_Leader__c != null)
            {
                v.KOL_Name__c = p.Key_Opinion_Leader__c;
           
             } 
              update v;
          } 

      catch(Exception e)
      {    
          NewContact__c c = new NewContact__c();
        
           system.debug('Query*************'+c);
        
             if(p.Process_Step__c == 'Awareness')
            {                
               c.Awareness__c = p.id;
            } 
             if(p.Process_Step__c == 'Credibility')
            {
               
                c.Credibility__c = p.id;
          
            }
             if(p.Process_Step__c == 'Connection')
            {
                
                c.Connection__c = p.id;
          
            }
             if(p.Process_Step__c == 'Convinced')
            {
               
                c.Convinced__c = p.id;
                
          
            } if(p.Process_Step__c == 'Advocating')
            {
               
               c.Advocating__c = p.id;
          
            }
      
            if(p.Country__c != null)
            {
                c.Country__c = p.Country__c;
           
             } 
               if(p.KOL_Title__c != null)
            {
                c.KOL_Title__c = p.KOL_Title__c;
           
             }
   
            if(p.Status__c != null)
            {
                c.Status__c = p.Status__c;
           
             } 
              if(p.Product__c != null)
            {
                c.Product__c = p.Product__c;
           
             }

               if(p.Order__c != null)
            {
                c.Order__c = p.Order__c;
           
             } 
               if(p.Key_Opinion_Leader__c != null)
            {  c.KOL_Name__c = p.Key_Opinion_Leader__c;  } 
              insert c; 
      } 
      }   
}
}
Test Class:
@isTest(SeeAllData=true)
private class TestPopulateNewContact
{
 static testMethod void TestPopulateNewContact()
 {
 Map <String,Schema.RecordTypeInfo> recordTypeMap = Account.sObjectType.getDescribe().getRecordTypeInfosByName();
Account accountObj = new Account();
accountObj.name = 'Test Record Type';
if(recordTypeMap.containsKey('Country')) 
{
 accountObj.RecordTypeId= recordTypeMap.get('Country').getRecordTypeId();
}
insert accountObj;

Product2 p= new Product2(Name='Pali 250WG',Dilution_volume__c='ndklc');
insert p;

Contact c= new Contact( FirstName='John',LastName='Walton',MailingCountry='South Africa',MailingStreet='Free State',
MailingState='Free State');
insert c;        

Product_EntryStatus__c pes =new Product_EntryStatus__c(Product__c=p.Id,Global_Objective__c='AchieveRegistration',
Process_Step__c='Awareness',Country__c=accountObj.id,Order__c=1.00,Key_Opinion_Leader__c=c.Name);           
insert pes;

NewContact__c ns= new NewContact__c(KOL_Title__c='Title',KOL_Name__c =c.Name, Country__c= pes.Country__c, Product__c=pes.Product__c );
insert ns;
Product_EntryStatus__c pes1 =new Product_EntryStatus__c(Product__c=p.Id,Global_Objective__c='AchieveRegistration',
Process_Step__c='Credibility',Country__c=accountObj.id,Key_Opinion_Leader__c=c.Name);           
insert pes1;

NewContact__c ns1= new NewContact__c(KOL_Title__c='Title',KOL_Name__c =c.Name, Country__c= pes.Country__c, Product__c=pes.Product__c,Credibility__c  = pes1.id );
insert ns1;



 }

}
 

I want to send an email alert to create a pdf of the invoice when enddate of the milestone is reached(milestone and invoice has lookup relation).
I am using professional edition so this can be done using process builder. but my process builder is not working properly..can anyone provide me with some solution for this??
Do we have Any alternate solution to do it??
I have used the mass email functionality  in my code but after sending emails 10 times jus to single person or 2 at a time i got the following error:
Visualforce Error
Help for this Page
System.EmailException: SendEmail failed. First exception on row 0; first error: MASS_MAIL_LIMIT_EXCEEDED, Email limit exceeded: []
Error is in expression '{!processSelected}' in component <apex:commandButton> in page sendmail: Class.ContactSelectClassController.processSelected: line 81, column 1
Class.ContactSelectClassController.processSelected: line 81, column 1
I am pasting  my code below:
Visualforcepage:
apex:pageBlock >
            <apex:pageBlockButtons location="bottom">
                <apex:commandButton value="Send Email" action="{!processSelected}" styleClass="sendemail" rerender="table2"/>
            </apex:pageBlockButtons>
 
            <apex:pageblockSection title="All Contacts" collapsible="false">
 
             <apex:pageBlockTable value="{!wrapAccountList}" var="accWrap" id="table">
                    <apex:column >
                        <apex:facet name="header">
                            <apex:inputCheckbox onclick="selectAllCheckboxes(this,'inputId')"/>
                        </apex:facet>
                        <apex:inputCheckbox value="{!accWrap.selected}" id="inputId"/>
                    </apex:column>
                    <apex:column value="{!accWrap.acc.Name}" />
                    <apex:column value="{!accWrap.acc.Email}" />
                    <apex:column value="{!accWrap.acc.Phone}" />
                </apex:pageBlockTable>
 
               <apex:pageBlockTable value="{!selectedAccounts}" var="c" id="table2" title="Selected Accounts">
                   <apex:column value="{!c.Id}" headerValue="Contact"/>
                    <apex:column value="{!c.Name}" headerValue="Contact Name"/>
                    <apex:column value="{!c.Email}" headerValue="Email"/>
                    <apex:column value="{!c.Phone}" headerValue="Phone"/>
                    
                </apex:pageBlockTable>
 
            </apex:pageblockSection>
            
        </apex:pageBlock> 
Controller:
public class ContactSelectClassController{
 
   
    public List<wrapAccount> wrapAccountList {get; set;}
    public List<Contact> selectedAccounts{get;set;}
    public String feedid;
    private  List<Id> contactids=new list<Id>();
    public List<Contact> conts;
   
    public List<Feedback_Contacts__c> feedcon{get;set;} 
    public ContactSelectClassController()
    {
     feedid= (ApexPages.currentPage().getParameters().get('fid'));
    system.debug('*********************Feedback id is :*********************************'+feedid);
     system.debug('*********************contactidscontactidscontactids:*********************************'+selectedAccounts);
           
        if(wrapAccountList == null)
         {
            wrapAccountList = new List<wrapAccount>();
            for(Contact a: [select Id, Name,Email,Phone from Contact])
             {
                wrapAccountList.add(new wrapAccount(a));
             }
         }
     }
   public pageReference CancelAction()
  {
    PageReference pr1 = new PageReference('/apex/LaunchPage');
   
    pr1.setRedirect(false);
    return pr1;
  } 

    public void processSelected()
     {
     
     feedid= (ApexPages.currentPage().getParameters().get('fid'));
     
       system.debug('*********************Feedback id feedidfeedid :*********************************'+feedid);
        system.debug('*********************contactidscontactidscontactids:*********************************'+selectedAccounts);
           
    selectedAccounts = new List<Contact>();
 
        for(wrapAccount wrapAccountObj : wrapAccountList)
         {
            if(wrapAccountObj.selected == true)
             {
                selectedAccounts.add(wrapAccountObj.acc);
                 system.debug('*********************contactidscontactidscontactids:*********************************'+selectedAccounts);
           
             }
         }
         system.debug('*********************selectedAccountsselectedAccountsselectedAccounts*********************************'+selectedAccounts);
           
          for(Contact cont: selectedAccounts)
        {
           system.debug('*********************contactidscontactidscontactids:*********************************'+contactids);
            contactids.add(cont.Id);
            system.debug('*********************contactidscontactidscontactids:*********************************'+contactids);
        } 
        feedcon=new List<Feedback_Contacts__c>();
        for(Contact cont: selectedAccounts)
        {
        Feedback_Contacts__c fc=new Feedback_Contacts__c();
        fc.FeedbackContactName__c=cont.Id;
        fc.FeedBackNo__c='a0036000005RaG0';
        
        feedcon.add(fc);
        insert fc;
        // feedcon.add(cont.Id);
        // feedcon.add('a0036000005RaG0');
         
        } 
        
        Messaging.MassEmailMessage mail = new Messaging.MassEmailMessage();
      system.debug('*********************selectedAccountsselectedAccountsselectedAccounts*********************************'+selectedAccounts);
   // system.debug('*********************s*********************************'+);
              
        mail.setTargetObjectIds(contactids);
        mail.setTemplateId('00X360000015j6P');
        Messaging.sendEmail(new Messaging.MassEmailMessage[] { mail });
     }
 
    public class wrapAccount {
        public Contact acc {get; set;}
        public Boolean selected {get; set;}
 
        public wrapAccount(Contact a) {
            acc = a;
            selected = false;
        }
    }
}

How will i be able to get the limit for my org 
I have a a requirement that when priview button on the 1st vf page is clicked then the corresponding information of the record for which the button is pressed should be displayed on a new vf page. but it is not working properly.. my code is:
Ist vf page:
<apex:page standardController="FeedbackMain__c" extensions="FeedbackMainlistController">
<apex:form>
  <apex:pageBlock >
  <apex:pageBlockTable value="{!feed}" var="a" rowClasses="oddrow,evenrow,dataTableRow" styleClass="fontfamily" id="Details1" style="width:40%;">
            <apex:column headerValue="Feedback Number" style="width:10%;">
            <apex:outputField value="{!a.Name}"/> <br></br>
        </apex:column>
         <apex:column headerValue="Feedback Preview" style="width:35%;" >
            <input type="button" onclick="{!queslist}" value="Preview" style="width:35%;"/>
            </apex:column>
  </apex:pageBlockTable>
  </apex:pageBlock>
  </apex:form>
</apex:page>
controller:

public class FeedbackMainlistController
{
  Public Id qid{get;set;}
    public FeedbackMainlistController(ApexPages.StandardController controller) {
       qid=controller.getId();
    }
    public List <FeedbackMain__c>queslist;
    public List<FeedbackMain__c> showQues;
    public List<FeedbackMain__c> feed;
    public List<FeedbackMain__c> getFeed()
 {
feed=[SELECT id,name,Feedback_Name__c FROM FeedbackMain__c];
return feed;


 }
  public pageReference queslist()
  {
  
    //showQues=[SELECT Related_Question_Bank__r.Name FROM FeedbackMain__c where id=:qid];
    PageReference P = new PageReference('https://c.cs20.visual.force.com/apex/FeedbackQuestionMain');
    p.setRedirect(true);
    return p;
  }
}

2nd vf page:
<apex:page standardController="FeedbackMain__c" extensions="FeedbackMainlistController">> <apex:pageBlock > <apex:pageBlockTable value="{!feed}" var="a" rowClasses="oddrow,evenrow,dataTableRow" styleClass="fontfamily" id="Details1" style="width:40%;"> <!-- <div id="{!a.Id}" class="hideshow{!a.Id}">--> <apex:column headerValue="Feedback Question" style="width:10%;"> <div id="{!a.Id}" class="hideshow{!a.Id}"> <apex:outputField value="{!a.Related_Question_Bank__r.Name}"/> <br></br> </div> </apex:column> </apex:pageBlockTable> </apex:pageBlock> </apex:page>
I have developed an app in salesforce which i want to put on the app exchange .can anyone tell me the stepwise procedure to do the same??
its urgent..please help
I want to migrate data of communities from 1 sandbox to another.. is it possible? can anyone give me the steps to do so?
I have a requirement that when particular contacts are selected from the contacts list email should be sent to those contacts.but it is giving the above error . my code is:
vf page:
<apex:page controller="ContactSelectClassController" sidebar="false">
    <script type="text/javascript">
        function selectAllCheckboxes(obj,receivedInputID){
            var inputCheckBox = document.getElementsByTagName("input");
            for(var i=0; i<inputCheckBox.length; i++){
                if(inputCheckBox[i].id.indexOf(receivedInputID)!=-1){
                    inputCheckBox[i].checked = obj.checked;
                }
            }
        }
    </script>
    <apex:form >
        <apex:pageBlock >
            <apex:pageBlockButtons >
                <apex:commandButton value="Show Selected Accounts" action="{!processSelected}" rerender="table2"/>
            </apex:pageBlockButtons>
 
            <apex:pageblockSection title="All Contacts" collapsible="false" columns="2">
 
             <apex:pageBlockTable value="{!wrapAccountList}" var="accWrap" id="table" title="All Contacts">
                    <apex:column >
                        <apex:facet name="header">
                            <apex:inputCheckbox onclick="selectAllCheckboxes(this,'inputId')"/>
                        </apex:facet>
                        <apex:inputCheckbox value="{!accWrap.selected}" id="inputId"/>
                    </apex:column>
                    <apex:column value="{!accWrap.acc.Name}" />
                    <apex:column value="{!accWrap.acc.Email}" />
                    <apex:column value="{!accWrap.acc.Phone}" />
                </apex:pageBlockTable>
 
                <apex:pageBlockTable value="{!selectedAccounts}" var="c" id="table2" title="Selected Accounts">
                   <apex:column value="{!c.Id}" headerValue="Contact"/>
                    <apex:column value="{!c.Name}" headerValue="Contact Name"/>
                    <apex:column value="{!c.Email}" headerValue="Email"/>
                    <apex:column value="{!c.Phone}" headerValue="Phone"/>
                    
                </apex:pageBlockTable>
 
            </apex:pageblockSection>
            <apex:pageBlockButtons >
                <apex:commandButton value="Send Email" action="{!SendEmail}"/>
            </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:form>
 
</apex:page>

controller:
public class ContactSelectClassController{
 
   
    public List<wrapAccount> wrapAccountList {get; set;}
    public List<Contact> selectedAccounts{get;set;}
 
 private  List<Id> contactids=new list<Id>();
  public List<Contact> conts;
  
 

  public void SendEmail()
  {
    
      for(Integer i=0;i<5;i++)
     {
         contactids.add(selectedAccounts[i].Id);
      } 
       Messaging.MassEmailMessage mail = new Messaging.MassEmailMessage();
       mail.setTargetObjectIds(contactids);
       mail.setTemplateId('00X28000000QfNL');
// the above template id is a valid id of template i have created.
       Messaging.sendEmail(new Messaging.MassEmailMessage[] { mail });
      
 } 
 
 
 
    public ContactSelectClassController()
    {
        if(wrapAccountList == null)
         {
            wrapAccountList = new List<wrapAccount>();
            for(Contact a: [select Id, Name,Email,Phone from Contact limit 10])
             {
                wrapAccountList.add(new wrapAccount(a));
             }
         }
     }
 
    public void processSelected()
     {
    selectedAccounts = new List<Contact>();
 
        for(wrapAccount wrapAccountObj : wrapAccountList)
         {
            if(wrapAccountObj.selected == true)
             {
                selectedAccounts.add(wrapAccountObj.acc);
                
           
             }
         }
     }
 
    public class wrapAccount {
        public Contact acc {get; set;}
        public Boolean selected {get; set;}
 
        public wrapAccount(Contact a) {
            acc = a;
            selected = false;
        }
    }
}
User-added image
i have 3 date fields sop, sofi, confirmdelivery. as shown in the image i have condition that for dates between sop and sofi i need to show blue color similarly for date between sofi to confirmdelivery display purple color. for this i have given my code below:
 but the problem is it is not considering month of end date. 
is there any way to compare dates in apex repeat or does anyone has any other solution for this??

vf code:
 <apex:repeat value="{!verleih}" var="t">
                        <tr>
                            <td class="anlage">
                                <apex:outputLink value="/{!t.Id}" title="PT System Details" target="_blank">{!t.Name}</apex:outputLink>
                            </td>
                         
                            <td class="anlage">
                                <apex:outputLink value="/{!t.Id}" title="PT System Owner" target="_blank">{!t.Owner.Name}</apex:outputLink>
                            </td>
                            
                            <apex:repeat value="{!weeks}" var="wk">
                            <apex:repeat value="{!wk.days}" var="day">
                            
                            <td align="left" class="{!day.cssname}" valign="top">
                            
                              <apex:variable var="ACTUALDATE" value="{!wk.startingdate}">
                              <apex:variable var="SOFIDATE" value="{!t.SOFI__c}">
                              <apex:variable var="SOPDATE" value="{!t.SOP__c}">     
                              <apex:variable var="CONFIRMDATE" value="{!t.Confirmed_delivery_date__c}">

                              
                              
                                <apex:variable var="dayOf" value="{!DAY(day.date)}">
                                <apex:variable var="monthOf" value="{!MONTH(day.date)}">
                                <apex:variable var="yearOf" value="{!YEAR(day.date)}">
                                <apex:variable var="sofi" value="{!TEXT(t.SOFI__c)}">
                                <apex:variable var="SOP_DAY" value="{!DAY(t.SOP__c)}">
                                <apex:variable var="SOP_MONTH" value="{!MONTH(t.SOP__c)}">     
                                <apex:variable var="SOFI_DAY" value="{!DAY(t.SOFI__c)-1}">
                                <apex:variable var="SOFI1_DAY" value="{!DAY(t.SOFI__c)}">
                                <apex:variable var="SOFI_MONTH" value="{!MONTH(t.SOFI__c)}"> 
                                
                                
                                 <apex:variable var="monthOf1" value="{!MONTH(day.date)+1}"/> 
                                <apex:variable var="CONFIRM_DAY" value="{!DAY(t.Confirmed_delivery_date__c)-1}">
                                <apex:variable var="CONFIRM1_DAY" value="{!DAY(t.Confirmed_delivery_date__c)}">
                                <apex:variable var="CONFIRM_MONTH" value="{!MONTH(t.Confirmed_delivery_date__c)}">                                
                                <apex:variable var="sop" value="{!TEXT(t.SOP__c)}"/>
                                
                                    <apex:variable var="format1" value="{!DAY(day.date)}.{!MONTH(day.date)}.{!YEAR(day.date)}">
                                    <apex:variable var="format2" value="{!DAY(day.date)}/{!MONTH(day.date)}/{!YEAR(day.date)}">
                                    <apex:variable var="format3" value="{!DAY(day.date)}-{!MONTH(day.date)}-{!YEAR(day.date)}">
                                    <apex:variable var="format4" value="{!MONTH(day.date)}/{!DAY(day.date)}/{!YEAR(day.date)}">
                                    <apex:variable var="format5" value="{!YEAR(day.date)}.{!DAY(day.date)}.{!MONTH(day.date)}">
                                    <apex:variable var="format6" value="{!YEAR(day.date)}/{!MONTH(day.date)}/{!DAY(day.date)}">
                                    <apex:variable var="format7" value="{!YEAR(day.date)}-{!MONTH(day.date)}-{!DAY(day.date)}">
                                    
                                    <apex:variable var="d" value="{!CASE(Region,'de',format1,'de_DE_EURO',format1,'de_DE',format1,'uk',format1,CASE(Region,'ca',format2,'es',format2,'fr',format2,'fr_BE',format2,'fr_FR_EURO',format2,'fr_FR',format2,'en_CA',format2,'en_GB',format2,'it',format2,'it_IT',format2,CASE(Region,'da',format3,'da_DK',format3,'nl',format3,'nl_NL',format3,'pt_PT',format3,CASE(Region,'en_US',format4,'es_PR',format4,CASE(Region,'ko',format5,'ko_KR',format5,'hu',format5,'lt_LT',format5,CASE(Region,'ja',format6,'ja_JP',format6,CASE(Region,'fr_CA',format7,'')))))))}" >
                              
       <div style="margin-top:3px;margin-left:3px;z-index:1">
        <apex:outputPanel rendered="{!IF(SOP_DAY!=null && SOFI_MONTH!=null && SOP_MONTH!=null && SOFI_DAY!=null  && CONFIRM_MONTH!=null && CONFIRM_DAY!=null ,'true','false')}">
   
        <a class="{!IF((monthOf >= SOP_MONTH && dayOf >= SOP_DAY ) && (monthOf <= SOFI_MONTH && dayOf <=SOFI_DAY ), 'blue',
        IF(dayOf >= SOFI_DAY && dayOf <=CONFIRM_DAY && monthOf >= SOFI_MONTH && monthOf <= CONFIRM_MONTH, 'violet', 
        IF(dayOf=CONFIRM1_DAY && monthOf =CONFIRM_MONTH,'cross','error')))}" 
        style="hover:text-decoration:none;" href="/{!t.Id}" title="{!d}: PT System '{!t.Name}' for '{!t.Owner.Name}'" target="blank">_____</a> &nbsp;&nbsp;<font size="+1"></font>&nbsp; 
        </apex:outputPanel>
       </div>   
              
                            </apex:variable>
                            </apex:variable>
                            </apex:variable>
                            </apex:variable> 
                           
                            </apex:variable>
                            </apex:variable>
                            </apex:variable>
                            </apex:variable>
                            </apex:variable>
                            </apex:variable>
                            </apex:variable>
                            </apex:variable>
                            </apex:variable>
                            </apex:variable>
                            </apex:variable>
                            </apex:variable>
                            </apex:variable>
                            </apex:variable>
                            </apex:variable>
                            </apex:variable>
                            </apex:variable>
                            </apex:variable>
                            </apex:variable>
                            </apex:variable>
                            
                            </td>
                            </apex:repeat>
                            </apex:repeat>
                            </tr>
                    </apex:repeat>
I have three condition that when fufilled will show 3 different things ie blue ,red color and for third condition a 'X '. here i have issue that for a same record it is being displayed in 3 different rows as shown in image below and i want it in a single row. i found out that since m using 3 different <a> tags the problem is coming..can anyonye help me to combine my conditions in a single <a>  tag.
my code:

 <div style="margin-top:3px;margin-left:3px;z-index:1">
        <apex:outputPanel rendered="{!IF(SOP_DAY!=null && SOFI_MONTH!=null && SOP_MONTH!=null && SOFI_DAY!=null  && CONFIRM_MONTH!=null && CONFIRM_DAY!=null ,'true','false')}">
        <a class="{!IF(dayOf >= SOP_DAY && dayOf <=SOFI_DAY && monthOf >= SOP_MONTH && monthOf <= SOFI_MONTH, 'blue','')}" style="hover:text-decoration:none;" href="/{!t.Id}" title="{!d}: PT System '{!t.Name}' for '{!t.Owner.Name}'" target="blank">_____</a> &nbsp;&nbsp;<font size="+1"></font>&nbsp; 
        
        <a class="{!IF(dayOf > SOFI_DAY && dayOf <=CONFIRM_DAY && monthOf >= SOFI_MONTH && monthOf <= CONFIRM_MONTH, 'red','error')}" style="hover:text-decoration:none;" href="/{!t.Id}" title="{!d}: PT System '{!t.Name}' for '{!t.Owner.Name}'" target="blank">_____</a> &nbsp;&nbsp;<font size="+1"></font>&nbsp; 
       </apex:outputPanel> 
       
        <apex:outputPanel rendered="{!IF(dayOf=CONFIRM1_DAY && monthOf =CONFIRM_MONTH ,true,false)}">
        <a class="{!IF(dayOf=CONFIRM1_DAY && monthOf =CONFIRM_MONTH ,'X','')}" style="hover:text-decoration:none;background:white; !important  " href="/{!t.Id}" title="{!d}: PT System '{!t.Name}' for '{!t.Owner.Name}'" target="blank"></a> X &nbsp;<font size="+1"></font>&nbsp; 
        </apex:outputPanel> 
        
        </div> 
pls help its urgent!!!
User-added image
 
I am converting the date values to string and then using them but whn i use a '<' or '>' operator it gives an error .
so i need to reconvert date1 and sofi variables in date again so that i can use them with < and > operators.. can anyone tell me how to do it??
my code is:

<div style="margin-top:3px;margin-left:3px;z-index:1">
                                   <apex:variable var="date1" value="{!TEXT((MOD(FLOOR( (wk.startingdate-7-DATEVALUE("2007-01-01" ))/7),52))+1)}"/>
                                   <apex:variable var="sofi" value="{!TEXT((MOD(FLOOR( (t.SOFI__c-7-DATEVALUE("2007-01-01" ))/7),52))+1)}"/> 
                                   <apex:outputPanel rendered="{!IF(date1=sofi,true,false)}">
                                   <a class="{!IF(date1< sofi,'red','')}" style="hover:text-decoration:none;" href="/{!t.Id}" title="{!d}: PT System '{!t.Name}' for '{!t.Owner.Name}'" target="blank">_____</a> &nbsp;&nbsp;<font size="+1"></font>&nbsp; 
                                   </apex:outputPanel> 
                                   </div>
                                   
My selected value is stored in the variable 'val' and in the controller  i have given {get;set;} for val but val is shoing null instead of selected value from the picklist..
 <apex:selectList id="selected_list" value="{!val}" required="false" size="1">
       <apex:selectOption itemvalue="AllTime" itemLabel="AllTime"/>
          <apex:selectOption itemvalue="CurrentWeek" itemLabel="CurrentWeek"/>
          <apex:selectOption itemvalue="LastWeek" itemLabel="LastWeek"/>
       <apex:actionSupport event="onchange" action="{!viewData}" reRender="block"/>
          </apex:selectList>

Controller:

public string val{get;set;}
 public pageReference viewData(){
 getTimesheetEntries();
 return null;
 }
public List<Time_Log__c>getTimesheetEntries()
{
   system.debug('****************************Value*****************************'+val); 
    List<Time_Log__c> timesheetentries = new List<Time_Log__c>();
    
    if(val =='CurrentWeek')
    {
    system.debug('****************************+++++++++INSIDE if Current Week+++++++*****************************'); 
    timesheetentries = [select id,name,Allocation__c,Assigned_to__c,Action_Status__c,End_Date__c,Billable__c,Start_Date__c,Milestone__c,Progress_Percentage__c,Role__c,Projects__c ,Activity_Type__c,Task_If_Assigned__c,Time_Spent_Hrs__c from Time_Log__c where LastModifiedDate = THIS_WEEK];
    
    }
    if(val =='LastWeek')
    {
    system.debug('****************************+++++++++INSIDE if LAst Week+++++++*****************************'); 
    timesheetentries = [select id,name,Allocation__c,Assigned_to__c,Action_Status__c,End_Date__c,Billable__c,Start_Date__c,Milestone__c,Progress_Percentage__c,Role__c,Projects__c ,Activity_Type__c,Task_If_Assigned__c,Time_Spent_Hrs__c from Time_Log__c where LastModifiedDate = LAST_WEEK];
   
    }
    else
    { 
     system.debug('****************************+++++++++INSIDE else+++++++*****************************');    
     timesheetentries = [select id,name,Allocation__c,Assigned_to__c,Action_Status__c,End_Date__c,Billable__c,Start_Date__c,Milestone__c,Progress_Percentage__c,Role__c,Projects__c ,Activity_Type__c,Task_If_Assigned__c,Time_Spent_Hrs__c from Time_Log__c];
    }
    return timesheetentries ;
 }
 
 
i want to use apex sharing on my 'projects' object which is a custom object  i went through the document:
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_bulk_sharing_creating_with_apex.html
They have Asked to create MyCustomObject__Share
do ineed to create new Object as projects__Share or edit the existing object...can anyone tell me the steps for the __Share object creation 
I have a custom object project which will be assigned to some users.  now i have a requirement that i should be able to see  only the projects in which i am a member rest should not be visible to me..Can anyone help me as how to do it??? 
I have a requirement that the user will select some objects from a list of objects(on a vf page) he has on his org  and i want to fire same trigger on those selected objects individually. Is it possible??
Does anyone have a solution for this?
I have  a javascript on a vf page from which i want to pass value to the controller. but i am getting null in the controller.can anyone help me in this? my code:
VF page:

<apex:page controller="visitController" showHeader="false" sidebar="false" setup="true" standardStylesheets="false">
<apex:form > <style> body { padding: 20px; background-color:#ffffc9 } p { margin : 0; } </style>
<Script> function geoFindMe()
{ var output = document.getElementById("out");
if (!navigator.geolocation){
output.innerHTML = "<p>Geolocation is not supported by your browser</p>"; return;
}
function success(position)
{ var latitude = position.coords.latitude;
var longitude = position.coords.longitude;
echo(latitude,longitude );
output.innerHTML = '<p>Latitude is ' + latitude + '° <br>Longitude is ' + longitude + '°</p>'; var img = new Image();
img.src = "https://maps.googleapis.com/maps/api/staticmap?center=" + latitude + "," + longitude + "&zoom=13&size=300x300&sensor=false"; output.appendChild(img); };
function error() {
output.innerHTML = "Unable to retrieve your location"; };
output.innerHTML = "<p>Locating…</p>";
navigator.geolocation.getCurrentPosition(success, error); }
</script>
<body>
 <apex:pageBlock id="block"> Sales Visit Name: <br />
<apex:inputField value="{!visit.name}" /><br />
Sales Visit Description: <br /> <apex:inputField value="{!visit.Description__c}" /><br /> Longitude: <br /> <apex:inputField value="{!visit.Longitude__c}" id="longitude" /><br />
Latitude: <br /> <apex:inputField value="{!visit.Latitude__c}" id="latitude" /><br /> <br/> <br/>
<apex:commandButton onclick="geoFindMe()" action="{!save}" value="Show my location!" /> <div id="out"></div>
<apex:actionFunction name="echo" action="{!echoVal}" reRender="resultPanel" status="myStatus">
<apex:param name="latitude" assignTo="{!enteredText1}" value="" />
<apex:param name="longitude" assignTo="{!enteredText2}" value="" />
</apex:actionFunction> </apex:pageBlock>
</body>
</apex:form>
</apex:page>

Controller:
public class visitController { 
    public String save { get; set; }

  public String Latval ;
  public String Lonval ;
    public Sales_Visit__c visit {get;set;}
 
 public String latitude {get;set;} 
 public String longitude{get;set;} 
  
    public visitController() {
        visit = new Sales_Visit__c();
        
       
    }   
 public void echoVal() 
    { 
    //  Latval = Apexpages.currentPage().getParameters().get('latitude');
     // Lonval = Apexpages.currentPage().getParameters().get('longitude'); 
     
    //  System.debug('*********latitude echoValechoVal latitude*********'+Latval);
     //      System.debug('*********longitude echoValechoVal longitude*********'+Lonval);
    } 

    
    public PageReference save() {
     Latval = Apexpages.currentPage().getParameters().get('latitude');
   Lonval = Apexpages.currentPage().getParameters().get('longitude'); 
     
     System.debug('*********latitudelatitude*********'+Latval);
           System.debug('*********longitudelongitude*********'+Lonval);
    
        insert visit;
        
        visit = new Sales_Visit__c();
        return null;
    }
}
public class MassEmail{
public void show(){
EmailTemplate et=[select id from EmailTemplate where name ='approve loan'];
Messaging.MassEmailMessage email1=new Messaging.MassEmailMessage();
email1.setTemplateId(et.Id);
Contact c =[select id,email from Contact limit 60];
List<id>whoids=new List<id>{c.id};
email1.setTargetObjectIds(whoids);
    
Messaging.Email[] em=new Messaging.Email[]{email1};
Messaging.sendEmail(em);
}
}
This is my code.My intension is to send email to list of contacts.i am getting list of  emails from contacts.While executing the above code i was get issue like "System.QueryException: List has no rows for assignment to SObject". Can any one find what mistake i have done. 
I want to send an email alert to create a pdf of the invoice when enddate of the milestone is reached(milestone and invoice has lookup relation).
I am using professional edition so this can be done using process builder. but my process builder is not working properly..can anyone provide me with some solution for this??
Do we have Any alternate solution to do it??
I want to migrate data of communities from 1 sandbox to another.. is it possible? can anyone give me the steps to do so?
I have a requirement that when particular contacts are selected from the contacts list email should be sent to those contacts.but it is giving the above error . my code is:
vf page:
<apex:page controller="ContactSelectClassController" sidebar="false">
    <script type="text/javascript">
        function selectAllCheckboxes(obj,receivedInputID){
            var inputCheckBox = document.getElementsByTagName("input");
            for(var i=0; i<inputCheckBox.length; i++){
                if(inputCheckBox[i].id.indexOf(receivedInputID)!=-1){
                    inputCheckBox[i].checked = obj.checked;
                }
            }
        }
    </script>
    <apex:form >
        <apex:pageBlock >
            <apex:pageBlockButtons >
                <apex:commandButton value="Show Selected Accounts" action="{!processSelected}" rerender="table2"/>
            </apex:pageBlockButtons>
 
            <apex:pageblockSection title="All Contacts" collapsible="false" columns="2">
 
             <apex:pageBlockTable value="{!wrapAccountList}" var="accWrap" id="table" title="All Contacts">
                    <apex:column >
                        <apex:facet name="header">
                            <apex:inputCheckbox onclick="selectAllCheckboxes(this,'inputId')"/>
                        </apex:facet>
                        <apex:inputCheckbox value="{!accWrap.selected}" id="inputId"/>
                    </apex:column>
                    <apex:column value="{!accWrap.acc.Name}" />
                    <apex:column value="{!accWrap.acc.Email}" />
                    <apex:column value="{!accWrap.acc.Phone}" />
                </apex:pageBlockTable>
 
                <apex:pageBlockTable value="{!selectedAccounts}" var="c" id="table2" title="Selected Accounts">
                   <apex:column value="{!c.Id}" headerValue="Contact"/>
                    <apex:column value="{!c.Name}" headerValue="Contact Name"/>
                    <apex:column value="{!c.Email}" headerValue="Email"/>
                    <apex:column value="{!c.Phone}" headerValue="Phone"/>
                    
                </apex:pageBlockTable>
 
            </apex:pageblockSection>
            <apex:pageBlockButtons >
                <apex:commandButton value="Send Email" action="{!SendEmail}"/>
            </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:form>
 
</apex:page>

controller:
public class ContactSelectClassController{
 
   
    public List<wrapAccount> wrapAccountList {get; set;}
    public List<Contact> selectedAccounts{get;set;}
 
 private  List<Id> contactids=new list<Id>();
  public List<Contact> conts;
  
 

  public void SendEmail()
  {
    
      for(Integer i=0;i<5;i++)
     {
         contactids.add(selectedAccounts[i].Id);
      } 
       Messaging.MassEmailMessage mail = new Messaging.MassEmailMessage();
       mail.setTargetObjectIds(contactids);
       mail.setTemplateId('00X28000000QfNL');
// the above template id is a valid id of template i have created.
       Messaging.sendEmail(new Messaging.MassEmailMessage[] { mail });
      
 } 
 
 
 
    public ContactSelectClassController()
    {
        if(wrapAccountList == null)
         {
            wrapAccountList = new List<wrapAccount>();
            for(Contact a: [select Id, Name,Email,Phone from Contact limit 10])
             {
                wrapAccountList.add(new wrapAccount(a));
             }
         }
     }
 
    public void processSelected()
     {
    selectedAccounts = new List<Contact>();
 
        for(wrapAccount wrapAccountObj : wrapAccountList)
         {
            if(wrapAccountObj.selected == true)
             {
                selectedAccounts.add(wrapAccountObj.acc);
                
           
             }
         }
     }
 
    public class wrapAccount {
        public Contact acc {get; set;}
        public Boolean selected {get; set;}
 
        public wrapAccount(Contact a) {
            acc = a;
            selected = false;
        }
    }
}
I am converting the date values to string and then using them but whn i use a '<' or '>' operator it gives an error .
so i need to reconvert date1 and sofi variables in date again so that i can use them with < and > operators.. can anyone tell me how to do it??
my code is:

<div style="margin-top:3px;margin-left:3px;z-index:1">
                                   <apex:variable var="date1" value="{!TEXT((MOD(FLOOR( (wk.startingdate-7-DATEVALUE("2007-01-01" ))/7),52))+1)}"/>
                                   <apex:variable var="sofi" value="{!TEXT((MOD(FLOOR( (t.SOFI__c-7-DATEVALUE("2007-01-01" ))/7),52))+1)}"/> 
                                   <apex:outputPanel rendered="{!IF(date1=sofi,true,false)}">
                                   <a class="{!IF(date1< sofi,'red','')}" style="hover:text-decoration:none;" href="/{!t.Id}" title="{!d}: PT System '{!t.Name}' for '{!t.Owner.Name}'" target="blank">_____</a> &nbsp;&nbsp;<font size="+1"></font>&nbsp; 
                                   </apex:outputPanel> 
                                   </div>
                                   
My selected value is stored in the variable 'val' and in the controller  i have given {get;set;} for val but val is shoing null instead of selected value from the picklist..
 <apex:selectList id="selected_list" value="{!val}" required="false" size="1">
       <apex:selectOption itemvalue="AllTime" itemLabel="AllTime"/>
          <apex:selectOption itemvalue="CurrentWeek" itemLabel="CurrentWeek"/>
          <apex:selectOption itemvalue="LastWeek" itemLabel="LastWeek"/>
       <apex:actionSupport event="onchange" action="{!viewData}" reRender="block"/>
          </apex:selectList>

Controller:

public string val{get;set;}
 public pageReference viewData(){
 getTimesheetEntries();
 return null;
 }
public List<Time_Log__c>getTimesheetEntries()
{
   system.debug('****************************Value*****************************'+val); 
    List<Time_Log__c> timesheetentries = new List<Time_Log__c>();
    
    if(val =='CurrentWeek')
    {
    system.debug('****************************+++++++++INSIDE if Current Week+++++++*****************************'); 
    timesheetentries = [select id,name,Allocation__c,Assigned_to__c,Action_Status__c,End_Date__c,Billable__c,Start_Date__c,Milestone__c,Progress_Percentage__c,Role__c,Projects__c ,Activity_Type__c,Task_If_Assigned__c,Time_Spent_Hrs__c from Time_Log__c where LastModifiedDate = THIS_WEEK];
    
    }
    if(val =='LastWeek')
    {
    system.debug('****************************+++++++++INSIDE if LAst Week+++++++*****************************'); 
    timesheetentries = [select id,name,Allocation__c,Assigned_to__c,Action_Status__c,End_Date__c,Billable__c,Start_Date__c,Milestone__c,Progress_Percentage__c,Role__c,Projects__c ,Activity_Type__c,Task_If_Assigned__c,Time_Spent_Hrs__c from Time_Log__c where LastModifiedDate = LAST_WEEK];
   
    }
    else
    { 
     system.debug('****************************+++++++++INSIDE else+++++++*****************************');    
     timesheetentries = [select id,name,Allocation__c,Assigned_to__c,Action_Status__c,End_Date__c,Billable__c,Start_Date__c,Milestone__c,Progress_Percentage__c,Role__c,Projects__c ,Activity_Type__c,Task_If_Assigned__c,Time_Spent_Hrs__c from Time_Log__c];
    }
    return timesheetentries ;
 }
 
 
i want to use apex sharing on my 'projects' object which is a custom object  i went through the document:
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_bulk_sharing_creating_with_apex.html
They have Asked to create MyCustomObject__Share
do ineed to create new Object as projects__Share or edit the existing object...can anyone tell me the steps for the __Share object creation 
I am trying to insert new record in object and if the project name and task name already exist then it should update the record. getting error
"System.DmlException: Insert failed. First exception on row 0 with id a0O17000001aWCvEAM; first error: INVALID_FIELD_FOR_INSERT_UPDATE, cannot specify Id in an insert call: [Id]
Error is in expression '{!save}' in component <apex:commandButton> in page timesheet1: Class.TimeSheetDataController.save: line 32, column 1"
mu code is:
<apex:pageBlock id="xxxpb1" title="TimeSheet Entry">
        <apex:pageBlockSection columns="2"> 
            <apex:inputField value="{!tsObj.Start_Date__c}"/>
            <apex:inputField value="{!tsObj.End_Date__c}"/>
            <apex:inputField value="{!tsObj.Projects__c}"/>
            <apex:inputField value="{!tsObj.Tasks__c}"/>   
            <apex:inputField value="{!tsObj.Log_Hours__c}"/>
            <apex:inputField value="{!tsObj.Important_Notes__c}"/>
        </apex:pageBlockSection>
       
        <apex:pageBlockButtons >
            <apex:commandButton value="Save" action="{!save}" reRender="block"/>
            <apex:commandButton value="Cancel" action="{!cancel}" reRender="block"/>

        </apex:pageBlockButtons>
    </apex:pageBlock>
 public PageReference save()
 {  PageReference page = new PageReference('/apex/Timesheet1');
  List<Timesheet__c> timesheetentries1 = new List<Timesheet__c>();
   
    timesheetentries1 = [select name,id,Important_Notes__c,Start_Date__c,End_Date__c,Projects__c,Owner.Name,Tasks__c,Log_Hours__c from Timesheet__c];
     
     for(Timesheet__c ts:timesheetentries1)
    {
       if(ts.Projects__c==tsObj.Projects__c && ts.Tasks__c==tsObj.Tasks__c )
        {
         d=tsObj.Log_Hours__c;
         tsObj1=[select id,name,Important_Notes__c,Start_Date__c,End_Date__c,Projects__c,Owner.Name,Tasks__c,Log_Hours__c from Timesheet__c where Projects__c =: tsObj.Projects__c and Tasks__c=:tsObj.Tasks__c];
         tsObj1.Log_Hours__c= tsObj1.Log_Hours__c+tsObj.Log_Hours__c;
         update tsObj1;
         page.setRedirect(true);
       }
      
      else{
        insert tsObj;
        page.setRedirect(true);}
        }
       return page;
 
 }
i have a date picker for fromdate and todate and want to display a weekly view for it  when search button is clicked. can anyone help me to do the same..i am attaching the pic as how should it look like:
this is how it should look after the search button is clicked