You need to sign in to do that
Don't have an account?

i am not able to get the current user id on javascript button
Hi ,
Here is the code for javascript button.
{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/29.0/apex.js")}
var records = result.getArray("records");
var f = new sforce.SObject("Appointment__c");
f.id = "{!Appointment__c.Id}";
f.Fini_Status__c = "Appt Canceled";
var user = sforce.connection.getUserInfo();
f.Cancelled_By__c =user.getuuserid;
f.Cancelled_Date_Time__c=new Date().toISOString();
sforce.connection.update([f]);
Here is the code for javascript button.
{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/29.0/apex.js")}
var records = result.getArray("records");
var f = new sforce.SObject("Appointment__c");
f.id = "{!Appointment__c.Id}";
f.Fini_Status__c = "Appt Canceled";
var user = sforce.connection.getUserInfo();
f.Cancelled_By__c =user.getuuserid;
f.Cancelled_Date_Time__c=new Date().toISOString();
sforce.connection.update([f]);
I am guessing that you are using this as JavaScript in a button. So you may need to add the sforce.connection.sessionId line such as
All Answers
that should get you the user's id.
I am not getting the userid.I have tried in my code.
Thanks for the reply.
I am guessing that you are using this as JavaScript in a button. So you may need to add the sforce.connection.sessionId line such as
Now its working without including "sforce.connection.sessionId".
Working only when ........ "f.Cancelled_By__c = sforce.connection.getUserInfo().userId"
Thanks for the help.
i am facing same kind of issue.
actually am trying to capture Userid and Datetime,
Its working fine for SystemAdministrator profile but not working for custom profile users(Not capturing UserId and DateTime).
please help.
Thanks In Advance