I've a object, custom button and two check box field on it.
The custom button which is updating the check box field to true.
from custom button java script code i'm calling apex class, after execution of apex class it should update the check box field on same object.
This is perfect working for system admin user,
but when i tried for non admin user it will not updating the checkbox to true but apex class is correct executing in this case
The check box field is read only from field accessibility for all profile.
why it is not updating for non admin user?
Code is.
{!REQUIRESCRIPT("/soap/ajax/19.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/19.0/apex.js")}
if("{!Patient_Services__c.Service_Invoiced__c}"== "0" ||
"{!Patient_Services__c.Service_Invoiced__c}"== "1" && " {!$Profile.Name}"=="System Administrator")
{
if("{!Patient_Services__c.Ready_for_Billing__c}" == "0" && "{!Patient_Services__c.Who_to_Invoice__c}" == '' )
{
alert('Please Select the Who To Invoice');
}
else
if("{!Patient_Services__c.Ready_for_Billing__c}" == "0" && "{!Patient_Services__c.Who_to_Invoice__c}" != "null" )
{
if("{!Patient_Services__c.Added_to_Opty__c}"== "0" && ("{!Patient_Services__c.Who_to_Invoice__c}"=="Medicare Account" || "{!Patient_Services__c.Who_to_Invoice__c}"=="DVA Account"))
{
var r = confirm("Opportunity will now be created;\nDo you want to proceed?");
if(r == true)
{
//alert("Opportunity now Created");
var a= sforce.apex.execute("CreateOpty","CreateOptywithps",{Id :"{!Patient_Services__c.Id}"});
// alert(a);
if(a>0)
alert("Opportunity created Successfully for Medicare/DVA Account..!\nFor Opportunity Product Please see bottom of page");
else if(1)
alert("Opportunity not Created for Medicare/DVA Account.\nCheck Rate Card is Available or Billing Error log. Please Contact your System Administrator")
var b;
if("{!Patient_Services__c.Dispensing_Footwear_F049__c}"=="1")
{
b = sforce.apex.execute("CreateOptyforDispenfoot","CreateOptywithps",{Id :"{!Patient_Services__c.Id}"});
// alert(b);
if(b>0)
alert("Opportunity created Successfully for Dispensing Footwear F049..!\nFor Opportunity Product Please see bottom of page");
else if(1)
alert("Opportunity not Created for Dispensing Footwear F049.\nCheck Rate Card is Available or Billing Error log.\nPlease Contact your System Administrator")
}
if(a>0 || b>0)
{
var c = new sforce.SObject("Patient_Services__c");
c.id = "{!Patient_Services__c.Id}";
c.Ready_for_Billing__c= "1";
result = sforce.connection.update([c]);
window.location.reload();
}
}
}}
apex class is
global class CreateOpty{
WebService static Integer CreateOptywithps(String Id)
{ .........
}}