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
Jim McCabeJim McCabe 

Security to prevent button from being pushed

Hello.  I am not a developer.  The following Java Script pushes contacts from SF into Marketo Campaigns.  Unfotunately it would have to be displayed on all Contact List views.  Does anyone know how I can limit the functionality of this button to specific people?  For example I would want only these two users to be able to push it.  The script is below

User ID = 00560000001VtiU
User ID =00560000001W0HL

function post_to_url(path, params, method) {
method = method || "post";
var form = document.createElement("form");
form.setAttribute("method", method);
form.setAttribute("action", path);

for(var key in params) {
if(params.hasOwnProperty(key)) {
var hiddenField = document.createElement("input");
hiddenField.setAttribute("type", "hidden");
hiddenField.setAttribute("name", String(key));
hiddenField.setAttribute("value", String(params[key]));
form.appendChild(hiddenField);
}
}
document.body.appendChild(form);
form.submit();
}

function build_action_path(actionName) {
var hostname = window.location.hostname;
var server = 'na1';
if (hostname.indexOf(".salesforce.com") != -1){
server = hostname.substring(0,hostname.indexOf(".salesforce.com") );
} else if (hostname.indexOf(".force.com") != -1){
server = hostname.substring(0,hostname.indexOf(".force.com") );
}
return "https://mkto-si." + server + ".visual.force.com/apex/" + actionName;
}

var idArray = {!GETRECORDIDS($ObjectType.Contact)};
if (idArray[0] == null){
alert('Please select at least one row');
} else {
var path = build_action_path("mkto_si__Add_to_Marketo_Campaign");
var method = 'post';
var params = {};
params['contactType'] = 'Contact';
params['contactIds'] = idArray;
params['retUrl'] = encodeURIComponent(document.location.href);
post_to_url(path, params, method);
}
Eric BollerEric Boller
You should be able to ues page layouts to limit who can see the button based on roles.