2

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;

1 Answer 1

0

DML Statements are not allowed on the Customer Adapter class, even though the DML Event logs provide a start and end, they are not actually committed.

Documentation here: https://help.salesforce.com/articleView?id=apex_adapter_considerations_apex.htm&type=5

Future Methods are not invoked in accordance with the above.

Triggers are not allowed on DML statement attempts in Data Source Connection.

The only viable workaround was to call a method on every page that utilizes a webservice callout to check the token status or to get a token for external object query.

You must log in to answer this question.

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