+ Start a Discussion
Irish@accIrish@acc 

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/connection.js")}

{!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.");

}

else{

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.Number_of_Change_Requests__c=0;

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

createqod.Dev_Lead__c="{!Project__c.Dev_Lead_UserId__c}"

sforce.connection.create([createqod]);

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");

 

 

 

 

}

BillB6416BillB6416

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.