{"action":"created","issue":{"url":"https://api.github.com/repos/financialforcedev/fflib-apex-common/issues/125","repository_url":"https://api.github.com/repos/financialforcedev/fflib-apex-common","labels_url":"https://api.github.com/repos/financialforcedev/fflib-apex-common/issues/125/labels{/name}","comments_url":"https://api.github.com/repos/financialforcedev/fflib-apex-common/issues/125/comments","events_url":"https://api.github.com/repos/financialforcedev/fflib-apex-common/issues/125/events","html_url":"https://github.com/financialforcedev/fflib-apex-common/issues/125","id":161759256,"number":125,"title":"You have uncommitted work pending","user":{"login":"tmichels","id":16563920,"avatar_url":"https://avatars.githubusercontent.com/u/16563920?v=3","gravatar_id":"","url":"https://api.github.com/users/tmichels","html_url":"https://github.com/tmichels","followers_url":"https://api.github.com/users/tmichels/followers","following_url":"https://api.github.com/users/tmichels/following{/other_user}","gists_url":"https://api.github.com/users/tmichels/gists{/gist_id}","starred_url":"https://api.github.com/users/tmichels/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tmichels/subscriptions","organizations_url":"https://api.github.com/users/tmichels/orgs","repos_url":"https://api.github.com/users/tmichels/repos","events_url":"https://api.github.com/users/tmichels/events{/privacy}","received_events_url":"https://api.github.com/users/tmichels/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-06-22T18:55:58Z","updated_at":"2016-06-22T19:40:30Z","closed_at":null,"body":"I am creating a new Account and if the account creation fails the exception is posted to an external service using the callout feature. Here is the snippet:\r\n\r\n```\r\ntry{\r\n    fflib_ISObjectUnitOfWork uow = BrightPlan_Rest_App.UnitOfWork.newInstance();\r\n      Account bpAccount = createAccount(userInfo);\r\n      uow.registerNew(bpAccount);\r\n      uow.commitWork();\r\ncatch(Exception ex){\r\n     LoggingService.logException(ex);\r\n}\r\n```\r\n\r\nLoggingService calls out to external service. I see the follow error message:\r\n\r\n> \"message\": \"System.CalloutException: You have uncommitted work pending. Please commit or rollback before calling out\"\r\n\r\nWhen I look at the code it seems like the commitWork handles rollback:\r\n```\r\ncatch (Exception e){\r\n\t\t\t// Rollback\r\n\t\t\tDatabase.rollback(sp);\r\n\t\t\t// Throw exception on to caller\r\n\t\t\tthrow e;\r\n}\r\n```\r\n\r\nAny suggestions?"},"comment":{"url":"https://api.github.com/repos/financialforcedev/fflib-apex-common/issues/comments/227854192","html_url":"https://github.com/financialforcedev/fflib-apex-common/issues/125#issuecomment-227854192","issue_url":"https://api.github.com/repos/financialforcedev/fflib-apex-common/issues/125","id":227854192,"user":{"login":"tfuda","id":1032721,"avatar_url":"https://avatars.githubusercontent.com/u/1032721?v=3","gravatar_id":"","url":"https://api.github.com/users/tfuda","html_url":"https://github.com/tfuda","followers_url":"https://api.github.com/users/tfuda/followers","following_url":"https://api.github.com/users/tfuda/following{/other_user}","gists_url":"https://api.github.com/users/tfuda/gists{/gist_id}","starred_url":"https://api.github.com/users/tfuda/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tfuda/subscriptions","organizations_url":"https://api.github.com/users/tfuda/orgs","repos_url":"https://api.github.com/users/tfuda/repos","events_url":"https://api.github.com/users/tfuda/events{/privacy}","received_events_url":"https://api.github.com/users/tfuda/received_events","type":"User","site_admin":false},"created_at":"2016-06-22T19:40:29Z","updated_at":"2016-06-22T19:40:29Z","body":"This is a platform thing, not an fflib issue. You can't call out to a web service after you've executed a DML operation. Nor can you call out to a web service if you've created a Savepoint. This is a limitation of the Salesforce platform (by design). Try annotating your LoggingService.logException method with the @future(callout=true) annotation. I think it should work then."}}
{"actor":{"display_login":"tfuda"}}