• Gautam Manchanda 12
  • 5 Points
  • Member since 2018

  • Chatter
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
  • 5
Hi All,

I am having a trouble while trying to get my Geolocation through Salesforce1 app. It works fine while trying to access the same in mobile browser but it fails to load the position when I try the same thing through the app. navigator.geolocation.getCurrentPosition(success) returns me Undefined.

Any help will be greatly appreciated!


I am also facing quite similar issue. I am sending emails using the below code:

for(Payment__c pay : lstOfPaymentsToProcess) {
      EmailMessage emailMsg = new EmailMessage();
      DateTime dt = null;
      String approvalDate = '';
      if((mapOfOppIdAndOpp.get(pay.CSAF_Number__c).Approval_Date__c)!= null) {
       approvalDate = Date.newInstance((mapOfOppIdAndOpp.get(pay.CSAF_Number__c).Approval_Date__c).year(), (mapOfOppIdAndOpp.get(pay.CSAF_Number__c).Approval_Date__c).month(), (mapOfOppIdAndOpp.get(pay.CSAF_Number__c).Approval_Date__c).day()).format();
      dt = pay.Date__c;
      Date payDate = Date.valueOf(dt);
      String[] ccAddresses = new String[]{'Fffinance@hindustantimes.com',mapOfOppIdAndOpp.get(pay.CSAF_Number__c).Owner.Email};
      string emailHtmlBody = 'Hi All';
      Messaging.SingleEmailMessage singleEmailMsg = new Messaging.SingleEmailMessage();
      singleEmailMsg.setSubject('Cheque bounced against ' + mapOfOppIdAndOpp.get(pay.CSAF_Number__c).CSAF_No__c);

All works good some times but some times it fails to send emails. Now this is a big issue for me to debug for the client as this is an intermittent issue and is not being reported daily. What can be the possible cause of it and any suggestions to resolve this would be of great help!

​Thanks in Advance!
Hi ,

i am getting error from managed package apex trigger. So i am uanble to save my record. How to stop the trigger form managed package


I have following error:
System.CalloutException: You have uncommitted work pending. Please commit or rollback before calling out

My usecase:
I am calling a webservice in a future handler. 

Other workaround i tried:
I tried to call the webservice without a future handler, but as i am calling in trigger it is giving me error.

Can someone please tell me any workaroud ?

thank you
<apex:page sidebar="false" showheader="false" standardController="Account" extensions="FindNearbyAcctExt">
    <!-- Uncomment the line below, and include your Google's Maps API key in the script link -->
<apex:includeScript value="https://maps.googleapis.com/maps/api/js?key=AIzaSyDBi-pMAogoA7oz7NE_vA3WMdZAAC6d3VA&sensor=false" />
    <!-- Setup the map to take up the whole window -->
        html, body { height: 100%; }
        .page-map, .ui-content, #map-canvas { width: 100%; height:100%; padding: 0; }
        #map-canvas { height: min-height: 100%; }
        function initialize() {
            var lat, lon, work;
              work = "Worked";
             // Check to see if the device has geolocation
             // detection capabilities with JavaScript
             if (navigator.geolocation) {
                     lat = position.coords.latitude;
                     lon = position.coords.longitude;                    
                     // Use VF Remoting to send values to be
                     // queried in the associated Apex Class
                     Visualforce.remoting.Manager.invokeAction('{!$RemoteAction.FindNearbyAcctExt.getNearby}', lat, lon,
                         function(result, event){
                             if (event.status) {
                                 createMap(lat, lon, result);           
                             } else if (event.type === 'exception') {
                                 //exception case code          
                             } else {
                          {escape: true}
              } else {
                  // Set default values for map if the device doesnt
                  // have geolocation capabilities
                    /** San Francisco **/
                    lat = 37.77493;
                    lon = -122.419416;
                    var result = [];
                    createMap(lat, lon, result);
            function createMap(lat, lon, warehouses){
                // Get the map div, and center the map at the proper geolocation
                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,
                    icon: 'http://maps.google.com/mapfiles/ms/micons/green.png'
                // Keep track of the map boundary that holds all markers
                var mapBoundary = new google.maps.LatLngBounds();
                // Set markers on the map from the @RemoteAction results
                var warehouse;
                for(var i=0; i<warehouses.length;i++){
                    warehouse = warehouses[i];
                // Resize map to neatly fit all of the markers

               function setupMarker(){
                    var warehouseNavUrl;
                    // Determine if we are in Salesforce1 and set navigation link appropriately
                            if( (typeof sforce != 'undefined') && (sforce != null) ){
                                //Salesforce1 Navigation
                                warehouseNavUrl = 'javascript:sforce.one.navigateToSObject(\'' + warehouse.Id + '\')';
                            } else {
                                //Set the windows URL using a VF expression
                                warehouseNavUrl =  '//'+ warehouse.Id;

                    var warehouseDetails =
                        '<a href="/!{warehouse.Id}">' +
                        warehouse.Name + '</a><br/>' +
                        warehouse.BillingStreet + '<br/>' +
                        warehouse.BillingCity + '<br/>' +
                   // Create the callout that will pop up on the marker     
                   var infowindow = new google.maps.InfoWindow({
                       content: warehouseDetails
                   // Place the marker on the map   
                   var marker = new google.maps.Marker({
                       map: map,
                       position: new google.maps.LatLng(
                   // Add the action to open up the panel when its marker is clicked      
                   google.maps.event.addListener(marker, 'click', function(){
                       infowindow.open(map, marker);

         // Fire the initialize function when the window loads
         google.maps.event.addDomListener(window, 'load', initialize);

    <!--  All content is rendered by the Google Maps code -->
    <!--  This minimal HTML justs provide a target for GMaps to write to -->
    <body style="font-family: Arial; border: 0 none;">
        <div id="map-canvas"></div>

It appears blank in Salesforce1 and doesn't even prompt for use of Location Services. It works perfect on desktop. Is the method for geolocation different on desktop and sf1?

Fixed issues of overall blank it was spacing issues.
The class for it is as follows:
global with sharing class FindNearbyAcctExt {

    public FindNearbyAcctExt(ApexPages.StandardController controller) {


    public FindNearbyAcctExt (ApexPages.StandardSetController controller) { }

    // Find warehouses nearest a geolocation
    global static List<Account> getNearby(String lat, String lon) {

        // If geolocation isn't set, use San Francisco
        if(lat == null || lon == null || lat.equals('') || lon.equals('')) {
            lat = '37.77493';
            lon = '-122.419416';

        // SOQL query to get the nearest warehouses
        String queryString =
           'SELECT Id, Name, Location__Longitude__s, Location__Latitude__s, ' +
            'BillingStreet, Phone, BillingCity ' +
            'FROM Account ' +
            'WHERE DISTANCE(Location__c, GEOLOCATION('+lat+','+lon+'), \'mi\') < 20 ' +
            'ORDER BY DISTANCE(Location__c, GEOLOCATION('+lat+','+lon+'), \'mi\') ' +
            'LIMIT 10';

        // Run and return the query results

Here is the Salesforce1 App debug log. The error in it.  I am just so confused why it won't run in SF1.  It works 100% perfect on desktop but not on sf1 and I really need it to.  Thanks
2015/01/22 19:40:49:239 INFO|LoginWorkflow|Suspended => Resuming for [DidBecomeActive,EulaAccepted,LoggedIn,HasOrgSettings,!PasscodeNeeded,CreateUserInterface,PasscodeValid,BrandingReady,UserInterfaceReady,WillEnterForeground,!RevokeLogin,!LoginScreenNeeded] 2015/01/22 19:40:49:248 INFO|SFAnalytics|Localytics Tagging Event: App Launch Attributes: { Build = 3002938; "External App" = "Direct Launch"; Method = Direct; Target = "Default Screen"; Type = "N/A"; Version = "7.0.1"; } 2015/01/22 19:40:49:264 INFO|SFOfflineManager|SFOfflineManager is 1 2015/01/22 19:40:49:331 INFO|SFAnalytics|Localytics Tagging Screen: Settings 2015/01/22 19:40:49:340 INFO|CHActionExecuter|Submit action GET /services/data/v31.0/connect/notifications/status 2015/01/22 19:40:49:340 INFO|CHActionExecuter|Submit action GET /services/data/v31.0/connect/notifications/status 2015/01/22 19:40:49:341 INFO|CHActionExecuter|Submit action GET /services/data/v31.0/connect/notifications/status 2015/01/22 19:40:49:349 INFO|CHActionExecuter|Submit action GET /services/data/v31.0/connect/notifications/status 2015/01/22 19:40:49:354 INFO|LoginWorkflow|Resuming => BeginOAuth for [DidBecomeActive,EulaAccepted,LoggedIn,HasOrgSettings,!PasscodeNeeded,CreateUserInterface,PasscodeValid,BrandingReady,UserInterfaceReady,WillEnterForeground,!RevokeLogin,!LoginScreenNeeded] 2015/01/22 19:40:49:393 INFO|LoginWorkflow|BeginOAuth => PostLogin for [DidBecomeActive,EulaAccepted,LoggedIn,HasOrgSettings,!PasscodeNeeded,CreateUserInterface,PasscodeValid,BrandingReady,UserInterfaceReady,WillEnterForeground,!RevokeLogin,!LoginScreenNeeded] 2015/01/22 19:40:49:394 INFO|PNManager|registering with Apple for remote push notifications 2015/01/22 19:40:49:441 INFO|SFOfflineManager|SFOfflineManager is 1 2015/01/22 19:40:49:461 INFO|PSPublisher|Publisher is ENABLED 2015/01/22 19:40:49:508 INFO|CHActionExecuter|Submit action GET /services/data/v31.0/chatter/users/005j000000BSJMH 2015/01/22 19:40:49:508 INFO|CHActionExecuter|Submit action GET /services/data/v31.0/connect/organization 2015/01/22 19:40:49:510 INFO|CHActionExecuter|Submit action GET /services/data/v32.0/sobjects/Global/describe/layouts/ 2015/01/22 19:40:49:511 INFO|CHActionExecuter|Submit action GET /services/data/v31.0/chatter/feeds 2015/01/22 19:40:49:512 INFO|CHActionExecuter|Submit action GET /services/data/v31.0/connect/communities 2015/01/22 19:40:49:540 INFO|LoginWorkflow|PostLogin => AppReady for [DidBecomeActive,EulaAccepted,LoggedIn,HasOrgSettings,!PasscodeNeeded,CreateUserInterface,PasscodeValid,BrandingReady,UserInterfaceReady,WillEnterForeground,!RevokeLogin,!LoginScreenNeeded] 2015/01/22 19:40:49:544 INFO|CHActionExecuter|Submit action POST /services/data/v31.0/sobjects/MobilePushServiceDevice 2015/01/22 19:40:49:558 INFO|LoginWorkflow|AppReady => BrandingReady for [DidBecomeActive,EulaAccepted,LoggedIn,HasOrgSettings,!PasscodeNeeded,CreateUserInterface,PasscodeValid,BrandingReady,UserInterfaceReady,WillEnterForeground,!RevokeLogin,!LoginScreenNeeded] 2015/01/22 19:40:49:734 INFO|LoginWorkflow|BrandingReady => AppUIReady for [DidBecomeActive,EulaAccepted,LoggedIn,HasOrgSettings,!PasscodeNeeded,CreateUserInterface,PasscodeValid,BrandingReady,UserInterfaceReady,WillEnterForeground,!RevokeLogin,!LoginScreenNeeded] **2015/01/22 19:40:49:885 ERROR|SFNetworkOperation|Operation failed to perform GET "https://na16.salesforce.com/services/data/v31.0/sobjects/Network/describe": The requested resource does not exist 2015/01/22 19:40:49:891 ERROR|SFDefaultMetadataManager|failed to get get object information for Network, [The requested resource does not exist] 2015/01/22 19:40:49:893 ERROR|SFDefaultMetadataManager|unable to load the Network object because Error Domain=NSURLErrorDomain Code=404 "The requested resource does not exist" UserInfo=0x1b989260 {NSLocalizedFailureReason=NOT_FOUND, NSLocalizedDescription=The requested resource does not exist}

** 2015/01/22 19:40:50:216 INFO|SFOfflineManager|SFOfflineManager is 1 2015/01/22 19:40:50:245 INFO|SFOfflineManager|SFOfflineManager is 1 2015/01/22 19:40:50:251 INFO|CHActionExecuter|Submit action GET /services/data/v31.0/connect/notifications/status 2015/01/22 19:40:50:252 INFO|CHActionExecuter|Submit action GET /services/data/v31.0/connect/notifications/status 2015/01/22 19:40:50:827 INFO|PSPublisher|Quick actions from the server didn't change since last time 2015/01/22 19:40:51:563 INFO|CHActionExecuter|Submit action GET /services/data/v31.0/connect/notifications/status

I have a VF page that's a simple proof of concept to get geolocation. The page is accessible through Salesforce1. The javascript on the page, makes a call to navigator.geolocation.getCurrentPosition and shows the location on the page. The page works correctly on desktop but through salesforce1, the geolocation.getCurrentPosition doesn't go go to success or error function handlers. I added javascript alerts to try to debug the problem. When viewing the page through salesforce1 I see the alert message "geolocation enabled" that I added in the if (navigator.geolocation) but none of the alerts from the success handler or the error handler show up! (Below is my VF page code)

What am I doing wrong?

Thank you. 
<apex:page controller="testController" doctype="html-5.0">
   <label id='test'>No geo-location</label>
   <script type="text/javascript">
    //error handler
    function showError(error) {
    alert('in error');
    var testElem = document.getElementById("test");
    var strError = "Unknown Error";
    switch(error.code) {
        case error.PERMISSION_DENIED:
            strError = "User denied the request for Geolocation."
        case error.POSITION_UNAVAILABLE:
            strError = "Location information is unavailable."
        case error.TIMEOUT:
            strError = "The request to get user location timed out."
        case error.UNKNOWN_ERROR:
            strError = "An unknown error occurred."
    testElem.innerText = strError;
    //success handler
    function successGeo(position){
            lat = position.coords.latitude;
            lon = position.coords.longitude;
            var testElem = document.getElementById("test");
            var strLatLong = 'lat: ' + lat.toString() + ', long:' + lon.toString();
            alert('Location: ' + strLatLong);
            testElem.innerText  = strLatLong;
    // detection capabilities with JavaScript
    if (navigator.geolocation) {
        var testElem = document.getElementById("test");
        testElem.innerText = 'getting geo location!';
        alert('geolocation enabled1');
        navigator.geolocation.getCurrentPosition(successGeo, showError);

  • December 13, 2014
  • Like
  • 0

There's been a change in the Salesforce API that causes emails to not be sent when there are spaces around the email address string.


(Debug log message shown below)

This string of email addresses resulted in Email not sent -- ccAddresses: [tsailing.test1@gmail.com,  tsailing.test2@gmail.com,  tsailing.test3@gmail.com]

This string of email addresses resulted in Email sent -- ccAddresses: [tsailing.test1@gmail.com,tsailing.test2@gmail.com,tsailing.test3@gmail.com]


The main issue is that there will be NO ERRORS RETURNED OR DISPLAYED to inform users that their emails were not sent. In fact, the system WILL RETURN A SUCCESS MESSAGE.


Here's the debug message received -- (Messaging.SendEmailResult[getErrors=();isSuccess=true;])


This is NOT an acceptable API behavior.



Sample code used --

Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage(); 

    String toRecipients = 'tsailing.test1@gmail.com';
    String[] toAddresses = toRecipients.split(';', 0);
    email.setToAddresses( toAddresses );
    System.debug('------------------- 7/1/2012: toAddresses: '+toAddresses);

String ccRecipients = 'tsailing.test2@gmail.com,  tsailing.test3@gmail.com,  tsailing.test4@hotmail.com';
    String[] ccAddresses = ccRecipients.split(',', 0); //switched this to "ccRecipients.split(', ', 0)" resolved the issue.
    System.debug('------------------- 7/1/2012: ccAddresses: '+ccAddresses);
try {
} catch (Exception e) {
System.debug('------------------- 7/1/2012: e: '+e);

Messaging.SendEmailResult [] r = 
Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});   
System.debug('------------------- 7/1/2012: r: '+r);