Last active
October 28, 2019 23:32
-
-
Save mtetlow/8fe2b088383873cfbf4f080035691fc5 to your computer and use it in GitHub Desktop.
ConnectApi.SmartDataDiscovery API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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