Enhance Element

Enhance Icon Also introduced in Summer ’19, the Enhance step allows you to modify a set of already existing recommendations using an Apex class. It takes a branch of recommendations as input (in the variable recommendations) and optionally custom attributes and returns the list of recommendations after you’ve modified them.

The typical use case for this is if you need to change something on the recommendations that goes beyond what you can do with the Map element. For example, things like doing calculations, doing additional lookups of data, etc, etc. For our example we’ll replace our Map call with an Enhance step and an Apex class doing exactly the same thing: making the user first name and the Subject of the case part of the description of the recommendation.

The Apex class for this:

global class NBAEnhanceTemplate {
		@InvocableMethod(
        label='NBA Enhance Example'
        description='This function updates the Descripion using the supplied input parameters')
        global static List<List<Recommendation>> sampleMethod(List<NBAEnhanceTemplateRequest> inputRequests) {
        List<List<Recommendation>> outputs = new List<List<Recommendation>>();

        for (NBAEnhanceTemplateRequest inputRequest : inputRequests)
        {
            List<Recommendation> singleRequestOutputs = new List<Recommendation>();
            
            for (Recommendation inputRecommendation : inputRequest.recommendations)
            {
            	inputRecommendation.Description = inputRequest.FirstInputVariable + ', ' + inputRecommendation.Description + ' for ' + inputRequest.SecondInputVariable;
                
                singleRequestOutputs.add(inputRecommendation);
            }      
            outputs.add(singleRequestOutputs);
        }
        return outputs;
    }
    
    
     global class NBAEnhanceTemplateRequest {
        @InvocableVariable
        global String FirstInputVariable;
         
        @InvocableVariable
        global String SecondInputVariable;
         
        @InvocableVariable
    	global List recommendations;
    }

Then the Enhance step looks like this:

Enhance screenshot

And the strategy is now:

Enhance screenshot

And the final recommendation output looks, similar to what we had before, like this:

Enhance screenshot

Back to Elements

2511 reads