• shobana shobana
  • NEWBIE
  • 85 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 15
    Questions
  • 23
    Replies
Hi all ,

          I have a requirement that i need to display all Account on Google maps using Single Visualforce page to track All Account from Current Location,can any one help me out to solve this issue.....

Below code  will show the location of particular records of Acccounts but i want to show all Account location in single visualforce page
<apex:page standardController="Account">

<head>

<script type="text/javascript" src="https://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script type="text/javascript">

$(document).ready(function() {

  var myOptions = {
    zoom: 15,
    mapTypeId: google.maps.MapTypeId.ROADMAP,
    mapTypeControl: false
  }

  var map;
  var marker;

  var geocoder = new google.maps.Geocoder();
  var address = "{!Account.BillingStreet}, " + "{!Account.BillingCity}, " + "{!Account.BillingPostalCode}, " + "{!Account.BillingCountry}";

  var infowindow = new google.maps.InfoWindow({
    content: "<b>{!Account.Name}</b><br>{!Account.BillingStreet}<br>{!Account.BillingCity}, {!Account.BillingPostalCode}<br>{!Account.BillingCountry}"
  });

  geocoder.geocode( { address: address}, function(results, status) {
    if (status == google.maps.GeocoderStatus.OK && results.length) {
      if (status != google.maps.GeocoderStatus.ZERO_RESULTS) {

        //create map
        map = new google.maps.Map(document.getElementById("map"), myOptions);

        //center map
        map.setCenter(results[0].geometry.location);

        //create marker
        marker = new google.maps.Marker({
            position: results[0].geometry.location,
            map: map,
            title: "{!Account.Name}"
        });

        //add listeners
        google.maps.event.addListener(marker, 'click', function() {
          infowindow.open(map,marker);
        });
        google.maps.event.addListener(infowindow, 'closeclick', function() {
          map.setCenter(marker.getPosition());
        });

      }

    } else {
      $('#map').css({'height' : '15px'});
      $('#map').html("Oops! {!Account.Name}'s billing address could not be found, please make sure the address is correct.");
      resizeIframe();
    }
  });

  function resizeIframe() {
    var me = window.name;
    if (me) {
      var iframes = parent.document.getElementsByName(me);
      if (iframes && iframes.length == 1) {
        height = document.body.offsetHeight;
        iframes[0].style.height = height + "px";
      }
    }
  }

});
</script>

<style>
#map {
  font-family: Arial;
  font-size:12px;
  line-height:normal !important;
  height:250px;
  background:transparent;
}
</style>

</head>

<body>
<div id="map"></div>
</body>
</apex:page>

Thank you in advance......

I'm trying to integrate a google maps using visualforce but without success,when i run the page it appears all blank,someone could help me with that?
 
<apex:page standardController="Account">
<apex:pageBlock >
<head>
 
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> 
<script type="text/javascript"> 
 
$(document).ready(function() {
  
  var myOptions = {
    zoom: 20,
    mapTypeId: google.maps.MapTypeId.HYBRID,
    mapTypeControl: true
  }
  
  var map;
  var marker;
  
  var geocoder = new google.maps.Geocoder();
  var address = "{!Account.Project_Street_Address__c}";
  var infowindow = new google.maps.InfoWindow({
    content: "<b>{!Account.Name}</b>"
  });
 
  geocoder.geocode( { address: address}, function(results, status) {
    if (status == google.maps.GeocoderStatus.OK && results.length) {
      if (status != google.maps.GeocoderStatus.ZERO_RESULTS) {
      
        //create map
        map = new google.maps.Map(document.getElementById("map"), myOptions);
      
        //center map
        map.setCenter(results[0].geometry.location);
        
        //create marker
        marker = new google.maps.Marker({
            position: results[0].geometry.location,
            map: map,
            title: "{!Account.Name}"
        });
        
        //add listeners
        google.maps.event.addListener(marker, 'click', function() {
          infowindow.open(map,marker);
        });
        google.maps.event.addListener(infowindow, 'closeclick', function() {
          map.setCenter(marker.getPosition()); 
        });
        
      }
      
    } else {
      $('#map').css({'height' : '15px'});
      $('#map').html("Oops! {!Account.Name}'s address could not be found, please make sure the address is correct.");
      resizeIframe();
    }
  });
  
  function resizeIframe() {
    var me = window.name;
    if (me) {
      var iframes = parent.document.getElementsByName(me);
      if (iframes && iframes.length == 1) {
        height = document.body.offsetHeight;
        iframes[0].style.height = height + "px";
      }
    }
  }
  
});
</script>
 
<style>
#map {
  font-family: Arial;
  font-size:12px;
  line-height:normal !important;
  height:500px;
  background:transparent;
}
</style>
 
</head>
 
<body>
<div id="map"></div> 
</body> 
</apex:pageBlock>
</apex:page>
Thank you in advance...
 
Hi everyone
For Lead object i want to put a Visualforce page as a section in it. However, the height of the content varies, and when I drop the section in, there is a large white space if the content does not fill. How do I deal with this.

Can anyone help me out to solve this issue.....

User-added image
Thank you in advance...
Hello everyone
I am new to salesforce
Actually i wrote a test class it showing me error can anyone help to solve this problem.
Apex class

public with sharing class UpdateMileStone{

    //public Mile_Stone__c mStone {get; set;}
    public Case__c project;
    public List<MSList> newMSList{get; set;}

    public UpdateMileStone(ApexPages.StandardController stdController){
        project = (Case__c)stdController.getRecord();
        
        project = [Select Id, (Select Id, Name, Date_Received__c, Description__c, Date_Required_By__c From Required_Documents__r)
                from Case__c  where Id =:project.Id];
              
        newMSList = new List<MSList>(); 

        for(Required_Documents__c m: project.Required_Documents__r){
            MSList msListTemp = new MSList();             
            msListTemp.mStone= m;
                newMSList.add(msListTemp);            
        }                                 
    }
    //Updating Milestone    
    public PageReference updateDocumentRecords(){
        List<Required_Documents__c> MSUpdateList = new List<Required_Documents__c>();
        for(MSList mTemp: newMSList){
            if(mTemp.selectMS){
              MSUpdateList.add(mTemp.mStone);
            }
        }
        if(MSUpdateList.size()>0){
          update MSUpdateList;
        }else{
          ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING,'Please select one/multiple Required Documents to update!'));
          return null;
        }
        return new PageReference('/'+project.Id);
    }
    
       
    // Inner Class to create Payment Schedule with Checkbox   
    public class MSList{
        public Boolean selectMS {get; set;}
        public Required_Documents__c mStone {get; set;}
        
        public MSList(){
            selectMS=false;
        }
    }

Test class

  @IsTest 
  Public class updatemilestone{
    static testMethod void testUpdateMileStone(){

       Test.startTest();
        User usr = new User(Id=UserInfo.getUserId());
        System.runAs(usr){
        
            Case__c p1=new Case__c(Name='test1');
            insert p1;
            
            Required_Documents__c m1=new Required_Documents__c(Name='test2');
            m1.Date_Received__c = System.today();
            insert m1;
            
            ApexPages.StandardController stdcontroller = new ApexPages.Standardcontroller(p1);
           UpdateMileStone ums = new UpdateMileStone(stdcontroller);
           
            ums.updateMileStoneRecords();
           Required_Documents__c k=new Required_Documents__c();
                k.selectMS= true;
               
            }
           
            ums.updateDocumentRecords(); 
            
            }
       Test.stopTest();
     
    }

Thank you in advance
 
Hi everyone,
   
I need to upload new attachment to opportunity,
If I click on New Attachment button( first Visualforce page ) , it redirects to other Visualforce and provision to choose file and click upload, then the attachment appears in first Visualforce page.
I  am not getting any error but functionality is not working..
Actually when i am clicking on Choosefile button on second visualforce page we can choose a file but the thing is while am clicking the upload button i want to show the chosen file in first visualforce.

 
How do I do that?

I wrote some code below, and I attached screenshots below.
 First visualfore page:
User-added image
My Second visualforce page:
User-added image
my visualfore page-1
<apex:page standardController="opportunity" extensions="FileUploadController">
  <apex:form >
        <apex:pageblock >
            <apex:pageBlockSection title="Attachments" columns="1">
            <apex:CommandButton value="New Attachment" action="{!attach_new}"/>
            </apex:pageBlockSection>
        </apex:pageblock>
    </apex:form> 
</apex:page>


Visualforce page-2


<apex:page standardController="Opportunity" extensions="FileUploadController" showHeader="true">
<apex:pageBlock id="Pid">
    <apex:pageBlockSection title="Select a file to be uploaded" collapsible="false"/>
</apex:pageBlock>
    <apex:outputPanel id="panel_Upload">
    <apex:form id="form_Upload">
        <apex:inputFile id="file_File" value="{!fileBody}" filename="{!fileName}"/>
        <apex:actionRegion >
            <apex:commandButton id="button_Upload" value="Upload" action="{!processUpload}"/>
        </apex:actionRegion>
        <apex:CommandButton value="Cancel" action="{!Cancel}"/>
    </apex:form>
    </apex:outputPanel>
    <apex:pageBlock id="BId">
        <apex:pageBlockSection >
            <apex:dataTable Value="{!la}" var="l">
                <apex:column value="{!l.Name}"/>
            </apex:dataTable>
        </apex:pageBlockSection>
    </apex:pageBlock>
    
</apex:page>


My controller:

public class FileUploadController {
Public Opportunity opp{get; set;}
    private String fileName;
    private Integer fileSize; 
    private Blob fileBody; 
    public FileUploadController(ApexPages.StandardController controller) { } 
    public String getFileName() {
         return this.fileName; 
    } 
    
    public void setFileName(String fileName) { 
        this.fileName = fileName; 
    } 
    public Blob getFileBody() {
        return this.fileBody; 
    }
    
    public void setFileBody(Blob fileBody) {
        this.fileBody = fileBody; 
        setFileSize(this.fileBody.size()); 
    } 
    
    public Integer getFileSize() { 
        return this.fileSize;
    } 
    
    public void setFileSize(Integer fileSize) { 
        this.fileSize = fileSize; 
    } 
    
    List<Attachment> la{get;set;}
    
    Public List<Attachment> getLa(){
        return la;
    }
    
    private Database.SaveResult insertCustomObject() { 
        Opportunity custObj = new Opportunity(); 
        custObj.Name= 'Ranjith';
        insert la;
        return Database.insert(custObj); 
    }
    private Database.SaveResult insertAttachment(Id parentId) {
        Database.SaveResult result; 
        Attachment attachment = new Attachment(); 
        attachment.Body = this.fileBody; 
        attachment.Name = this.fileName; 
        attachment.ParentId = parentId; 
        result = Database.insert(attachment); 
        fileBody = Blob.valueOf(' '); 
        return result; 
    } 
    
    public Void processUpload() {
        try { 
            Database.SaveResult result = insertCustomObject();
            result = insertAttachment(result.getId());  
           } catch (Exception e) {
                ApexPages.AddMessages(e);
           } 
   }
    public pagereference attach_new(){
                pagereference pag = new pagereference('/apex/NewAttachments');
                return pag;
    } 
}
Anyone help me out solve this scenario.
Thank you in advance...
 
Hi everyone
I wrote a test class for custom case object.It showing the error
" Invalid bind expression type of Schema.SObjectField for column of type Id".
My Apex class:
public class OpenEventsforPotentials {

public List<OpenActivity> open{get;set;}

    public Boolean refreshPage {get; set;}

    public List<Event> accs { get; set;}

    public Id Potentialld{get;set;}
    public Id Accountid{get;set;}

    public string SelectedEventId { get; set;}

    public OpenEventsforPotentials (ApexPages.StandardController controller) {

        Potentialld= ApexPages.CurrentPage().getparameters().get('id');
        list<Account> Accountid=[select id from Account]; 
        list<Opportunity>   c =[SELECT Name,

                                (Select Id,Subject,IsTask, WhoId, ActivityDate,Status, Priority, OwnerId FROM OpenActivities WHERE IsTask=False)

                           FROM Opportunity WHERE Id = :Potentialld];

        if(c.size() > 0){

            open = c[0].OpenActivities;

        }

     

    }

       

   

    public pageReference DeleteEvent(){

     

        // if for any reason we are missing the reference

        if (SelectedEventId != null) {

            Event tobeDeleted = [SELECT Id FROM Event WHERE Id =:SelectedEventId];

            if(tobeDeleted != null){

                delete tobeDeleted;

            }

             

            for(Integer i=0;i < open.size();i++){

                if(open[i].Id == SelectedEventId){

                    open.remove(i);

                    i--;

                }

            }

        }

         

        return null;

    }

    public Pagereference refresh(){

        PageReference secondPage = new PageReference('https://ap1.salesforce.com/{!Leadld}');

       secondPage.getParameters().put('id',Potentialld);

       secondPage.setRedirect(true);

         

        return secondPage;

     

    }   

}
Test class:
@isTest
public class  Testclassforcases{

    static TestMethod void testforcases(){

       User usr = [SELECT Id From User WHERE Id =:UserInfo.getUserID()];

        System.runAs(usr){
           Account A1=[select id from account
                       where id = : case__c.Account_Name__c];
           case__c case1=new case__c(OwnerId=usr.Id,CurrencyIsoCode = 'INR',Name=A1.Id
                                     );

            Insert case1;
           

             

           
            
            Event event1=new Event(OwnerId=usr.Id,Subject='cc',DurationInMinutes=60,ActivityDateTime=Datetime.newInstance(2015,25,2,00,00,00),
                                 EndDateTime=Datetime.newInstance(2015,25,2,01,00,00),StartDateTime=DateTime.newInstance(2015,25,2,00,00,00));
            
            Insert event1;
        

            ApexPages.StandardController stdcontroller = new ApexPages.Standardcontroller(case1);

            ApexPages.CurrentPage().getparameters().put('id',case1.Id);
            OpenEventsforCases eve=new OpenEventsforCases(stdcontroller);
            eve.DeleteEvent();
           // eve.refresh();
            OpenTasksforCases eve1= new OpenTasksforCases( stdcontroller);
            eve1.listwrapper[0].checked = true;
            eve1.close();

         

        }

    } 
}
Can anyone help me out to solve this problem.
Thank you in advance.....
 
Hi everyone
My scenario is to show the open task of lead object as a seperate related list instead of using open activity.
For that i took viusalforce and extension controller.
It works good actually.
when clicking  the close button and check box the particular record will get closed but the thing is 
its not showing in Activity History immediatly after refreshing the page only its shows that particular record in Activity History.
can anyone help me out to solve thing problem..
public class OpenTasks {

    public List<OpenActivity> open{get;set;}

    public Id leadLd{get;set;}
   
    public list<wrapperclass> listwrapper{get;set;}
    

    public OpenTasks(ApexPages.StandardController controller){

        leadLd = ApexPages.CurrentPage().getparameters().get('id');
        list<task> open1 =new list<Task>();

        listwrapper = new list<wrapperclass>();
         


        list<lead>   le =[SELECT Name, (Select Id,Subject, WhoId, ActivityDate,Status, Priority, OwnerId FROM Tasks WHERE IsClosed=false)

                            FROM Lead WHERE Id = :leadld];

        if(!le.isEmpty()){
            
            for(Task k: le[0].Tasks)

            {

               listwrapper.add(new Wrapperclass(k));
               
            }

        }

    }

     

    public class wrapperclass

    {
        public  boolean checked{get;set;}

        public Task k{get;set;}

        public Wrapperclass(Task k){

            this.k=k;

        }

    }

  public PageReference close()

    {  

        list<Task> listofopen=new list<Task>();

        if(!listwrapper.isEmpty()){

            for(Integer i=0; i<listwrapper.size();i++)

            {
                wrapperclass w = listwrapper[i];
           
                if(w.checked==true){
                    system.debug(w);
                    w.k.status='completed';
                    listofopen.add(w.k);
                    listwrapper.remove(i);
                    i--;
   
                                }
             
            }

        }

        if(listofopen.isEmpty())

        {

            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR,'Select atleast one column '));

        }

        else{

           update listofopen;   

        }
       
    
  
      return null;

    }  

 }

visualforce

<apex:page standardController="Lead" extensions="OpenTasks"  >

    <apex:form >

        <apex:pageBlock title="Open Tasks" mode="edit" id="opnTsks">

            <apex:Messages />        

            <center><a href="https://cs18.salesforce.com/00T/e?who_id={!leadld}&retURL={!leadld}" target="_top"><button type="button">New Task</button></a>

                <apex:commandButton value="close" action="{!close}" rerender="opnTsks" />

            </center>&nbsp;&nbsp;

            <apex:pageBlockTable value="{!listwrapper}" var="each" >

                <apex:column headerValue="Action">

                     <apex:inputCheckbox value="{!each.checked}"/>

                    &nbsp;|&nbsp;

                    <apex:outputlink value="/{!each.k.id}/e?retURL={!each.k.WhoId}" target="_top"> Edit </apex:outputlink>

                   </apex:column>

                <apex:column headerValue="Subject" value="{!each.k.Subject}"/>

                <apex:column headerValue="ActiveDate" value="{!each.k.ActivityDate}"/>

                <apex:column headerValue="Status" value="{!each.k.Status}"/>

            </apex:pageBlockTable>

        </apex:pageBlock>

     </apex:form>

</apex:page>
Thank you in advance...
 
Hi Everyone
My scenario is to show the open task and events of lead object as separate list in pagelayout instead of using  openactivity.
I got an output for this.I want to add my visualforce page in lead layout.
for that i took one section and i kept my visualforce in that section.
But it shows my visualforce page in half page i want to increase the width in pagelayout already it is 100% and  i  also don't want to see the standerd buttons in that section.
can anyone help to out to solve this problem..



Thank you in advance.
Hi everyone,
I am new bie to Salesforce.
This is my first  Test class.
I tried but somewhere i did mistake.
anyone give me guidelines to solve this.
 
My class


public class opentasks {

    public List<OpenActivity> open{get;set;}

    public Id leadld{get;set;}
   
    public list<wrapperclass> listwrapper{get;set;}
    

    public opentasks(ApexPages.StandardController controller){

        leadld = ApexPages.CurrentPage().getparameters().get('id');
        list<task> open1 =new list<Task>();

        listwrapper = new list<wrapperclass>();
         


        list<lead>   le =[SELECT Name, (Select Id,Subject, WhoId, ActivityDate,Status, Priority, OwnerId FROM Tasks WHERE IsClosed=false)

                            FROM Lead WHERE Id = :leadld];

        if(!le.isEmpty()){
            
            for(Task k: le[0].Tasks)

            {

               listwrapper.add(new Wrapperclass(k));
               
            }

        }

    }

     

    public class wrapperclass

    {
        public  boolean checked{get;set;}

        public Task k{get;set;}

        public Wrapperclass(Task k){

            this.k=k;

        }

    }

  public PageReference close()

    {  

        list<Task> listofopen=new list<Task>();

        if(!listwrapper.isEmpty()){

            for(Integer i=0; i<listwrapper.size();i++)

            {
                wrapperclass w = listwrapper[i];
           
                if(w.checked==true){
                    system.debug(w);
                    w.k.status='completed';
                    listofopen.add(w.k);
                    listwrapper.remove(i);
                    i--;
   
                                }
             
            }

        }

        if(listofopen.isEmpty())

        {

            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR,'Select atleast one column '));

        }

        else{

           update listofopen;   

        }
       

My test class:

public class c{
static TestMethod void testforlead()
{ 
Test.StartTest();
User user =new User(Id=UserInfo.getUserID());

System.runAs(usr){
Lead l1=new Lead();
l1.Text(80)='shobana';
l1.Company='rix';
l1.Status='Working-contacted';
Insert l1;

Task t1=new Task();
t1.Owner='shoba shoba';
t1.Subject='cc';
t1.Priority='High';
t1.Status='In progress';
t1.Whoid=l1.Id;
Insert t1;
 ApexPages.StandardController stdcontroller = new ApexPages.Standardcontroller(l1);
 opentasks cls= new opentasks( stdcontroller);
 cls.close();
 for(wrapperclass w:cls.listwrapper)

            {
              
 w.Checked=true;
break;
 } 

cls.close();
}
Test.stopTest();
 
 }
 
}
Thank you in advance.

 
Hi Everyone
 My scenario is to show the related events record of lead object  in pagelayout.
 For that i took visualforce page and extension controller.
Actually i am getting output but for delete action will get works when i refresh the page .
public class forevents {
public List<OpenActivity> open{get;set;}
    public Boolean refreshPage {get; set;}
    public List<Event> accs { get; set;}
    public Id leadld{get;set;}
    public string SelectedEventId { get; set;}
    public forevents(ApexPages.StandardController controller) {
       leadld = ApexPages.CurrentPage().getparameters().get('id');
        list<lead>   c =[SELECT Name, 
                                  (Select Id,Subject,IsTask, WhoId, ActivityDate,
                                    Status, Priority, OwnerId FROM OpenActivities WHERE IsTask=False) 
                            FROM Lead WHERE Id = :leadld];
        if(c.size() > 0){
            open = c[0].OpenActivities;
        }
        
        }
      
  
     public void DeleteEvent()
   {
   
   
      // if for any reason we are missing the reference 
      if (SelectedEventId == null) {
      
         return ;
         
      }

     
      // find the event record within the collection
     Event tobeDeleted = null;
     accs = [Select id, Whoid,description,subject,activitydate
               from event
               where Whoid=: leadld ]; 
      for(Event a : accs)
       if (a.Id == SelectedEventId) {
          tobeDeleted = a;
          break;
       }
      
      //if event record found delete it
      if (tobeDeleted != null) {
       Delete tobeDeleted;
      }
     
     
   }
  public Pagereference refresh()
  {
  PageReference secondPage = new PageReference('https://ap1.salesforce.com/{!Leadld}');
  secondPage.getParameters().put('id',Leadld); 
        secondPage.setRedirect(true);
         
        return secondPage; 
  
  }    
}


<apex:page standardController="Lead" extensions="forevents" >
<apex:form >
        <apex:pageBlock title="Open Events"  >          
<center><a href="https://ap1.salesforce.com/00U/e?who_id={!leadld}&retURL={!leadld}" target="_top"><button type="button">New Event</button></a>
</center>&nbsp;&nbsp;

                <apex:pageBlockTable value="{!open}" var="each"   ><br/>
                
                    <apex:column headerValue="Action">
                        <apex:outputlink value="/{!each.id}/e?retURL={!each.WhoId}" target="_top" style="font-weight:bold"> Edit </apex:outputlink>&nbsp;|&nbsp;
                       <a href="javascript:if (window.confirm('Are you sure?')) DeleteEvent('{!each.Id}');" style="font-weight:bold">Del</a>
                    </apex:column>
                    <apex:column headerValue="Subject" value="{!each.Subject}"/>
                    <apex:column headerValue="ActiveDate" value="{!each.ActivityDate}"/>
                    <apex:column headerValue="Status" value="{!each.Status}"/>
                </apex:pageBlockTable>
         </apex:pageBlock>
             <apex:actionFunction action="{!DeleteEvent}" name="DeleteEvent" reRender="form" >
                        <apex:param name="eventid" value="" assignTo="{!SelectedEventId}"/>
                    </apex:actionFunction>
                  
 </apex:form>
</apex:page>
Anyone help me out...
Thank you in advance.
Hi  everyone
This is my first wrapper class.
I would like to show open task as seperate section on my lead page layout.
For that i took a standard controller with extension.In this scenario i have finished upto 3steps and I got output also.
Step 1; showing  task record related to lead object.
Step 2:i have created new task button.
Step 3: i have show edit option for each records of task.

My 3rd and 4th step is to add a checkbox and close button for that section.whenever am clicking  checkbox and close botton i want to show that particular record in activity history.
for this concept i took wrapper class concept but its showing error " opentasks Compile Error: Variable does not exist: status
my controller page

public class opentasks {
public List<OpenActivity> open{get;set;}
    public Id leadld{get;set;}
    Public boolean allbool{get;set;}
    public list<wrapperclass> listwrapper{get;set;}
    public list<lead> c{get;set;}
    public opentasks(ApexPages.StandardController controller) {
        leadld = ApexPages.CurrentPage().getparameters().get('id');
         c =[SELECT Name, 
                                  (Select Id,Subject,IsTask, WhoId, ActivityDate,
                                    Status, Priority, OwnerId FROM OpenActivities WHERE IsTask=True) 
                            FROM Lead WHERE Id = :leadld];
                         
        if(c.size() > 0){
            open = c[0].OpenActivities;
        }
        
        }
    public opentasks(){
   list<openactivity> open1 =new list<openactivity>(); 
  list<lead>   le =[SELECT Name, 
                                  (Select Id,Subject,IsTask, WhoId, ActivityDate,
                                    Status, Priority, OwnerId FROM OpenActivities WHERE IsTask=True) 
                            FROM Lead WHERE Id = :leadld];
                         
        if(c.size() > 0){
            open1 = c[0].OpenActivities;
        }
    for(Openactivity k:open1)
    {
   
    listwrapper.add(new Wrapperclass(k));
    }
    }
    
    
    
    public class wrapperclass
    {
    public  boolean checked{get;set;}
    public Openactivity k{get;set;}
    public Wrapperclass(openactivity k)
    {
    this.k=k;
    }
    }
    public void close()
    {   
    list<openactivity> listofopen=new list<openactivity>();
    list<wrapperclass> listofwrapper=new list<wrapperclass>();
    for(wrapperclass w:listwrapper)
    {
   if(w.checked==true)
   {
   system.debug(w);
   w.status='completed';   HERE  AM GETTING ERROR
   listofopen.add(w.k);
   
   }
   
   
    else
    {
    listofwrapper.add(w);
    }
    }
    if(listofopen.size()==0)
    {
     ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR,'Select atleast one column t'));
    }}   
 }

can anyone help me out


Thank you in advance


 

hi everyone
My scenario is to while clicking the checkbox and close button i want to close the list of record of open task in lead object and it  should  be  store  in Activity history related list.
can anyone give me  guidence to solve this scenario.
I have wrote code for geting
1.New Task button
2.Related task record of lead object.
3.Edit operation for exiting task record of lead object.
I have got output for above 3 steps.
 my 4th step is while clicking the checkbox  and close button i want to close the list of record of open task in lead object and it  should  be  store  in Activity history related list.
 

public class k {
public List<OpenActivity> open{get;set;}
    public Id leadld{get;set;}
    public list<lead> c{get;set;}
    public k(ApexPages.StandardController controller) {
        leadld = ApexPages.CurrentPage().getparameters().get('id');
         c =[SELECT Name, 
                                  (Select Id,Subject,IsTask, WhoId, ActivityDate,
                                    Status, Priority, OwnerId FROM OpenActivities WHERE IsTask=True) 
                            FROM Lead WHERE Id = :leadld];
        if(c.size() > 0){
            open = c[0].OpenActivities;
        }
        
        }
    
                             
        
     
    
    
}

visualforce page:
<apex:page standardController="Lead" extensions="k" >
    <apex:form >
        <apex:pageBlock >
            


<center><a href="https://ap1.salesforce.com/00T/e?who_id={!leadld}&retURL={!leadld}" target="_top"><button type="button">New Task</button></a>
</center>

                <apex:pageBlockTable value="{!open}" var="each"   >
                <apex:column headerValue="Action">
                <apex:outputlink value="/{!each.id}/e?retURL={!each.WhoId}" target="_top"> Edit </apex:outputlink>
                   </apex:column>
                <apex:column headerValue="Subject" value="{!each.Subject}"/>
                <apex:column headerValue="ActiveDate" value="{!each.ActivityDate}"/>
                <apex:column headerValue="Status" value="{!each.Status}"/>
                </apex:pageBlockTable>
            </apex:pageBlock>
     </apex:form> 
</apex:page>
Hi everyone

I am going to display the Open Tasks for Leads.
I am able to do that, but I would like to show the New Task button(need Standard New Task Functionality), For this, I am doing url hacking, but some how I am missing something.

I am pasting my code below, 

The Intention is to show the Open Tasks, and New Task Button in Visualforce page. Later I will add this VFP to Lead Page layout, so that I can show Open Tasks to particular Lead.

Can any one please help me out?

public class MyOpenTasks {
public List<OpenActivity> open{get;set;}
    public Id leadld;
    public list<lead> c{get;set;}
    public MyOpenTasks (ApexPages.StandardController controller) {
        leadld = ApexPages.CurrentPage().getparameters().get('id');
         c =[SELECT Name, 
                                  (Select Id,Subject,IsTask, WhoId, ActivityDate,
                                    Status, Priority, OwnerId FROM OpenActivities WHERE IsTask=True) 
                            FROM Lead WHERE Id = :leadld];
        if(c.size() > 0){
            open = c[0].OpenActivities;
        }
        
        }
        // method for command button
    public Pagereference myTasks(){
    PageReference pageRef = new PageReference(' /00T/e?who_id={!ld.Id}&retURL={!ld.Id}');
    pageRef.setRedirect(True);
    return PageRef;
    } 
    
}
Visualforce Page

<apex:page standardController="Lead" extensions="MyOpenTasks " >
    <apex:form >
        <apex:pageBlock >
            <apex:pageBlockButtons location="top">
                <apex:commandButton value="new task" action="{!myTasks}"/>
            </apex:pageBlockButtons>


                <apex:pageBlockTable value="{!open}" var="each"   >
                <apex:column headerValue="Action">
                <apex:outputlink value="/{!each.id}/e?retURL={!each.WhoId}" target="_top"> Edit </apex:outputlink>
                   </apex:column>
                <apex:column headerValue="Subject" value="{!each.Subject}"/>
                <apex:column headerValue="ActiveDate" value="{!each.ActivityDate}"/>
                <apex:column headerValue="Status" value="{!each.Status}"/>
                </apex:pageBlockTable>
            </apex:pageBlock>
     </apex:form> 
</apex:page>
Thanks in Advance.....
Shobhana
 
Hi every one 
I am new bie to Salesforce.
My scenario is to display the New task button in visualforce.when am clicking the button in visualforce i want to create a task for particular object.
can anyone give me tips to display  task button in visualforce.
I have tried to do that by using url of task button but its not working.


Thank  you in advance.
 
Hi everyone,

I am new bie to Salesforce.
This is my first controller  and visualforce page.

This is my scenario....
I would like to show open task as seperate section on my lead page layout.
For that i took a standard controller with extension but its not showing the records but am not getting any error .Actually when i put that query in query editor its showing task  record of lead .
public class te {
    public List<OpenActivity> open{get;set;}
    public Lead ld;
    public te(ApexPages.StandardController controller) {
    
     ld=(Lead)controller.getrecord();
   
    }
public List<OpenActivity> getopen()
        {
               
            SObject[] c =[SELECT Name, 
                 (Select Id,Subject,IsTask, WhoId, WhatId,  ActivityDate,
                  Status, Priority, OwnerId FROM OpenActivities
                  where IsTask=True  
                  ) 
                  From Lead];
                      
  
        return  open;       
        } 

}


Visualforce page

<apex:page standardController="Lead" extensions="te">
<apex:pageBlock >
<apex:dataTable value="{!open}" var="each"  styleclass="list" >
<apex:column headerValue="Subject">{!each.Subject}</apex:column>
<apex:column headerValue="Name">{!each.WhoId}</apex:column>
<apex:column headerValue="Status">{!each.Status}</apex:column>
</apex:dataTable>
</apex:pageBlock>
</apex:page>
Can anyone please help me out.
Thank you in advance.

I'm trying to integrate a google maps using visualforce but without success,when i run the page it appears all blank,someone could help me with that?
 
<apex:page standardController="Account">
<apex:pageBlock >
<head>
 
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> 
<script type="text/javascript"> 
 
$(document).ready(function() {
  
  var myOptions = {
    zoom: 20,
    mapTypeId: google.maps.MapTypeId.HYBRID,
    mapTypeControl: true
  }
  
  var map;
  var marker;
  
  var geocoder = new google.maps.Geocoder();
  var address = "{!Account.Project_Street_Address__c}";
  var infowindow = new google.maps.InfoWindow({
    content: "<b>{!Account.Name}</b>"
  });
 
  geocoder.geocode( { address: address}, function(results, status) {
    if (status == google.maps.GeocoderStatus.OK && results.length) {
      if (status != google.maps.GeocoderStatus.ZERO_RESULTS) {
      
        //create map
        map = new google.maps.Map(document.getElementById("map"), myOptions);
      
        //center map
        map.setCenter(results[0].geometry.location);
        
        //create marker
        marker = new google.maps.Marker({
            position: results[0].geometry.location,
            map: map,
            title: "{!Account.Name}"
        });
        
        //add listeners
        google.maps.event.addListener(marker, 'click', function() {
          infowindow.open(map,marker);
        });
        google.maps.event.addListener(infowindow, 'closeclick', function() {
          map.setCenter(marker.getPosition()); 
        });
        
      }
      
    } else {
      $('#map').css({'height' : '15px'});
      $('#map').html("Oops! {!Account.Name}'s address could not be found, please make sure the address is correct.");
      resizeIframe();
    }
  });
  
  function resizeIframe() {
    var me = window.name;
    if (me) {
      var iframes = parent.document.getElementsByName(me);
      if (iframes && iframes.length == 1) {
        height = document.body.offsetHeight;
        iframes[0].style.height = height + "px";
      }
    }
  }
  
});
</script>
 
<style>
#map {
  font-family: Arial;
  font-size:12px;
  line-height:normal !important;
  height:500px;
  background:transparent;
}
</style>
 
</head>
 
<body>
<div id="map"></div> 
</body> 
</apex:pageBlock>
</apex:page>
Thank you in advance...
 
Hi everyone
For Lead object i want to put a Visualforce page as a section in it. However, the height of the content varies, and when I drop the section in, there is a large white space if the content does not fill. How do I deal with this.

Can anyone help me out to solve this issue.....

User-added image
Thank you in advance...
Hello everyone
I am new to salesforce
Actually i wrote a test class it showing me error can anyone help to solve this problem.
Apex class

public with sharing class UpdateMileStone{

    //public Mile_Stone__c mStone {get; set;}
    public Case__c project;
    public List<MSList> newMSList{get; set;}

    public UpdateMileStone(ApexPages.StandardController stdController){
        project = (Case__c)stdController.getRecord();
        
        project = [Select Id, (Select Id, Name, Date_Received__c, Description__c, Date_Required_By__c From Required_Documents__r)
                from Case__c  where Id =:project.Id];
              
        newMSList = new List<MSList>(); 

        for(Required_Documents__c m: project.Required_Documents__r){
            MSList msListTemp = new MSList();             
            msListTemp.mStone= m;
                newMSList.add(msListTemp);            
        }                                 
    }
    //Updating Milestone    
    public PageReference updateDocumentRecords(){
        List<Required_Documents__c> MSUpdateList = new List<Required_Documents__c>();
        for(MSList mTemp: newMSList){
            if(mTemp.selectMS){
              MSUpdateList.add(mTemp.mStone);
            }
        }
        if(MSUpdateList.size()>0){
          update MSUpdateList;
        }else{
          ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING,'Please select one/multiple Required Documents to update!'));
          return null;
        }
        return new PageReference('/'+project.Id);
    }
    
       
    // Inner Class to create Payment Schedule with Checkbox   
    public class MSList{
        public Boolean selectMS {get; set;}
        public Required_Documents__c mStone {get; set;}
        
        public MSList(){
            selectMS=false;
        }
    }

Test class

  @IsTest 
  Public class updatemilestone{
    static testMethod void testUpdateMileStone(){

       Test.startTest();
        User usr = new User(Id=UserInfo.getUserId());
        System.runAs(usr){
        
            Case__c p1=new Case__c(Name='test1');
            insert p1;
            
            Required_Documents__c m1=new Required_Documents__c(Name='test2');
            m1.Date_Received__c = System.today();
            insert m1;
            
            ApexPages.StandardController stdcontroller = new ApexPages.Standardcontroller(p1);
           UpdateMileStone ums = new UpdateMileStone(stdcontroller);
           
            ums.updateMileStoneRecords();
           Required_Documents__c k=new Required_Documents__c();
                k.selectMS= true;
               
            }
           
            ums.updateDocumentRecords(); 
            
            }
       Test.stopTest();
     
    }

Thank you in advance
 
Hi everyone,
   
I need to upload new attachment to opportunity,
If I click on New Attachment button( first Visualforce page ) , it redirects to other Visualforce and provision to choose file and click upload, then the attachment appears in first Visualforce page.
I  am not getting any error but functionality is not working..
Actually when i am clicking on Choosefile button on second visualforce page we can choose a file but the thing is while am clicking the upload button i want to show the chosen file in first visualforce.

 
How do I do that?

I wrote some code below, and I attached screenshots below.
 First visualfore page:
User-added image
My Second visualforce page:
User-added image
my visualfore page-1
<apex:page standardController="opportunity" extensions="FileUploadController">
  <apex:form >
        <apex:pageblock >
            <apex:pageBlockSection title="Attachments" columns="1">
            <apex:CommandButton value="New Attachment" action="{!attach_new}"/>
            </apex:pageBlockSection>
        </apex:pageblock>
    </apex:form> 
</apex:page>


Visualforce page-2


<apex:page standardController="Opportunity" extensions="FileUploadController" showHeader="true">
<apex:pageBlock id="Pid">
    <apex:pageBlockSection title="Select a file to be uploaded" collapsible="false"/>
</apex:pageBlock>
    <apex:outputPanel id="panel_Upload">
    <apex:form id="form_Upload">
        <apex:inputFile id="file_File" value="{!fileBody}" filename="{!fileName}"/>
        <apex:actionRegion >
            <apex:commandButton id="button_Upload" value="Upload" action="{!processUpload}"/>
        </apex:actionRegion>
        <apex:CommandButton value="Cancel" action="{!Cancel}"/>
    </apex:form>
    </apex:outputPanel>
    <apex:pageBlock id="BId">
        <apex:pageBlockSection >
            <apex:dataTable Value="{!la}" var="l">
                <apex:column value="{!l.Name}"/>
            </apex:dataTable>
        </apex:pageBlockSection>
    </apex:pageBlock>
    
</apex:page>


My controller:

public class FileUploadController {
Public Opportunity opp{get; set;}
    private String fileName;
    private Integer fileSize; 
    private Blob fileBody; 
    public FileUploadController(ApexPages.StandardController controller) { } 
    public String getFileName() {
         return this.fileName; 
    } 
    
    public void setFileName(String fileName) { 
        this.fileName = fileName; 
    } 
    public Blob getFileBody() {
        return this.fileBody; 
    }
    
    public void setFileBody(Blob fileBody) {
        this.fileBody = fileBody; 
        setFileSize(this.fileBody.size()); 
    } 
    
    public Integer getFileSize() { 
        return this.fileSize;
    } 
    
    public void setFileSize(Integer fileSize) { 
        this.fileSize = fileSize; 
    } 
    
    List<Attachment> la{get;set;}
    
    Public List<Attachment> getLa(){
        return la;
    }
    
    private Database.SaveResult insertCustomObject() { 
        Opportunity custObj = new Opportunity(); 
        custObj.Name= 'Ranjith';
        insert la;
        return Database.insert(custObj); 
    }
    private Database.SaveResult insertAttachment(Id parentId) {
        Database.SaveResult result; 
        Attachment attachment = new Attachment(); 
        attachment.Body = this.fileBody; 
        attachment.Name = this.fileName; 
        attachment.ParentId = parentId; 
        result = Database.insert(attachment); 
        fileBody = Blob.valueOf(' '); 
        return result; 
    } 
    
    public Void processUpload() {
        try { 
            Database.SaveResult result = insertCustomObject();
            result = insertAttachment(result.getId());  
           } catch (Exception e) {
                ApexPages.AddMessages(e);
           } 
   }
    public pagereference attach_new(){
                pagereference pag = new pagereference('/apex/NewAttachments');
                return pag;
    } 
}
Anyone help me out solve this scenario.
Thank you in advance...
 
Hi everyone
I wrote a test class for custom case object.It showing the error
" Invalid bind expression type of Schema.SObjectField for column of type Id".
My Apex class:
public class OpenEventsforPotentials {

public List<OpenActivity> open{get;set;}

    public Boolean refreshPage {get; set;}

    public List<Event> accs { get; set;}

    public Id Potentialld{get;set;}
    public Id Accountid{get;set;}

    public string SelectedEventId { get; set;}

    public OpenEventsforPotentials (ApexPages.StandardController controller) {

        Potentialld= ApexPages.CurrentPage().getparameters().get('id');
        list<Account> Accountid=[select id from Account]; 
        list<Opportunity>   c =[SELECT Name,

                                (Select Id,Subject,IsTask, WhoId, ActivityDate,Status, Priority, OwnerId FROM OpenActivities WHERE IsTask=False)

                           FROM Opportunity WHERE Id = :Potentialld];

        if(c.size() > 0){

            open = c[0].OpenActivities;

        }

     

    }

       

   

    public pageReference DeleteEvent(){

     

        // if for any reason we are missing the reference

        if (SelectedEventId != null) {

            Event tobeDeleted = [SELECT Id FROM Event WHERE Id =:SelectedEventId];

            if(tobeDeleted != null){

                delete tobeDeleted;

            }

             

            for(Integer i=0;i < open.size();i++){

                if(open[i].Id == SelectedEventId){

                    open.remove(i);

                    i--;

                }

            }

        }

         

        return null;

    }

    public Pagereference refresh(){

        PageReference secondPage = new PageReference('https://ap1.salesforce.com/{!Leadld}');

       secondPage.getParameters().put('id',Potentialld);

       secondPage.setRedirect(true);

         

        return secondPage;

     

    }   

}
Test class:
@isTest
public class  Testclassforcases{

    static TestMethod void testforcases(){

       User usr = [SELECT Id From User WHERE Id =:UserInfo.getUserID()];

        System.runAs(usr){
           Account A1=[select id from account
                       where id = : case__c.Account_Name__c];
           case__c case1=new case__c(OwnerId=usr.Id,CurrencyIsoCode = 'INR',Name=A1.Id
                                     );

            Insert case1;
           

             

           
            
            Event event1=new Event(OwnerId=usr.Id,Subject='cc',DurationInMinutes=60,ActivityDateTime=Datetime.newInstance(2015,25,2,00,00,00),
                                 EndDateTime=Datetime.newInstance(2015,25,2,01,00,00),StartDateTime=DateTime.newInstance(2015,25,2,00,00,00));
            
            Insert event1;
        

            ApexPages.StandardController stdcontroller = new ApexPages.Standardcontroller(case1);

            ApexPages.CurrentPage().getparameters().put('id',case1.Id);
            OpenEventsforCases eve=new OpenEventsforCases(stdcontroller);
            eve.DeleteEvent();
           // eve.refresh();
            OpenTasksforCases eve1= new OpenTasksforCases( stdcontroller);
            eve1.listwrapper[0].checked = true;
            eve1.close();

         

        }

    } 
}
Can anyone help me out to solve this problem.
Thank you in advance.....
 
Hi everyone
My scenario is to show the open task of lead object as a seperate related list instead of using open activity.
For that i took viusalforce and extension controller.
It works good actually.
when clicking  the close button and check box the particular record will get closed but the thing is 
its not showing in Activity History immediatly after refreshing the page only its shows that particular record in Activity History.
can anyone help me out to solve thing problem..
public class OpenTasks {

    public List<OpenActivity> open{get;set;}

    public Id leadLd{get;set;}
   
    public list<wrapperclass> listwrapper{get;set;}
    

    public OpenTasks(ApexPages.StandardController controller){

        leadLd = ApexPages.CurrentPage().getparameters().get('id');
        list<task> open1 =new list<Task>();

        listwrapper = new list<wrapperclass>();
         


        list<lead>   le =[SELECT Name, (Select Id,Subject, WhoId, ActivityDate,Status, Priority, OwnerId FROM Tasks WHERE IsClosed=false)

                            FROM Lead WHERE Id = :leadld];

        if(!le.isEmpty()){
            
            for(Task k: le[0].Tasks)

            {

               listwrapper.add(new Wrapperclass(k));
               
            }

        }

    }

     

    public class wrapperclass

    {
        public  boolean checked{get;set;}

        public Task k{get;set;}

        public Wrapperclass(Task k){

            this.k=k;

        }

    }

  public PageReference close()

    {  

        list<Task> listofopen=new list<Task>();

        if(!listwrapper.isEmpty()){

            for(Integer i=0; i<listwrapper.size();i++)

            {
                wrapperclass w = listwrapper[i];
           
                if(w.checked==true){
                    system.debug(w);
                    w.k.status='completed';
                    listofopen.add(w.k);
                    listwrapper.remove(i);
                    i--;
   
                                }
             
            }

        }

        if(listofopen.isEmpty())

        {

            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR,'Select atleast one column '));

        }

        else{

           update listofopen;   

        }
       
    
  
      return null;

    }  

 }

visualforce

<apex:page standardController="Lead" extensions="OpenTasks"  >

    <apex:form >

        <apex:pageBlock title="Open Tasks" mode="edit" id="opnTsks">

            <apex:Messages />        

            <center><a href="https://cs18.salesforce.com/00T/e?who_id={!leadld}&retURL={!leadld}" target="_top"><button type="button">New Task</button></a>

                <apex:commandButton value="close" action="{!close}" rerender="opnTsks" />

            </center>&nbsp;&nbsp;

            <apex:pageBlockTable value="{!listwrapper}" var="each" >

                <apex:column headerValue="Action">

                     <apex:inputCheckbox value="{!each.checked}"/>

                    &nbsp;|&nbsp;

                    <apex:outputlink value="/{!each.k.id}/e?retURL={!each.k.WhoId}" target="_top"> Edit </apex:outputlink>

                   </apex:column>

                <apex:column headerValue="Subject" value="{!each.k.Subject}"/>

                <apex:column headerValue="ActiveDate" value="{!each.k.ActivityDate}"/>

                <apex:column headerValue="Status" value="{!each.k.Status}"/>

            </apex:pageBlockTable>

        </apex:pageBlock>

     </apex:form>

</apex:page>
Thank you in advance...
 
Hi Everyone
My scenario is to show the open task and events of lead object as separate list in pagelayout instead of using  openactivity.
I got an output for this.I want to add my visualforce page in lead layout.
for that i took one section and i kept my visualforce in that section.
But it shows my visualforce page in half page i want to increase the width in pagelayout already it is 100% and  i  also don't want to see the standerd buttons in that section.
can anyone help to out to solve this problem..



Thank you in advance.
Hi everyone,
I am new bie to Salesforce.
This is my first  Test class.
I tried but somewhere i did mistake.
anyone give me guidelines to solve this.
 
My class


public class opentasks {

    public List<OpenActivity> open{get;set;}

    public Id leadld{get;set;}
   
    public list<wrapperclass> listwrapper{get;set;}
    

    public opentasks(ApexPages.StandardController controller){

        leadld = ApexPages.CurrentPage().getparameters().get('id');
        list<task> open1 =new list<Task>();

        listwrapper = new list<wrapperclass>();
         


        list<lead>   le =[SELECT Name, (Select Id,Subject, WhoId, ActivityDate,Status, Priority, OwnerId FROM Tasks WHERE IsClosed=false)

                            FROM Lead WHERE Id = :leadld];

        if(!le.isEmpty()){
            
            for(Task k: le[0].Tasks)

            {

               listwrapper.add(new Wrapperclass(k));
               
            }

        }

    }

     

    public class wrapperclass

    {
        public  boolean checked{get;set;}

        public Task k{get;set;}

        public Wrapperclass(Task k){

            this.k=k;

        }

    }

  public PageReference close()

    {  

        list<Task> listofopen=new list<Task>();

        if(!listwrapper.isEmpty()){

            for(Integer i=0; i<listwrapper.size();i++)

            {
                wrapperclass w = listwrapper[i];
           
                if(w.checked==true){
                    system.debug(w);
                    w.k.status='completed';
                    listofopen.add(w.k);
                    listwrapper.remove(i);
                    i--;
   
                                }
             
            }

        }

        if(listofopen.isEmpty())

        {

            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR,'Select atleast one column '));

        }

        else{

           update listofopen;   

        }
       

My test class:

public class c{
static TestMethod void testforlead()
{ 
Test.StartTest();
User user =new User(Id=UserInfo.getUserID());

System.runAs(usr){
Lead l1=new Lead();
l1.Text(80)='shobana';
l1.Company='rix';
l1.Status='Working-contacted';
Insert l1;

Task t1=new Task();
t1.Owner='shoba shoba';
t1.Subject='cc';
t1.Priority='High';
t1.Status='In progress';
t1.Whoid=l1.Id;
Insert t1;
 ApexPages.StandardController stdcontroller = new ApexPages.Standardcontroller(l1);
 opentasks cls= new opentasks( stdcontroller);
 cls.close();
 for(wrapperclass w:cls.listwrapper)

            {
              
 w.Checked=true;
break;
 } 

cls.close();
}
Test.stopTest();
 
 }
 
}
Thank you in advance.

 
Hi Everyone
 My scenario is to show the related events record of lead object  in pagelayout.
 For that i took visualforce page and extension controller.
Actually i am getting output but for delete action will get works when i refresh the page .
public class forevents {
public List<OpenActivity> open{get;set;}
    public Boolean refreshPage {get; set;}
    public List<Event> accs { get; set;}
    public Id leadld{get;set;}
    public string SelectedEventId { get; set;}
    public forevents(ApexPages.StandardController controller) {
       leadld = ApexPages.CurrentPage().getparameters().get('id');
        list<lead>   c =[SELECT Name, 
                                  (Select Id,Subject,IsTask, WhoId, ActivityDate,
                                    Status, Priority, OwnerId FROM OpenActivities WHERE IsTask=False) 
                            FROM Lead WHERE Id = :leadld];
        if(c.size() > 0){
            open = c[0].OpenActivities;
        }
        
        }
      
  
     public void DeleteEvent()
   {
   
   
      // if for any reason we are missing the reference 
      if (SelectedEventId == null) {
      
         return ;
         
      }

     
      // find the event record within the collection
     Event tobeDeleted = null;
     accs = [Select id, Whoid,description,subject,activitydate
               from event
               where Whoid=: leadld ]; 
      for(Event a : accs)
       if (a.Id == SelectedEventId) {
          tobeDeleted = a;
          break;
       }
      
      //if event record found delete it
      if (tobeDeleted != null) {
       Delete tobeDeleted;
      }
     
     
   }
  public Pagereference refresh()
  {
  PageReference secondPage = new PageReference('https://ap1.salesforce.com/{!Leadld}');
  secondPage.getParameters().put('id',Leadld); 
        secondPage.setRedirect(true);
         
        return secondPage; 
  
  }    
}


<apex:page standardController="Lead" extensions="forevents" >
<apex:form >
        <apex:pageBlock title="Open Events"  >          
<center><a href="https://ap1.salesforce.com/00U/e?who_id={!leadld}&retURL={!leadld}" target="_top"><button type="button">New Event</button></a>
</center>&nbsp;&nbsp;

                <apex:pageBlockTable value="{!open}" var="each"   ><br/>
                
                    <apex:column headerValue="Action">
                        <apex:outputlink value="/{!each.id}/e?retURL={!each.WhoId}" target="_top" style="font-weight:bold"> Edit </apex:outputlink>&nbsp;|&nbsp;
                       <a href="javascript:if (window.confirm('Are you sure?')) DeleteEvent('{!each.Id}');" style="font-weight:bold">Del</a>
                    </apex:column>
                    <apex:column headerValue="Subject" value="{!each.Subject}"/>
                    <apex:column headerValue="ActiveDate" value="{!each.ActivityDate}"/>
                    <apex:column headerValue="Status" value="{!each.Status}"/>
                </apex:pageBlockTable>
         </apex:pageBlock>
             <apex:actionFunction action="{!DeleteEvent}" name="DeleteEvent" reRender="form" >
                        <apex:param name="eventid" value="" assignTo="{!SelectedEventId}"/>
                    </apex:actionFunction>
                  
 </apex:form>
</apex:page>
Anyone help me out...
Thank you in advance.
Hi  everyone
This is my first wrapper class.
I would like to show open task as seperate section on my lead page layout.
For that i took a standard controller with extension.In this scenario i have finished upto 3steps and I got output also.
Step 1; showing  task record related to lead object.
Step 2:i have created new task button.
Step 3: i have show edit option for each records of task.

My 3rd and 4th step is to add a checkbox and close button for that section.whenever am clicking  checkbox and close botton i want to show that particular record in activity history.
for this concept i took wrapper class concept but its showing error " opentasks Compile Error: Variable does not exist: status
my controller page

public class opentasks {
public List<OpenActivity> open{get;set;}
    public Id leadld{get;set;}
    Public boolean allbool{get;set;}
    public list<wrapperclass> listwrapper{get;set;}
    public list<lead> c{get;set;}
    public opentasks(ApexPages.StandardController controller) {
        leadld = ApexPages.CurrentPage().getparameters().get('id');
         c =[SELECT Name, 
                                  (Select Id,Subject,IsTask, WhoId, ActivityDate,
                                    Status, Priority, OwnerId FROM OpenActivities WHERE IsTask=True) 
                            FROM Lead WHERE Id = :leadld];
                         
        if(c.size() > 0){
            open = c[0].OpenActivities;
        }
        
        }
    public opentasks(){
   list<openactivity> open1 =new list<openactivity>(); 
  list<lead>   le =[SELECT Name, 
                                  (Select Id,Subject,IsTask, WhoId, ActivityDate,
                                    Status, Priority, OwnerId FROM OpenActivities WHERE IsTask=True) 
                            FROM Lead WHERE Id = :leadld];
                         
        if(c.size() > 0){
            open1 = c[0].OpenActivities;
        }
    for(Openactivity k:open1)
    {
   
    listwrapper.add(new Wrapperclass(k));
    }
    }
    
    
    
    public class wrapperclass
    {
    public  boolean checked{get;set;}
    public Openactivity k{get;set;}
    public Wrapperclass(openactivity k)
    {
    this.k=k;
    }
    }
    public void close()
    {   
    list<openactivity> listofopen=new list<openactivity>();
    list<wrapperclass> listofwrapper=new list<wrapperclass>();
    for(wrapperclass w:listwrapper)
    {
   if(w.checked==true)
   {
   system.debug(w);
   w.status='completed';   HERE  AM GETTING ERROR
   listofopen.add(w.k);
   
   }
   
   
    else
    {
    listofwrapper.add(w);
    }
    }
    if(listofopen.size()==0)
    {
     ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR,'Select atleast one column t'));
    }}   
 }

can anyone help me out


Thank you in advance


 
Hi all ,
          I have a requirement that i need to to display all Contacts and Leads of our Organization on Google maps using Single Visualforce page to track All Contacts and Leads from Current Location, Here i displayed all Leads from current location but i need to display All Contacts also for the same Page if any one knows pls help

Here is my code

Class:
--------
global with sharing class LeadsNearbyMe {

public Lead leads{get; set;}

@RemoteAction
   global static List<Lead> getNearby(String lat, String lon) {

        if(lat == null || lon == null || lat.equals('') || lon.equals('')) {
            lat = '51.096214';
            lon = '3.683153';
        }

        String queryString =
            'SELECT Id, Name, Location__Longitude__s, Location__Latitude__s, ' +
                'Street, City,State,Country, PostalCode ' +
            'FROM Lead ' +
            'WHERE DISTANCE(Location__c, GEOLOCATION('+lat+','+lon+'), \'km\') < 60 ' +
            'ORDER BY DISTANCE(Location__c, GEOLOCATION('+lat+','+lon+'), \'km\') ' +
            'LIMIT 25';
        return(database.Query(queryString));
    }
}

Page:
--------

<apex:page sidebar="false" showheader="false" controller="LeadsNearbyMe">
 
  <apex:includeScript value="{!$Resource.googleMapsAPI}" />
      <script type="text/javascript"
        src="https://maps.googleapis.com/maps/api/js?key=AIzaSyCROH4OR9fzDhmprWPL1wGWfPT4uGUeMWg&sensor=false">
        </script>
        
    <!-- Setup the map to take up the whole window -->
    <style>
        html, body { height: 100%; }
        .page-map, .ui-content, #map-canvas { width: 100%; height:100%; padding: 0; }
        #map-canvas { height: min-height: 100%; }
    </style>
    
    <script>
        function initialize() {
            var lat, lon;
          
             if (navigator.geolocation) {
                 navigator.geolocation.getCurrentPosition(function(position){
                     lat = position.coords.latitude;
                     lon = position.coords.longitude;                    
                     
                     // Use Visualforce JavaScript Remoting to query for nearby conts      
                     Visualforce.remoting.Manager.invokeAction('{!$RemoteAction.LeadsNearbyMe.getNearby}', lat, lon,
                         function(result, event){
                             if (event.status) {
                                 console.log(result);
                                 createMap(lat, lon, result);           
                             } else if (event.type === 'exception') {
                                 //exception case code          
                             } else {
                                            
                             }
                          },
                          {escape: true}
                      );
                  });
              } else {
                  // Set default values for map if the device doesn't have geolocation capabilities
                    /** Eindhoven **/
                    lat = 51.096214;
                    lon = 3.683153;
                    
                    var result = [];
                    createMap(lat, lon, result);
              }
          
         }
    
         function createMap(lat, lon, leads){
            var currentPosition = new google.maps.LatLng(lat,lon);
            var mapDiv = document.getElementById('map-canvas');
            var map = new google.maps.Map(mapDiv, {
                center: currentPosition,
                zoom: 13,
                mapTypeId: google.maps.MapTypeId.ROADMAP
            });
            
            // Set a marker for the current location
            var positionMarker = new google.maps.Marker({
                map: map,
                position: currentPosition,
                title: 'You are here',
            });
            
            // Keep track of the map boundary that holds all markers
            var mapBoundary = new google.maps.LatLngBounds();
            mapBoundary.extend(currentPosition);
            
            // Set markers on the map from the @RemoteAction results
            var cont;
            for(var i=0; i<leads.length;i++){
                cont = leads[i];
                console.log(leads[i]);
                setupMarker();
            }
       map.fitBounds(mapBoundary);

           function setupMarker(){
                var contNavUrl;
           
                try{
                    if(sforce.one){
                        contNavUrl =
                            'javascript:sforce.one.navigateToSObject(\'' + cont.Id + '\')';
                    }
                } catch(err) {
                    console.log(err);
                    contNavUrl = '\\' + cont.Id;
                }
                
                var contDetails =
                    
                    cont.Name + ',' +
                    cont.Street + ',' +
                    cont.City + ',' +
                    cont.PostalCode;
           var marker = new google.maps.Marker({
                   map: map,
                   icon : "{!URLFOR($Resource.GoogleMarkers, 'GoogleMark/4-l.png')}",
                   title:contDetails,
                   position: new google.maps.LatLng(
                                   cont.Location__Latitude__s,
                                   cont.Location__Longitude__s)
               });
               mapBoundary.extend(marker.getPosition());
           }
                  
           }
 
        google.maps.event.addDomListener(window, 'load', initialize);
        
    </script>
<body style="font-family: Arial; border: 0 none;">
 
        <div id="map-canvas"></div>
    </body>
 
</apex:page>


Screen shot:
------------------

User-added image


Thanks & Regards,
  • January 07, 2015
  • Like
  • 2