Predict PI result as a message

arpita roy
Tera Contributor

Hi Everyone,

 

I have a requirement where -

When a agent creates a new incident ticket the prediction result should display as a message instead of auto populating the assignment group.

 

As a agent i want whenever i select a CI in CI field and enter short description and description it should show the prediction result as a message "The predicted assignment group for the CI is XYZ group"

 

Please let me know how to achieve this requirement. Also this is a valid requirement or not.

 

Thanks in advance.

3 REPLIES 3

Prinssi
Mega Sage

Hi @arpita roy, can you explain why it is a requirement to suggest an assignment group instead of auto-populating it?

 

To actually build this, you would need to have some kind of trigger to run the prediction. There are a couple ways you could accomplish this.

You could add something like an onChange client script (probably a couple) that can trigger an AJAX call to return the predicted assignment group and present it in either a field message, or as a form message.

Or, you could create a new UI Action called "Predict Assignment Group" that when clicked it gets the prediction result and returns it in a field message or form message.

Hi Prinssi,

 

Thank you for your response. I want to write a Business Rule where variable will be stored in scratchpad and then want to use the  on load client script to populate the field message. can you help me with that ? currently i have below BR - 

(function executeRule(current, previous /*null when async*/) {
   
    var solutionName ='XYZ';
    var predictor = new MLPredictor();
    var solution = predictor.findActiveSolution(solutionName);
        if (!solution)
            return;
    predictor.applyPredictionForSolution(current, solution);
    gs.addInfoMessage('Hi');

    var predictionValue = current.solution;
    if(predictionValue) {
        gs.addInfoMessage("The Predicted value is: "+ predictionValue);
    }
})(current, previous);

 

How to store the predicted value and use it further in CS.

 

Hi @arpita roy,

 

I assume you are using a Display Business Rule? It looks like you are most of the way there.

 

The scratchpad is an object. To store something in scratchpad, it is as simple as setting a value in any other object:

 

g_scratchpad.predictedAssignmentGroup = predictionValue;

 

 

From there, you would be able to call the scratchpad value from the CS:

g_form.addInfoMessage("The predicted group is: " + g_scratchpad.predictedAssignmentGroup);

 

I found a great Community article, and a YouTube video that give similar examples of using scratchpad.