1
0
-1

Hi Team,
I need to display the error message in the Error Block like Mandatory error message are displaying. Eg. I am getting exception from API and that need to be displayed in the Error Block.Please help on this.

Thanks

    CommentAdd your comment...

    1 answer

    1.  
      1
      0
      -1

      The only way to get a validation message into the Error block is to have a Validation rule on a component in the form.

      If you are receiving an error message from the server then you'll need to add that message to the form data and have a component validation rule refer to that value.

      E.g. when processing your API response you could add the following code to store an error message:

      data.$serverError = "Something went wrong!";

      Then in your validation rule you could just return this value:

      return data.$serverError;

      You will need to identify an appropriate location to place your validation rule. I would suggest adding this rule to the block that contains the component performing the validation rule.

      Remember to clear the error message when the issue is resolved.

      1. surendarvel

        Hi Ben,

        Thanks Much for the help and i am getting the error message in the Error block. But the thing is i am also getting the error message in the place of the component.  So please help me to show the error message only in the error block. let me know i need to do any more configuration also.Thanks

      2. Ben Warner

        The error block is really just an aggregation of errors that appear on components so I'm not sure you can have an error in the error block but not on a component. What is the reason you don't want it shown with the component?

      3. surendarvel

        Okay sure, The reason behind is, i planned to display the exception or error from the API in the Error Block. SO please suggest me there is any other way to notify user.Thanks

      4. Ben Warner

        You can do a JavaScript alert:

        alert(errorMsg);

        or create a custom dialog to show the message.

        Alternatively you could add your own error display using the Text Display component and show your custom error message as described here:

        Maestro - add icon to TextDisplay

         

      5. surendarvel

        Thanks Ben for the options will use any of them.but still if we can show the error message only in error block that will be helpfull.Thanks

      CommentAdd your comment...