cancel
Showing results for 
Search instead for 
Did you mean: 

SAP Fiori Elements - Client-side error messages in the same Message Popover?

redace_xiii14
Discoverer
0 Kudos

Hi,

Is it possible to add SAPUI5 client-side error messages/validations into the same Message Popover handled by the framework when using Fiori Elements ? I try to use sap.ui.core.message.ControlMessageProcessor and I can see my messages in the Message Manager message model when debugging (both OData and Frontend), however the Message Popover only shows the OData error messages. How can I show both ?

Here is my code. For context, the following code is implemented in the Event handler "fieldChange" of sap.ui.comp.smarttable.SmartTable. The target works fine since the app successfully changes the value state to Error (red) on the correct control and displays the value state error message on the field. My issue is that it doesn't add it to the Message Popover. What am I missing?

(this is on ABAP Platform 1909 and SAPUI5 1.71 version)

// ____________________________________________________var oMessageManager = sap.ui.getCore().getMessageManager();
var oMessageProcessor = new sap.ui.core.message.ControlMessageProcessor();
oMessageManager.registerMessageProcessor(oMessageProcessor);
oMessageManager.registerObject(this.getView(), true);
var sTarget = oEvent.getParameters().changeEvent.getSource().getInnerControls()[0].getId() + "/value";
var fnAddMessage = function() {
return new Promise(function(resolve, reject) {
var oMessage = new sap.ui.core.message.Message({
message: "Duplicate",
persistent: false,
type: sap.ui.core.MessageType.Error,
target: sTarget,
processor: oMessageProcessor
});
oMessageManager.addMessages(oMessage);
resolve();
});
};

this.extensionAPI.securedExecution(fnAddMessage);

// ____________________________________________________

Accepted Solutions (0)

Answers (1)

Answers (1)

WouterLemaire
Active Contributor
0 Kudos

You can use the securedapi for your action and add custom messages to the messagemanager, check the docu here https://ui5.sap.com/#/topic/6a39150ad3e548a8b5304d32d560790a

Here an example on how to do this: https://ui5.sap.com/#/topic/5a9a2a0f2c054b9686acb3497ba32ae2.html

redace_xiii14
Discoverer
0 Kudos

Hi, that's what I did, I used securedExecution... The only difference is that the example in your link is for transition messages since persistent is set to true (error appears as a new Dialog and not in the Message Popover).