+ Start a Discussion
Kyriacos TheohariKyriacos Theohari 

New Button on Account Object

I need to create a button on the account object that adds the users name to a custom field which is a lookup field to the user object. This field is similar to the account owner field
Best Answer chosen by Kyriacos Theohari
Create a new javascript button on Account object and use below code.
Here in place of Users__c, you need to use your field name

// identify the record
var a = new sforce.SObject("Account");
a.id = "{!Account.Id}";
// Get the user Info
var user = sforce.connection.getUserInfo();
// make the field change
a.Users__c = user.userId;
// save the change
//refresh the page