Reporting on dynamic recommendations created by the Generate node

When using a Generate node to create dynamic recommendations, you need to ensure that the ID for the recommendation is passed because that is the primary key on which the node operates and further downstream reports are generated.  A point to watch out for is that it is not straightforward to generate IDs dynamically and be assigned to the recommendation object because Apex is strongly typed and would look for an ID of type Recommendation. 

However, there are several recommended workarounds for this situation. 

  1. If your use case can instead use the load node to load an SObject (vs a recommendation object) and then map the fields such as Id, name, accept label, reject label and flow name in a map node as shown below.
Using the Map node to map required fields on the Recommendation object
Using the Map node to map required fields on the Recommendation object

If this doesn’t work because of the dynamic nature of your use case and the Generate node needs to be used to programmatically create recommendations, another way to tackle it is as below.

Say the recommendations are mapped by querying a product object in the Apex class. You can assign the ID field of the object queried to the External ID field of the recommendation object created. This avoids the ‘Strong type’ checking of the ID issue. Following is a code snippet from a Generate node.

And then use the map element in the strategy following the generate element to map the external ID to the ID of the recommendation object. 

Use a Map node to map the external Id to Recommendation Id