Answers.Body: <p>I know this is a late reply. I hope it will help others.</p>
  
  <p>You need to <code>return false;</code> so that the background color is red.</p>
  
  <p>Example:</p>
  
  <pre><code>     if (count($criteria-&gt;ids()) &gt; 1)
       {
           $this-&gt;setMessage($this-&gt;getParams()-&gt;warningMessage);
  
           return false;
       }
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-09-29T10:05:03.463Z
Answers.LastActivityDate: 2016-09-29T17:12:42.463Z
Answers.LastEditDate: 2016-09-29T17:12:42.463Z
Answers.UserDisplayName: Anya Dit
Body: <p>I call a service function inside the performAction method of custom element-action and I'd like to show an error message to user if the service function returned false.</p>
  
  <p>I was able to set success message by using:</p>
  
  <pre><code>$this-&gt;setMessage($this-&gt;getParams()-&gt;successMessage);
  </code></pre>
  
  <p>But I don't know how to set an error message i.e. with red background.</p>
  
Tags: <plugin-development><plugins><control-panel><elementaction>
Title: How to set error message in element action?
ThreadText: # How to set error message in element action?
  
  (Asked by: username_0 on 2016-02-06)
  
  I call a service function inside the performAction method of custom element-action and I'd like to show an error message to user if the service function returned false.
  
  I was able to set success message by using:
  
  ```
  $this->setMessage($this->getParams()->successMessage);
  
  ```
  
  But I don't know how to set an error message i.e. with red background.
  
  **Tags:** plugin-development, plugins, control-panel, elementaction
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2016-09-29. Score: 1 | Accepted answer
  
  I know this is a late reply. I hope it will help others.
  
  You need to `return false;` so that the background color is red.
  
  Example:
  
  ```
       if (count($criteria->ids()) > 1)
       {
           $this->setMessage($this->getParams()->warningMessage);
  
           return false;
       }
  
  ```
  
  
  ---
  
  