1

I am making a callout to an external site to populate certain fields on the Account object based on the response of the the external site. There is a custom button on the Account object which is working on javascript and calls an apex controller which makes the callout.

The format of the apex class is :

global class ApexCallout {
    webservice static String xyz(Id accountId){
        Account accountDetails = [SELECT Id, Number1__c, Country1__c FROM Account WHERE Id = :accountId];
        // Request logic here
        // Response logic here; the response comes without any issue
        accountDetails.Registered_Name__c = response.name;
        accountDetails.Registered_Address__c = response.address;
        accountDetails.Request_Date__c = response.requestDate;
        System.debug(response);  
       return String.valueOf(response.valid);  

    }
}

Valid is a Boolean here.

The response of this callout is coming without any issue. Registered name, Registered Address and Request Date are the fields on the Account object which should be populated based on the response as soon as I click on that custom button on the Account detail page.

However, in my case the button is working, the response is coming but these fields are not getting populated on the detail page. Can someone please let me know what I am missing here.

1 Answer 1

2

This is probably just a simple oversight, but it appears you forgot to commit the changes to the database:

update accountDetails;
2
  • Thank you so much, I totally forgot to commit the changes, all good now.
    – Div Snk
    Commented Nov 6, 2016 at 5:19
  • @DivSnk So glad I could help you. Sometimes you just need a second pair of eyes.
    – sfdcfox
    Commented Nov 6, 2016 at 5:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .