I am trying to update a field on all users in the organization. Ex: I would like to update the company name for all users in my organization.

I tried these: - Create a list view of all users and try to mass update by double clicking but I am unable to (P.S: I enabled enhanced lists and inline editing from Setup > User Interface)

  • I tried to do this from Developer Console:

list abc = [ Select Title From Users ]; for(Users abc : abc) { abc.title = 'Hello'; } update abc;

Even this didn't work

Can someone please help me on this.

I am a newbie to salesforce community

  • how many users are there in the org? – Rajiv Bhatt Apr 15 '15 at 18:15
  • there are more than 100. I tried exporting records to Excel, update and importing back which kind of works for now but I would like to know is there any inbuilt functionality either declaratively or programatically to solve this – sf_user Apr 15 '15 at 18:17
  • do you have experience with SQL? (i didn't mean SOQL, i really mean SQL!) and i am asking this for a reason. coz there is this very nice tool which you can use to fire update/delete soqls without worrying about all the code. – Rajiv Bhatt Apr 15 '15 at 18:24
  • I have a very little knowledge on SQL. But if you can share me the infomation on tool, I will try to look into that. Thanks – sf_user Apr 15 '15 at 18:28

Please query id as well.

List abc = [ Select id,Title From User ]; 
for(User abc : abc) 
{ abc.title = 'Hello'; } 
update abc;
| improve this answer | |
  • I tried to do this but on Execution getting the following error: sObject type 'Users' is not supported. – sf_user Apr 15 '15 at 18:22
  • 1
    please use user not users. – Lemon Apr 15 '15 at 18:29

I am a huge fan of SQLForce . Of course, there are lot of ways using which records could be updated. However, it is always good to keep few utilities handy like this one. If you have experience of SQLs, you would really feel the pain and miss the update and delete dmls in Salesforce (and of course there is reason for that!). However, using SQLForce you can continue using the same syntax on salesforce and fire update/delete SQLs.

Once you are connected to the org, an update that you have requested would simply look like this:

update user set title='Hello';

Thats it! This would update all the user records (coz there is no where clause!). Quite handy for those who are comfortable with SQLs.

| improve this answer | |
  • Thanks Rajiv for your input. Will definitely look into this. – sf_user Apr 15 '15 at 18:37

If you are just talking about a few records you could do this:

List myobjects = [ Select Id, CompanyName From User ]; for( User myobject : myobjects ) { myobject.CompanyName = 'xxxxxxx'; }

update myobjects;

You could also use dataloader, i.e. extract the records, update the value to true and then update with data loader if you don't want to use Apex

| improve this answer | |
  • same error Varun. "sObject type 'Users' is not supported. " when tried from console. I am installing dataloader to see if it is easier than excel. But I am interested in knowing the industry standards on how they update if there are tons of records – sf_user Apr 15 '15 at 18:26
  • sObject type 'Users' is not supported should not be the error. Looks like you are using users in the query. – varun guruvugari Apr 15 '15 at 21:06
  • The Industry standard is you have to either use a batch apex class or use data loader tool to update records in salesforce. – varun guruvugari Apr 15 '15 at 21:07
  • Thanks Varun for your inputs. That will be really helpful for me. – sf_user Apr 15 '15 at 21:09

Me & my admins usually use the Smart-Mass-Update app (instead of writing dedicated code each time and throw it 30 minutes after...)



Mass Update / Edit Mode

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.