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
R R MR R M 

Not capturing Custom profile User id and DateTime

HI Folks,

I have Onclick javascript button to change the status and i tried to capture the time and Userid. So its working perfectily for System administrators and able to capture userid and time also but for Custom profile users this not working. userid and time not capturinng. 

see below code
{!REQUIRESCRIPT("/soap/ajax/30.0/connection.js")} 
{!REQUIRESCRIPT("/soap/ajax/24.0/apex.js")} 
var x; 
if (confirm("Are you Sure! You want to Reject this Customer?") == true) { 
x = "Yes"; 
} else { 
x = "Cancel"; 
} 
if(x == 'Cancel'){ 
window.location.replace('/{!Customer__c.Id}') 
} 
else { 
var journystatus = "SELECT id,Customer_Status__c FROM Customer__c WHERE Id = '{!Customer__c.Id}' limit 1"; 

var records = sforce.connection.query(journystatus); 
var values = records.getArray('records'); 
var status = values[0].Customer_Status__c ; 

if(status == 'Referred') 
{ 
var result = sforce.apex.execute("CustomerStatusChanginginDBUsingAPI","StatusChange", {extrnlid:"{!Customer__c.Customer_External_Id__c}", 
CusJurSt:"Rejected"}); 
location.reload(); 
} 
else 
{ 
alert('Cannot change the customer status as customer already in REJECTED/REFFERED state'); 
}
var f = new sforce.SObject("Customer__c"); 
f.id = "{!Customer__c.Id}"; 
f.Rejected_Date_Time__c =new Date().toISOString();
f.Rejected_By__c =sforce.connection.getUserInfo().userId; 
sforce.connection.update([f]); 
}


please do help.
Thanks in Advance.