You need to sign in to do that
Don't have an account?
sandy18031985
Custom Button Salesforce1
Hello Everyone,
i have a custom button in my custom object where i am calling a java script. what it does is i gets the values and updates the custom field in the object.
this working perfect in my laptop but in salesforce1 i cant see the custombutton. what i had read in documnets is that custom buttons are not supported in salesforce1.
i should use a publisher actions only for salesforce1. can any one please tell me how to use this in actions :
{!REQUIRESCRIPT ("/soap/ajax/34.0/connection.js")}
if (navigator.geolocation) {
var setPosition = function (position) {
var visitId = "{!Visitas__c.Id}";
var userId = "{!$User.Id}";
//console.log("Latitude: " + position.coords.latitude + "\nLongitude: " + position.coords.longitude);
var visit = new sforce.SObject("Visitas__c");
visit.set("Id", visitId);
visit.set("Local_do_Check_In__Latitude__s", position.coords.latitude );
visit.set("Local_do_Check_In__Longitude__s", position.coords.longitude );
visit.set("Data_e_Horario_de_Check_In__c", new Date().toISOString() );
var result = sforce.connection.update([visit]);
if (result[0].getBoolean("success") == false) {
alert("Erro ao atualizar os dados da visita.");
}
else {
function redirect() { parent.frames.location.replace("/{!Visitas__c.Id}"); }
redirect();
window.close();
}
};
navigator.geolocation.getCurrentPosition(setPosition);
} else {
alert("Este navegador não suporta geolocalização.");
}
how can i use this in publisher actions.
Thanks in advance
i have a custom button in my custom object where i am calling a java script. what it does is i gets the values and updates the custom field in the object.
this working perfect in my laptop but in salesforce1 i cant see the custombutton. what i had read in documnets is that custom buttons are not supported in salesforce1.
i should use a publisher actions only for salesforce1. can any one please tell me how to use this in actions :
{!REQUIRESCRIPT ("/soap/ajax/34.0/connection.js")}
if (navigator.geolocation) {
var setPosition = function (position) {
var visitId = "{!Visitas__c.Id}";
var userId = "{!$User.Id}";
//console.log("Latitude: " + position.coords.latitude + "\nLongitude: " + position.coords.longitude);
var visit = new sforce.SObject("Visitas__c");
visit.set("Id", visitId);
visit.set("Local_do_Check_In__Latitude__s", position.coords.latitude );
visit.set("Local_do_Check_In__Longitude__s", position.coords.longitude );
visit.set("Data_e_Horario_de_Check_In__c", new Date().toISOString() );
var result = sforce.connection.update([visit]);
if (result[0].getBoolean("success") == false) {
alert("Erro ao atualizar os dados da visita.");
}
else {
function redirect() { parent.frames.location.replace("/{!Visitas__c.Id}"); }
redirect();
window.close();
}
};
navigator.geolocation.getCurrentPosition(setPosition);
} else {
alert("Este navegador não suporta geolocalização.");
}
how can i use this in publisher actions.
Thanks in advance
You have to move your javascript in visualforce page and use this visual force page for custom button.
This way, the custom button will be available in Salesforce1 but take care that your visualforce page has "Available for Salesforce mobile apps"
option enabled.
e.g. start with something like:
You will need to require your script differently as in this example shown in the AJAX Toolkit Developer's Guide (https://developer.salesforce.com/docs/atlas.en-us.ajax.meta/ajax/sforce_api_ajax_vf_sample.htm): Then you will need to wrap all this JavaScript in script tags: I can not guarantee if you will need any other changes in your JavaScript without testing it out, but the merge fields should work the same since this action is launched from a specific record.
Finally you need to create an action under Objects > Your custom object > Buttons, Links, and Actions, and set the new action source to use this Visualforce page.