• BillB6416
  • NEWBIE
  • 5 Points
  • Member since 2012

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies

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

 

 

 

 

}