cancel
Showing results for 
Search instead for 
Did you mean: 

Fiori Elements extension - displaying messages in response from custom Action (List Report)

afordham
Participant
0 Kudos

Hi all,

I have added a custom action to the toolbar of a Fiori Elements List Report Page and implemented its functionality in the OData service. I can't implement the action using annotations as I require both multiple selection on the List and an additional parameter on the action.

In my extension controller, I have successfully put in a call to the extendedAPI.invokeActions() method and can see the response being returned.

I would now like to display these messages in the same way that they are displayed when invoking a (non-custom) action (i.e. single success in a message toast, single error or multiple messages in a dialog). I have been trying to debug the UI5 code for hours, but I am an ABAP developer with a sketchy understanding of JavaScript and I haven't come across what I'm looking for.

How can I add these messages to some sort of message handler and get them displayed?

Many thanks,

Andrew

P.S. Here's the code in my extension controller

sap.ui.controller("myApp.ext.controller.ListReportExt", {
    onCustomAction: function (oEvent) {
        var oApi = this.extensionAPI;
        var aSelectedContexts = oApi.getSelectedContexts();
        var mParameters = {
            "MyCustomParameter": "<a_value_determined_in_the_app>"
        };
        oApi.invokeActions("ENTITYSET/CustomAction", aSelectedContexts, mParameters).then(
            function (oResponse) {
                // Display the messages returned in the response
            },
            function (oError) { 
                // Display the messages returned in the response
            });
    }
});

Accepted Solutions (1)

Accepted Solutions (1)

rahullohia
Advisor
Advisor

Hello Andrew,

You can do a couple of things here.

1. Send a transient message from the backend within your action implementation.

DATA(lo_msg_container) = IO_TECH_REQUEST_CONTEXT->get_message_container( ).

lo_msg_container->add_message_text_only(
EXPORTING
iv_msg_type = /iwbep/cl_cos_logger=>error " Message Type - defined by GCS_MESSAGE_TYPE
iv_msg_text = "Text"
iv_add_to_response_header = abap_true
iv_message_target = '/#TRANSIENT#'

The fiori app should itself display the messages on return.

2. In your function response (within the app controller) you can check for below to add more messages.

if ("Success") { var msgText = "Request submitted successfully.";

consolidatedMessage = new sap.ui.core.message.Message({ message: msgText, type: sap.ui.core.MessageType.Information, target: '', persistent: true }); sap.ui.getCore().getMessageManager().addMessages(consolidatedMessage);

Hope this helps!

Thanks,

Rahul

Answers (1)

Answers (1)

VinothT
Explorer
0 Kudos

Hello Andrew,

Just happened to read on of your posts on error message handling for Restful Apps on S/4 Hana (https://answers.sap.com/questions/13209178/abap-rap-1909-managing-messages-from-repeated-call.html).

At the moment I am trying to implement error handling on an Unmanaged scenario, but although I pass the message from the backend, I get a totally different error message in the front UI. This is the link to the question I posted(https://answers.sap.com/questions/13747440/abap-rap-1909-message-handling.html). The UI5 version used is '1.107.1'

So would be nice if you could tell us how you did it or point us to the correct help documentation to Unmanaged RAP for 1909-on premise system as I can understand that you were able to successfully implement error handling.

Many Thanks.