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
bathybathy 

Custom Button in salesforce1

Hi Guys,

I have a custom with Javascript as below. I want to add this button to salesforce1 but because salesforce1 doesn't support custom button i am unable to do that. After investigation, I found out we can do this using publisher actions. Can anyone give an idea how to proceed on this? I have posted the code here for your reference.

Thanks,
{!REQUIRESCRIPT("/soap/ajax/20.0/connection.js")} 

var crecord = []; 

var l = new sforce.SObject("Lead"); 

var c = new sforce.SObject("sf4twitter__Twitter_Conversation__c"); 

c.id = "{!sf4twitter__Twitter_Conversation__c.Id}"; 

var cm = new sforce.SObject("CampaignMember"); 


l.lastName = "{!sf4twitter__Twitter_Conversation__c.sf4twitter__Author_Real_Name__c}"; 

l.Facebook_Private_Message__c = "{!sf4twitter__Twitter_Conversation__c.sf4twitter__Message__c}"; 



l.RecordTypeId = "01290000001An45"; 

l.Database_name__c = "Facebook"; 

l.leadsource = "Facebook"; 

l.Company = "Facebook"; 

l.Assigned_to_caller__c = "Jordan Meates"; 

l.OwnerId = "00590000001B9wH"; 

var result = sforce.connection.create([l]); 

cm.CampaignId = "70190000000reFr"; 

cm.leadid = result[0].id; 

var result2 = sforce.connection.create([cm]); 

var NewlID = result[0].id; 

c.sf4twitter__Lead__c = NewlID; 

c.RecordTypeId = "01290000000ubYI"; 

crecord.push(c); 

result3 = sforce.connection.update(crecord); 



if(result[0].getBoolean("success")){ 
window.location = "/" + result[0].id ; 
}else{ 
alert('Could not create record '+result); 
}

 
Himanshu MaheshwariHimanshu Maheshwari
Hi Bathy,

You cannot use javascript in publisher actions. You can use the custon VF page to do the above task.