function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
sawaji varunsawaji varun 

custom button not displayed on mobile

Hi, I have created a custom button 'Checkin' on opportunity and below is the javascript for this. on cllick of the button, its creating a task under opportunity by saving checkin logtitude latitude.

{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")} 

var tsk = new sforce.SObject('Task'); 


tsk.WhatId = '{!Opportunity.Id}'; 
tsk.subject = 'Subject1'; 

if(navigator.geolocation){ 
//browser support geolocation 
navigator.geolocation.getCurrentPosition(callbackSuccess, callbackError,{enableHighAccuracy:true,timeout:3000}); 

}else{ 
alert('Navigation is not supported'); 


function callbackSuccess(position) { 

//get latitude and longitude 
var lat = position.coords.latitude; 
var lon = position.coords.longitude; 

tsk.Checkin_Geolocation__Latitude__s=lat; 
tsk.Checkin_Geolocation__Longitude__s=lon; 
sforce.connection.create([tsk]); 

window.location.reload(); 


function callbackError(error) { 
switch(error.code) { 
case error.UNKNOWN_ERROR: 
alert("UNKNOWN_ERROR."); 
break; 
case error.PERMISSION_DENIED: 
alert("PERMISSION_DENIED."); 
break; 
case error.POSITION_UNAVAILABLE: 
alert("POSITION_UNAVAILABLE."); 
break; 
case error.TIMEOUT: 
alert("TIMEOUT."); 
break; 

}


I am unable to see this button in salesforce1 app in mobile. Any solution for this.? Alternatively, how can we write this in visualforce page.
Yury BondarauYury Bondarau

Hi Sawaji,

Cusotm javascript buttons are not supported in lightnign, please read more details in documentation - https://help.salesforce.com/HTViewHelpDoc?id=links_considerations.htm&language=en_US

You can create visualforce page and put this logic to apex controller. Then you will be able to add visualforce page as a Publisher Action that is displayed in SF1

Deepak Raj 34Deepak Raj 34
Hi Swami,

need your small help  on this.as i am new to salesforce could you please help me .please call me on 8689960849 or email me on draj25m@gmail.com.

Regards
Deepak Rak