• Nilima Kumari
  • NEWBIE
  • 10 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 3
    Replies
Hello Experts

I am new to the Visualforce, 
i am working on a requirement where live Location has to be tracked on the VF page Google maps Including Markers with help of Geolocation latitude and langitude which must be fetched from custom object (Contact_Check_In__c)

My Custom Object name is Contact_Check_In__c
 and i have fields called geolocation(GeoLocation__c)
With Lot of effort and searching i came accross vf page and apex controller, all is ok but it is not capturing the Live Geolocation

all i want is vf page has to take the dynamic geolocation from the record and show it on the google maps on vf page

i refered this blogs still not able to resolve my issue
https://developer.salesforce.com/forums?id=906F0000000AKp5IAG
https://success.salesforce.com/answers?id=90630000000guBkAAI

Any help would be highly appreciated

Below are my VF page
<apex:page StandardController="Contact_Check_In__c" extensions="MyCheckInController" lightningStylesheets="true" docType="HTML-5.0">

<html>
  <head>
   <title>Check In Detail</title>
   <style>
      /* Always set the map height explicitly to define the size of the div
       * element that contains the map. */
      #map {
        height: 90%;
      }
      /* Optional: Makes the sample page fill the window. */
      html, body {
        height: 90%;
        margin: 0;
        padding: 0;
      }
    </style>
  </head>

  <body onload = "loadMap()">
    <h2>Check In on the Map</h2>
    <div id = "map" ></div>
      <script>

        
        function loadMap() {
          // Initialize Google Maps
          const mapOptions = {
            center:new google.maps.LatLng(13.0161331,76.0898104),
            zoom: 13
          }
          const map = new google.maps.Map(document.getElementById("map"), mapOptions);
          
          var text = '{!JsonCheckInData}';
          var iconBase = 'https://maps.google.com/mapfiles/kml/shapes/';
            var icons = {
              parking: {
                icon: iconBase + 'parking_lot_maps.png'
              },
              library: {
                icon: iconBase + 'library_maps.png'
              },
              info: {
                icon: iconBase + 'info-i_maps.png'
              }
            };
            
          var obj = JSON.parse(text);
          //alert(obj);
          //return obj;
          var x;
          var jsonData='';
          var loc1='';
          var loc2;
          var address='';
          for (x in obj) {
           
            temp=obj[x].location.split(",");
            loc1=temp[0].replace("[", "");
            loc2=temp[1].replace("]", "");
            
                                   
            let marker = new google.maps.Marker({
              map: map,
              icon:icons['library'].icon,
              position: new google.maps.LatLng(loc1, loc2),
              title: 'Person Name:' +  obj[x].name + ' CheckIn:' +obj[x].checkIn 
            })
            
            
          } 
        
        }
      </script>
      <!--<script src = "https://maps.googleapis.com/maps/api/js"></script>-->
     <script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyBqqej11sosokXGaQTk_-Zw9AIXMVkXoAE&callback=loadMap">
    </script>
    {!JsonCheckInData}
  </body>
</html>
</apex:page>

My Controller
 
public class MyCheckInController {

    public MyCheckInController(ApexPages.StandardController controller) {

    }


    public list<Contact_Check_In__c> LstContactCheckIn{get;set;}
    
    public string JsonCheckInData{get;set;}

    public MyCheckInController(){
        
        LstContactCheckIn=[Select Id, CheckIn_Date_Time__c, GeoLocation__latitude__s, GeoLocation__longitude__s, Contact__r.Name from Contact_Check_In__c];
        
        list<WrpData> lstWrpData=new list<WrpData>();
        
        for(Contact_Check_In__c Check:LstContactCheckIn){
               string strLocation='[' + string.valueOf(check.GeoLocation__latitude__s) + ','  + string.valueOf(check.GeoLocation__longitude__s)+ ']';
               WrpData wrp=new WrpData(check.Contact__r.Name, strLocation, string.ValueOf(check.CheckIn_Date_Time__c),string.valueOf(check.GeoLocation__latitude__s),string.valueOf(check.GeoLocation__longitude__s));
               lstWrpData.add(wrp);
        }
        
        JsonCheckInData=Json.Serialize(lstWrpData);
        
    }
    
    public class WrpData{
        
        public string name{get;set;}
        public string location{get;set;}
        public string checkIn{get;set;}
        public string lat{get;set;}
        public string lng{get;set;}
        public WrpData(string nm,string loc,string chkIn, string lt,string ln){
            name=nm;
            location=loc;
            checkIn=chkIn;
            lat=lt;
            lng=ln;
        }
    }
   
}

​​​​​​​

 
Hello Developers

i am trying to design a Test class for the Apex class but i am not able to do the code coverage of the following apex class, can anyone please help
 
public class FutureHandler {
    
    @future
    public static void updaterecs(Map<String,Id> oldManagerQuotaMap1){
        Map<Id,Quota__c> oldMapQuota = new Map<Id,Quota__c>();
        if(null != oldManagerQuotaMap1 && oldManagerQuotaMap1.size() > 0){
            for (aggregateResult result: [Select Manager_Quota__c, Sum(Inside_Sales_Roll_Up__c) 
                                          FROM Quota__c WHERE 
                                          Manager_Quota__c IN: oldManagerQuotaMap1.values() 
                                          GROUP BY Manager_Quota__c]) {
                                              system.debug('result'+result)    ;          
                                              oldMapQuota.put((Id)result.get('Manager_Quota__c'),new Quota__c(Id=(Id)result.get('Manager_Quota__c'),Actual_Amount__c =(Decimal)result.get('expr0')));         
                                          }
            
            for(Id qId : oldManagerQuotaMap1.values()){
                if(!oldMapQuota.containskey(qId)){
                    oldMapQuota.put(qId, new Quota__c(Id = qId,Actual_Amount__c = 0.0));
                }
            }
            
            if(null != oldMapQuota && oldMapQuota.size() > 0){
                update oldMapQuota.values();
            }
            
        }
    }

    public static void sendOppsForApproval(List<Opportunity> opps){
        
        List<Opportunity> oppsToBeSentForApproval = new List<Opportunity>();
        String monthYear = System.now().format('MMMM-yyyy');
        String month = monthYear.split('-')[0];
        String year = monthYear.split('-')[1];
        Date nextMonthStart = System.today().toStartOfMonth().addMonths(1).toStartOfMonth();
        List<Aggregate_Approval__c> appr = [Select Id from Aggregate_Approval__c where Month__c=:month And Year__c=:year]; 
        Id approvalId;
        if(appr.size()>0){
            approvalId = appr[0].Id;
            
            for(Opportunity opp : opps){
                opp.Aggregate_Approval__c = approvalId;
                opp.Status__c = 'In Approval';
                oppsToBeSentForApproval.add(opp);
            }
            update oppsToBeSentForApproval;
           // List<Approval.LockResult> li = Approval.lock(opps);
            
            Approval.ProcessSubmitRequest oppAggregateApproval = new Approval.ProcessSubmitRequest();
            oppAggregateApproval.setComments('Submitting opportunities for Approval for '+System.now().format('MMMM-yyyy'));
            oppAggregateApproval.setObjectId(approvalId);
            Approval.ProcessResult approvalResult = Approval.process(oppAggregateApproval); 
            
        } 
    }
}
My Test Class
 
@isTest
public class FutureHandlerTestclass {
    
    static testmethod void Futuretest(){
        
        List<Quota__c> Ftur = new list <Quota__c>();
        Quota__c FF = new Quota__c();
        FF.Name='Julian';
        FF.Assigned_To__c = userinfo.getUserId();
        FF.Month__c='March';  
        FF.Quater__c='Q1';       
        FF.Quater_Year__c = '2020';
        FF.Actual_Amount__c = 100;
        FF.Unique_Identifier_Per_Quater_Per_User__c = 'Hello';
        Ftur.add(FF);
        insert FF;
        
        
        Quota__c FF1 = new Quota__c();
        FF1.Name='rahul';
        FF1.Assigned_To__c = userinfo.getUserId();
        FF1.Month__c='October';  
        FF1.Quater__c='Q4';       
        FF1.Quater_Year__c = '2030';
        FF.Actual_Amount__c = 200;
        FF1.Unique_Identifier_Per_Quater_Per_User__c = 'Helloworld';
        Ftur.add(FF1);
        insert FF1;
        
        Account testAcct = new Account (Name = 'My Test Account');
        insert testAcct;
        
        User u = [Select id,name from user where isactive=true Limit 1];
        
        List<Opportunity> Oppps = new list <Opportunity>(); 
        Opportunity oop = new Opportunity();
        
        oop.Name = 'Test1';
        oop.AccountId = testAcct.ID;
        oop.StageName = 'Demo';
        oop.CloseDate = system.today();
        oop.Billing_To_Be_Initiated__c = 'Yes';
        oop.LeadSource = 'Customer';
        oop.Country__c = 'India';        
        Oppps.add(oop);
        insert oop;
    }
    }

 
Hi all

i am new to the apex development, i have been given the task for writing the test class for Emailalertbatclass, but i am not able to cover the excute method, it is only showing 27%, could anyone please help in the covering 100%
 
global class Emailalertbatchclass implements Database.Batchable<sObject>, Schedulable, Database.Stateful {
    
    //Variable Section
    global FINAL String strQuery;
    global FINAL String leadid;
    global List<String> errorMessages = new List<String>();
    
    global Emailalertbatchclass() { 
        this.strQuery = getBatchQuery();
    }
    
    //Returns the Query String to Batch constructor to fetch right records.
    private String getBatchQuery() {
        String strQuery = 'SELECT Id,Name,Status,Email,owner.email,owner.name,ownerid,No_Enquiry_Email_Sent__c,Manager_Email__c,recordtype.name FROM Lead where No_Enquiry_Email_Sent__c=false AND recordtype.name=\'Lead Registration\' AND Lead_Intent_Type__c=\'High Intent Lead\' AND Status=\'Enquiry\' And ((DaysSinceLastActivityDone__c>=0) OR (DayssinceEnquirystage__c >= 0))';
        return strQuery;
    }
    
    //Batch Start method
    global Database.QueryLocator start(Database.BatchableContext BC) {
        return Database.getQueryLocator(strQuery);
    }
    
    //Batch Execute method calls findCostForWoD method
    global void execute(Database.BatchableContext BC, List<sObject> scopeList) {
        System.debug(LoggingLevel.INFO, '== scopeList size ==' + scopeList.size());
        
        List<Lead> ld = (List<Lead>) scopeList;
        List<Lead> updatedld = new List<Lead>();
        if(!ld.isEmpty()) { 
            List<Messaging.SingleEmailMessage> mailList = new List<Messaging.SingleEmailMessage>();
            for (Lead prod : ld)
            {               
                // Step 1: Create a new Email
                Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
                System.debug( 'prod.owner.Email ' + prod.owner.Email);
                String[] toAddresses = new String[] {prod.owner.Email};
                    // Step 2: Set list of people who should get the email
                    if(prod.Manager_Email__c!=null && prod.Manager_Email__c==''){
                        toAddresses.add(prod.Manager_Email__c);
                    }
                mail.setToAddresses(toAddresses);
                System.debug( 'toAddresses ' + toAddresses);
                
                // Step 3: Set who the email is sent from
                mail.setReplyTo(prod.owner.Email);
                mail.setSenderDisplayName('No Activity on Leads for 24hrs');
                
                // (Optional) Set list of people who should be CC'ed
                List<String> ccTo = new List<String>();
                mail.setCcAddresses(ccTo);
                
                // Step 4. Set email contents - you can use variables!
                mail.setSubject('No Activity on Lead for 24hrs');
                String body = 'Dear ' + prod.owner.name + ', <br><br>';
                body += 'This is to notify you that there is no activity done on the respective <b> Lead Name: ';
                body +=prod.Name+'</b>  please find the link below..<br><br>';
                body += 'link to file: '+URL.getSalesforceBaseUrl().toExternalForm()+'/'+prod.id+'<br><br><br> Thanks,<br>Moengage Team</body></html>';
                mail.setHtmlBody(body);
                System.debug( 'body ' + body);
                
                // Step 5. Add your email to the master list
                mailList.add(mail);
                prod.No_Enquiry_Email_Sent__c = true;
                updatedld.add(prod);
                System.debug( 'prod ' + prod);
                
            }
            if(!mailList.isEmpty()) {
                try{
                    Messaging.sendEmail(mailList);
                    update updatedld;
                    system.debug('mailList '+mailList);
                }
                catch (Exception ex) {
                    errorMessages.add('Unable to send email to Tech: '+ ex.getStackTraceString());
                }
            }
        }
    }  
    
    //Batch Finish method for after execution of batch work
    global void finish(Database.BatchableContext BC) { 
        
    }
    
    //Method which schedules the ProductDownloadBatch
    global void execute(SchedulableContext sc) {        
        Emailalertbatchclass snInstance = new Emailalertbatchclass();
        ID batchprocessid = Database.executeBatch(snInstance);
    }
}
My Test Class
 
@isTest
public class EmailalertbatchclassTestclass
{
    static testMethod void testmethod1()
    {
        
        Id rcdTypeId = Schema.SObjectType.Lead.getRecordTypeInfosByName().get('Lead Registration').getRecordTypeId();
        List<Lead> Leadld = new List<Lead>();
        lead ld = new lead();
        ld.FirstName= 'test';
        ld.LastName='Test2';
        ld.status='Enquiry';
        ld.Company = 'fgfh';
        ld.Email = 'Nilu112@gmail.com';
        ld.Manager_Email__c = 'rakeshkumar1998@gmail.com';
        ld.RecordTypeId = rcdTypeId;//added here
        ld.No_Enquiry_Email_Sent__c = false;  //changed true to false
        
        Insert ld;
        Leadld.add(ld); 
        
        Test.startTest();
        ld.FirstName = 'test1';
        update ld;
        
        Emailalertbatchclass snInstance = new Emailalertbatchclass();
        ID batchprocessid = Database.executeBatch(snInstance);
        
        Test.stopTest();
    }
    public static testMethod void testschedule() {
        Test.StartTest();
        Emailalertbatchclass sh1 = new Emailalertbatchclass();
        String sch = '0 00 01 * * ?'; 
        ID batchprocessid = Database.executeBatch(sh1);
        String jobId = system.schedule('Emailalertbatchclass', sch, sh1);
        System.assert(jobId != null);
        Test.stopTest(); 
    }
}


 
Hello Developers

i am new to the Salesforce, and i am trying to lear Formula fields, i have been given a task where Start Date and End date should show when custom field(Month__c) is selected, Now if i try to put Year, it shows error, 
 
Quota Start Date

DATE(
YEAR(TODAY()),
CASE(TEXT(Month__c), 
"January", 1, 
"February", 2,
"March", 3,
"April", 4,
"May", 5,
"June",6,
"July", 7,
"August",8, 
"September", 9,
"October", 10,
"November", 11,
"December", 12,
0),
1
)
----------------------------- 
Quota End Date

DATE(
YEAR(TODAY()),
CASE(TEXT(Month__c), 
"January", 1, 
"February", 2,
"March", 3,
"April", 4,
"May", 5,
"June",6,
"July", 7,
"August",8, 
"September", 9,
"October", 10,
"November", 11,
"December", 12,
0),
1
)

Now i want to add Picklist Field Name called Quater Year (Quater_Year__c), it consist of Number of Years from 2020 to 2030

So my requirement is when i select Picklist Quater Year as 2022 and Picklist Month as Jan, the Quota Start Date and Quota End Date should show for that particular Year i.e Jan 1st 2022 and Jan 31st 2022

but i am getting an error

User-added image
How do i resolve this issue??
Hi all

i am new to the apex development, i have been given the task for writing the test class for Emailalertbatclass, but i am not able to cover the excute method, it is only showing 27%, could anyone please help in the covering 90%

My Class
 
global class Emailalertbatchclass implements Database.Batchable<sObject>, Schedulable, Database.Stateful {
    
    //Variable Section
    global FINAL String strQuery;
    global FINAL String leadid;
    global List<String> errorMessages = new List<String>();
    
    global Emailalertbatchclass() { 
        this.strQuery = getBatchQuery();
    }
    
    //Returns the Query String to Batch constructor to fetch right records.
    private String getBatchQuery() {
        String strQuery = 'SELECT Id,Name,Status,Email,owner.email,owner.name,ownerid,No_Enquiry_Email_Sent__c,Manager_Email__c,recordtype.name FROM Lead where No_Enquiry_Email_Sent__c=false AND recordtype.name=\'Lead Registration\' AND Status=\'Enquiry\' And ((DaysSinceLastActivityDone__c>=0) OR (DayssinceEnquirystage__c >= 0))';
        return strQuery;
    }
    
    //Batch Start method
    global Database.QueryLocator start(Database.BatchableContext BC) {
        return Database.getQueryLocator(strQuery);
    }
    
    //Batch Execute method calls findCostForWoD method
    global void execute(Database.BatchableContext BC, List<sObject> scopeList) {
        System.debug(LoggingLevel.INFO, '== scopeList size ==' + scopeList.size());
        
        List<Lead> ld = (List<Lead>) scopeList;
        List<Lead> updatedld = new List<Lead>();
        if(!ld.isEmpty()) { 
            List<Messaging.SingleEmailMessage> mailList = new List<Messaging.SingleEmailMessage>();
            for (Lead prod : ld)
            {               
                // Step 1: Create a new Email
                Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
                System.debug( 'prod.owner.Email ' + prod.owner.Email);
                String[] toAddresses = new String[] {prod.owner.Email};
                    // Step 2: Set list of people who should get the email
                    if(prod.Manager_Email__c!=null && prod.Manager_Email__c==''){
                        toAddresses.add(prod.Manager_Email__c);
                    }
                mail.setToAddresses(toAddresses);
                System.debug( 'toAddresses ' + toAddresses);
                
                // Step 3: Set who the email is sent from
                mail.setReplyTo(prod.owner.Email);
                mail.setSenderDisplayName('No Activity on Leads for 24hrs');
                
                // (Optional) Set list of people who should be CC'ed
                List<String> ccTo = new List<String>();
                mail.setCcAddresses(ccTo);
                
                // Step 4. Set email contents - you can use variables!
                mail.setSubject('No Activity on Lead for 24hrs');
                String body = 'Dear ' + prod.owner.name + ', <br><br>';
                body += 'This is to notify you that there is no activity done on the respective <b> Lead Name: ';
                body +=prod.Name+'</b>  please find the link below..<br><br>';
                body += 'link to file: '+URL.getSalesforceBaseUrl().toExternalForm()+'/'+prod.id+'<br><br><br> Thanks,<br>Moengage Team</body></html>';
                mail.setHtmlBody(body);
                System.debug( 'body ' + body);
                
                // Step 5. Add your email to the master list
                mailList.add(mail);
                prod.No_Enquiry_Email_Sent__c = true;
                updatedld.add(prod);
                System.debug( 'prod ' + prod);
                
            }
            if(!mailList.isEmpty()) {
                try{
                    Messaging.sendEmail(mailList);
                    update updatedld;
                    system.debug('mailList '+mailList);
                }
                catch (Exception ex) {
                    errorMessages.add('Unable to send email to Tech: '+ ex.getStackTraceString());
                }
            }
        }
    }  
    
    //Batch Finish method for after execution of batch work
    global void finish(Database.BatchableContext BC) { 
        
    }
    
    //Method which schedules the ProductDownloadBatch
    global void execute(SchedulableContext sc) {        
        Emailalertbatchclass snInstance = new Emailalertbatchclass();
        ID batchprocessid = Database.executeBatch(snInstance);
    }
}

my Test class
 
@isTest
public class EmailalertbatchclassTestclass
{
    static testMethod void testmethod1()
    {
        List<Lead> Leadld = new List<Lead>();
        lead ld = new lead();
        ld.FirstName= 'test';
        ld.LastName='Test2';
        ld.status='Enquiry';
        ld.Company = 'fgfh';
        ld.Email = 'Nilu112@gmail.com';
        ld.Manager_Email__c = 'rakeshkumar1998@gmail.com';
        ld.No_Enquiry_Email_Sent__c = true;
        Insert ld;
        Leadld.add(ld); 
        
        Test.startTest();
        ld.FirstName = 'test1';
        update ld;
        
        Emailalertbatchclass snInstance = new Emailalertbatchclass();
        ID batchprocessid = Database.executeBatch(snInstance);
        
        Test.stopTest();
    }
    public static testMethod void testschedule() {
        Test.StartTest();
        Emailalertbatchclass sh1 = new Emailalertbatchclass();
        String sch = '0 00 01 * * ?'; 
        ID batchprocessid = Database.executeBatch(sh1);
        String jobId = system.schedule('Emailalertbatchclass', sch, sh1);
        System.assert(jobId != null);
        Test.stopTest(); 
    }
}

 
Hey guys,
i am new to the apex development, i am trying to design a apex code 
where it should directly update emailoptout checkbox in lead and contact when unsubscribe link is clicked

i know there is an app exchange app called "Unsubscribe opt-out", i tried copying and modifying that code, when email comes
from my instance to my personal gmail, and when i click on unsubscribe link, unsubscribe email popup comes and i need to send another
mail and then emailoptout checkbox gets updated
 
Global class unsubscribe implements Messaging.inboundEmailHandler{

Global Messaging.InboundEmailResult handleInboundEmail(Messaging.InboundEmail email, 
                            Messaging.InboundEnvelope env ) {

// Create an inboundEmailResult object for returning 
//the result of the Apex Email Service
Messaging.InboundEmailResult result = new Messaging.InboundEmailResult();
 
// Contact and Lead lists to hold all the updated records
List<Contact> lc = new List <contact>();
List<Lead> ll = new List <lead>();
 
// Convert the subject line to lower case, so I can match on lower case
String mySubject = email.subject.toLowerCase();
// String I am searching for in the subject line
String s = 'unsubscribe';
 
// Check variable to see if the word "unsubscribe" was found in the subject line 
Boolean unsubMe;
// Look for the unsubcribe word in the subject line, 
// if it is found return true, otherwise false is returned
unsubMe = mySubject.contains(s);
 
 // If unsubscribe is found in the subject line enter the if statement
 
 if (unsubMe == true) {
    
    try {
        
    // Lookup all contacts with a matching email address
        
     for (Contact c : [Select Id, Name, Email, HasOptedOutOfEmail
                        From Contact
                        Where Email = :env.fromAddress
                        And hasOptedOutOfEmail = false
                        Limit 100]) {
                        
        // Add all the contacts into the List   
                            c.hasOptedOutOfEmail = true;
                            lc.add(c);                                 
    }    
        // update all the Contact records
        
        update lc;
            }
    catch (System.QueryException e) {
        System.debug('Contact Query Issue: ' + e);
        }   

    try {
        // Lookup all leads matching the email address
     for (Lead l : [Select Id, Name, Email, HasOptedOutOfEmail
                        From Lead
                        Where Email = :env.fromAddress
                        And isConverted = false
                        And hasOptedOutOfEmail = false
                        Limit 100]) {
        // Add all the leads to the List        
        l.hasOptedOutOfEmail = true;
        ll.add(l);
                               
           System.debug('Lead Object: ' + l);   
    }    
        // Update all Lead records in the query
        update ll;
            }

    catch (System.QueryException e) {
        System.debug('Lead Query Issue: ' + e);
        }   

    System.debug('Found the unsubscribe word in the subject line.');
 } 
 else {
    System.debug('No Unsuscribe word found in the subject line.' );
 }
// Return true and exit
// True will confirm it is complete and no bounced email 
// should be send the sender of the unsubscribe request. 
result.success = true;
return result;
    }   
    
    // Test method to ensure you have enough code coverage
    // Have created two methods, one that does the testing
    // with a valid "unsubcribe" in the subject line
    // and one the does not contain "unsubscribe" in the
    // subject line
    
static testMethod void testUnsubscribe() {

// Create a new email and envelope object
   Messaging.InboundEmail email = new Messaging.InboundEmail() ;
   Messaging.InboundEnvelope env    = new Messaging.InboundEnvelope();

// Create a new test Lead and insert it in the Test Method        
   Lead l = new lead(firstName='Rasmus', 
            lastName='Mencke',
            Company='Salesforce', 
            Email='rmencke@salesforce.com', 
            HasOptedOutOfEmail=false);
   insert l;

// Create a new test Contact and insert it in the Test Method  
   Contact c = new Contact(firstName='Rasmus', 
                lastName='Mencke', 
                Email='rmencke@salesforce.com', 
                HasOptedOutOfEmail=false);
   insert c;
   
   // test with subject that matches the unsubscribe statement
   email.subject = 'test unsubscribe test';
   env.fromAddress = 'rmencke@salesforce.com';
   
   // call the class and test it with the data in the testMethod
   unsubscribe unsubscribeObj = new unsubscribe();
   unsubscribeObj.handleInboundEmail(email, env );
                        
   }
 
static testMethod void testUnsubscribe2() {

// Create a new email and envelope object
   Messaging.InboundEmail email = new Messaging.InboundEmail();
   Messaging.InboundEnvelope env = new Messaging.InboundEnvelope();

// Create a new test Lead and insert it in the Test Method        
   Lead l = new lead(firstName='Rasmus', 
            lastName='Mencke',
            Company='Salesforce', 
            Email='rmencke@salesforce.com', 
            HasOptedOutOfEmail=false);
   insert l;

// Create a new test Contact and insert it in the Test Method    
   Contact c = new Contact(firstName='Rasmus', 
                lastName='Mencke', 
                Email='rmencke@salesforce.com', 
                HasOptedOutOfEmail=false);
   insert c;
   
   // Test with a subject that does Not contain unsubscribe
   email.subject = 'test';
   env.fromAddress = 'rmencke@salesforce.com';

   // call the class and test it with the data in the testMethod
   unsubscribe unsubscribeObj = new unsubscribe();
   unsubscribeObj.handleInboundEmail(email, env );                      
   }    
   
}

 
Hello Experts

I am new to the Visualforce, 
i am working on a requirement where live Location has to be tracked on the VF page Google maps Including Markers with help of Geolocation latitude and langitude which must be fetched from custom object (Contact_Check_In__c)

My Custom Object name is Contact_Check_In__c
 and i have fields called geolocation(GeoLocation__c)
With Lot of effort and searching i came accross vf page and apex controller, all is ok but it is not capturing the Live Geolocation

all i want is vf page has to take the dynamic geolocation from the record and show it on the google maps on vf page

i refered this blogs still not able to resolve my issue
https://developer.salesforce.com/forums?id=906F0000000AKp5IAG
https://success.salesforce.com/answers?id=90630000000guBkAAI

Any help would be highly appreciated

Below are my VF page
<apex:page StandardController="Contact_Check_In__c" extensions="MyCheckInController" lightningStylesheets="true" docType="HTML-5.0">

<html>
  <head>
   <title>Check In Detail</title>
   <style>
      /* Always set the map height explicitly to define the size of the div
       * element that contains the map. */
      #map {
        height: 90%;
      }
      /* Optional: Makes the sample page fill the window. */
      html, body {
        height: 90%;
        margin: 0;
        padding: 0;
      }
    </style>
  </head>

  <body onload = "loadMap()">
    <h2>Check In on the Map</h2>
    <div id = "map" ></div>
      <script>

        
        function loadMap() {
          // Initialize Google Maps
          const mapOptions = {
            center:new google.maps.LatLng(13.0161331,76.0898104),
            zoom: 13
          }
          const map = new google.maps.Map(document.getElementById("map"), mapOptions);
          
          var text = '{!JsonCheckInData}';
          var iconBase = 'https://maps.google.com/mapfiles/kml/shapes/';
            var icons = {
              parking: {
                icon: iconBase + 'parking_lot_maps.png'
              },
              library: {
                icon: iconBase + 'library_maps.png'
              },
              info: {
                icon: iconBase + 'info-i_maps.png'
              }
            };
            
          var obj = JSON.parse(text);
          //alert(obj);
          //return obj;
          var x;
          var jsonData='';
          var loc1='';
          var loc2;
          var address='';
          for (x in obj) {
           
            temp=obj[x].location.split(",");
            loc1=temp[0].replace("[", "");
            loc2=temp[1].replace("]", "");
            
                                   
            let marker = new google.maps.Marker({
              map: map,
              icon:icons['library'].icon,
              position: new google.maps.LatLng(loc1, loc2),
              title: 'Person Name:' +  obj[x].name + ' CheckIn:' +obj[x].checkIn 
            })
            
            
          } 
        
        }
      </script>
      <!--<script src = "https://maps.googleapis.com/maps/api/js"></script>-->
     <script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyBqqej11sosokXGaQTk_-Zw9AIXMVkXoAE&callback=loadMap">
    </script>
    {!JsonCheckInData}
  </body>
</html>
</apex:page>

My Controller
 
public class MyCheckInController {

    public MyCheckInController(ApexPages.StandardController controller) {

    }


    public list<Contact_Check_In__c> LstContactCheckIn{get;set;}
    
    public string JsonCheckInData{get;set;}

    public MyCheckInController(){
        
        LstContactCheckIn=[Select Id, CheckIn_Date_Time__c, GeoLocation__latitude__s, GeoLocation__longitude__s, Contact__r.Name from Contact_Check_In__c];
        
        list<WrpData> lstWrpData=new list<WrpData>();
        
        for(Contact_Check_In__c Check:LstContactCheckIn){
               string strLocation='[' + string.valueOf(check.GeoLocation__latitude__s) + ','  + string.valueOf(check.GeoLocation__longitude__s)+ ']';
               WrpData wrp=new WrpData(check.Contact__r.Name, strLocation, string.ValueOf(check.CheckIn_Date_Time__c),string.valueOf(check.GeoLocation__latitude__s),string.valueOf(check.GeoLocation__longitude__s));
               lstWrpData.add(wrp);
        }
        
        JsonCheckInData=Json.Serialize(lstWrpData);
        
    }
    
    public class WrpData{
        
        public string name{get;set;}
        public string location{get;set;}
        public string checkIn{get;set;}
        public string lat{get;set;}
        public string lng{get;set;}
        public WrpData(string nm,string loc,string chkIn, string lt,string ln){
            name=nm;
            location=loc;
            checkIn=chkIn;
            lat=lt;
            lng=ln;
        }
    }
   
}

​​​​​​​

 
Hello Developers

i am trying to design a Test class for the Apex class but i am not able to do the code coverage of the following apex class, can anyone please help
 
public class FutureHandler {
    
    @future
    public static void updaterecs(Map<String,Id> oldManagerQuotaMap1){
        Map<Id,Quota__c> oldMapQuota = new Map<Id,Quota__c>();
        if(null != oldManagerQuotaMap1 && oldManagerQuotaMap1.size() > 0){
            for (aggregateResult result: [Select Manager_Quota__c, Sum(Inside_Sales_Roll_Up__c) 
                                          FROM Quota__c WHERE 
                                          Manager_Quota__c IN: oldManagerQuotaMap1.values() 
                                          GROUP BY Manager_Quota__c]) {
                                              system.debug('result'+result)    ;          
                                              oldMapQuota.put((Id)result.get('Manager_Quota__c'),new Quota__c(Id=(Id)result.get('Manager_Quota__c'),Actual_Amount__c =(Decimal)result.get('expr0')));         
                                          }
            
            for(Id qId : oldManagerQuotaMap1.values()){
                if(!oldMapQuota.containskey(qId)){
                    oldMapQuota.put(qId, new Quota__c(Id = qId,Actual_Amount__c = 0.0));
                }
            }
            
            if(null != oldMapQuota && oldMapQuota.size() > 0){
                update oldMapQuota.values();
            }
            
        }
    }

    public static void sendOppsForApproval(List<Opportunity> opps){
        
        List<Opportunity> oppsToBeSentForApproval = new List<Opportunity>();
        String monthYear = System.now().format('MMMM-yyyy');
        String month = monthYear.split('-')[0];
        String year = monthYear.split('-')[1];
        Date nextMonthStart = System.today().toStartOfMonth().addMonths(1).toStartOfMonth();
        List<Aggregate_Approval__c> appr = [Select Id from Aggregate_Approval__c where Month__c=:month And Year__c=:year]; 
        Id approvalId;
        if(appr.size()>0){
            approvalId = appr[0].Id;
            
            for(Opportunity opp : opps){
                opp.Aggregate_Approval__c = approvalId;
                opp.Status__c = 'In Approval';
                oppsToBeSentForApproval.add(opp);
            }
            update oppsToBeSentForApproval;
           // List<Approval.LockResult> li = Approval.lock(opps);
            
            Approval.ProcessSubmitRequest oppAggregateApproval = new Approval.ProcessSubmitRequest();
            oppAggregateApproval.setComments('Submitting opportunities for Approval for '+System.now().format('MMMM-yyyy'));
            oppAggregateApproval.setObjectId(approvalId);
            Approval.ProcessResult approvalResult = Approval.process(oppAggregateApproval); 
            
        } 
    }
}
My Test Class
 
@isTest
public class FutureHandlerTestclass {
    
    static testmethod void Futuretest(){
        
        List<Quota__c> Ftur = new list <Quota__c>();
        Quota__c FF = new Quota__c();
        FF.Name='Julian';
        FF.Assigned_To__c = userinfo.getUserId();
        FF.Month__c='March';  
        FF.Quater__c='Q1';       
        FF.Quater_Year__c = '2020';
        FF.Actual_Amount__c = 100;
        FF.Unique_Identifier_Per_Quater_Per_User__c = 'Hello';
        Ftur.add(FF);
        insert FF;
        
        
        Quota__c FF1 = new Quota__c();
        FF1.Name='rahul';
        FF1.Assigned_To__c = userinfo.getUserId();
        FF1.Month__c='October';  
        FF1.Quater__c='Q4';       
        FF1.Quater_Year__c = '2030';
        FF.Actual_Amount__c = 200;
        FF1.Unique_Identifier_Per_Quater_Per_User__c = 'Helloworld';
        Ftur.add(FF1);
        insert FF1;
        
        Account testAcct = new Account (Name = 'My Test Account');
        insert testAcct;
        
        User u = [Select id,name from user where isactive=true Limit 1];
        
        List<Opportunity> Oppps = new list <Opportunity>(); 
        Opportunity oop = new Opportunity();
        
        oop.Name = 'Test1';
        oop.AccountId = testAcct.ID;
        oop.StageName = 'Demo';
        oop.CloseDate = system.today();
        oop.Billing_To_Be_Initiated__c = 'Yes';
        oop.LeadSource = 'Customer';
        oop.Country__c = 'India';        
        Oppps.add(oop);
        insert oop;
    }
    }