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

custom button not working for other profile

Below is the code which creates the related child object it works fine for sys admin but doesn't work for other profile



{!REQUIRESCRIPT("/soap/ajax/27.0/apex.js")} var url = parent.location.href;

var prjid='{!Project__c.Id}';

var TaskId='{!Task__c.Id}';

result = sforce.connection.query("Select Status__c,Project__c from Task__c where Status__c not in ('Complete','Cancelled') and Project__c='"+prjid +"'");


var records = result.getArray("records");

var date = new Date('{!TODAY()}');

var i = records.length; if(i>0) 

  {     parent.location.href = url; 

   window.alert("All Tasks need to be completed before the project can be closed.");



var createqod = new sforce.SObject("Quality_of_delivery__c");

createqod.Project__c = "{!Project__c.Id}";

createqod.Name = "{!Project__c.Name} ";

createqod.Approved_Status__c="Pending input from Dev Specialist";


createqod.date__c=date; createqod.Final__c="True";



parent.location.href = url; window.alert("A final Quality of Delivery record has been created for the project. It needs to be updated and approved by Dev Lead - only then the project will be closed");







I am certainly no JavaScript expert, but after recently running into a similar problem (and you may have already checked this) you might want to check the field level security setting for any fields that will be updated or inserted via your JavaScript routine.


In my particular experience I found that our custom button using on-click JavaScript was trying to make updates to various custom fields and the targeted user profile did not have these fields setup as 'visible' in the field level security settings.