Skip to content

Instantly share code, notes, and snippets.

@mtetlow
Last active October 28, 2019 23:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mtetlow/8fe2b088383873cfbf4f080035691fc5 to your computer and use it in GitHub Desktop.
Save mtetlow/8fe2b088383873cfbf4f080035691fc5 to your computer and use it in GitHub Desktop.
ConnectApi.SmartDataDiscovery API
ConnectApi.SmartDataDiscoveryPredictInputRecords input = new ConnectApi.SmartDataDiscoveryPredictInputRecords();
input.predictionDefinition = '0ORf0000000xxxxxxx';
input.records = new List<Id>{'a291Y000002Exxxxxxx'};
ConnectApi.SmartDataDiscoveryPrediction request =
ConnectApi.SmartDataDiscovery.predict(input);
// Everything up to here so far so good
System.debug('ConnectApi.SmartDataDiscoveryPrediction');
System.debug(JSON.serializePretty(request));
List<ConnectApi.SmartDataDiscoveryPredictObject> predictions = request.predictions;
// This is where it breaks down
for (ConnectApi.SmartDataDiscoveryPredictObject obj : predictions) {
ConnectApi.SmartDataDiscoveryPredict pred = obj.prediction;
system.debug(LoggingLevel.ERROR,pred.total);
// How do i get to these results per the doc?
// ConnectApi.SmartDataDiscoveryPredict test = obj.prediction.total;
}
// Docs say you request.predictions are either
// - List<ConnectApi.SmartDataDiscoveryPredictObject
// - or List<ConnectApi.SmartDataDiscoveryPredictErrorObject
// But casting to either of those directly don't work
// Also Serializing/deserializing then casting to those also don't work
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment