I am using a custom object to store Oauth credentials.
I am able to update this object in Apex Execute Anonymous.
I am unable to update this object in an apex class. Salesforce Connect DataSourceConnection class.
The fields are encrypted.
In both instances, I can see the DML begin and end logs and no errors are reported for either, but a query of the object after the apex class reveals the object has not actually been updated. A query of the object after the apex execute anonymous shows the object has been updated.
What am I missing?
tokenStore__c tokenDefault = [select accessToken__c, tokenExpirationDateTime__c, tokenServiceActive__c from tokenStore__c LIMIT 1];
tokenDefault.tokenServiceActive__c = false;
tokenOefault.tokenExpirationDateTime__c = Datetime.valueOf('2018-12-25 01:01:01');
tokegDefault.accessToken__c = 'test';
system.debug(tokenDefault);
update tokenDefault;