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
Craig RosenbaumCraig Rosenbaum 

update() on Organization Object

According to the API guide, I should be able to update the Organization object. 

When I try to update it via annonymous apex, I receive this error: "DML not allowed on Organization". Here's my code: 
Organization o = [Select Name from Organization];
o.City = 'Dallas';
update o;
This was executed by the system admin on the account with "View All Data" enabled. 

Our use case is to allow users to edit their Organization's address through a custom visualforce page made in Skuid. When we were unable to edit this object in Skuid, I tried it in apex to confirm and received the same result. Is there a way to update the Organization information outside of the standard SF page? The documentation suggests so but I have not been successful with it.
Best Answer chosen by Craig Rosenbaum
Martijn SchwarzerMartijn Schwarzer
Hi Craig,

This is one of those cases where the functionality is only available through the API. So you will have to implement the update() method of the SOAP or REST api to update the Organization. This will not work using Apex and DML.

Hope this helps!

Best regards,
Martijn Schwärzer

Ps. If my answer helps you to solve your problem please mark it as best answer. It will help other to find best answer.

All Answers

Martijn SchwarzerMartijn Schwarzer
Hi Craig,

This is one of those cases where the functionality is only available through the API. So you will have to implement the update() method of the SOAP or REST api to update the Organization. This will not work using Apex and DML.

Hope this helps!

Best regards,
Martijn Schwärzer

Ps. If my answer helps you to solve your problem please mark it as best answer. It will help other to find best answer.
This was selected as the best answer
Craig RosenbaumCraig Rosenbaum
Thanks for the explanation Martijn, I was afraid that was the answer.