I am in the process of learning apex / salesforce.

I am trying to update a textfield, in the salesforce UI with the Account object, when a HTTP request is made.

So in the base class I made for the HTTP method I added

    public static HttpRequest createRequest() {
        Account acct = new Account();
        acct.usedAmounts = "111";

So my thinking is all accounts, will get this updated field of 111 when an HTTP request is made.

The issue, is when I do make a http request system.debug() shows the text I put to see if the method is running and everything is good. Yet the textfield for the account object is never updated, and it throws no errors.


For any changes to be made permanent, you need to commit the account record to the database.

If you wish to insert this as a new account, add insert acct; at the end, if you wish to update an existing account, you will need to ensure that the Id field is populated with the relevant Id, and add update acct; at the end.

To retrieve the Id, you can query the account(s) first, and then make the change to the queried record. For example, if you are trying to update a single record:

Account acct = [SELECT Id FROM Account WHERE Name = 'The Name' LIMIT 1];
acct.usedAmounts = "111";
update acct;
  • OP does not have an ID so perhaps insert ?
    – cropredy
    Mar 11 at 19:29
  • Yes it just gave an error that it does not have an ID. I will try insert now. Mar 11 at 19:30
  • Good point cropredy, Ill update the answer. Mar 11 at 19:31

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.