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
DannyTKDannyTK 

How to add a Profile restriction to Javascript button

Good morning, 

I have an easy one for someone to answer (easy for a developer, not for me), 

I created a Javascript button to update the Status field on a Custom Object (Sales Order), but only want specific profiles to be able to click this button: the javascript for the button to update works fine, but I'm not sure how to add a line to make it execute only for specific profile(s):

{!requireScript("/soap/ajax/29.0/connection.js")}
var sor = new sforce.SObject("Sales_Order__c");

sor.Id = "{!Sales_Order__c.Id}";

sor.Status__c = "Sales Order Completion";
var result = sforce.connection.update([sor]);
window.location.reload();


Can somebody guide me on how to add a line to allow for only specific profiles (or to restrict certain profiles)
AmitAmit (Salesforce Developers) 
Hello,

You will have to use different page layout with button and then assign those layouts to the profiles.

More information can be found at following link :

http://help.salesforce.com/apex/HTViewSolution?id=000002488&language=en_US

http://help.salesforce.com/HTViewHelpDoc?id=customize_layoutoverview.htm&language=en_US

http://help.salesforce.com/HTViewHelpDoc?id=customize_layoutassign.htm&language=en_US

Thanks,
Amit Bhardwaj