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
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"); = "{!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