Skip to main content

Support Article

Set Style action does not work in the On Change event

SA-67211

Summary



Set Style action does not work in the On Change event. The action works for the Focus event.


Error Messages



Not Applicable


Steps to Reproduce



1. In a text input field, perform the following, 
- Add an Action Set.
- Add a Change event.
- Add a Set Style action.
- Set Style Source to Inline Style
- Set Inline Style: background-color: yellow; (it does not work with any other Style).
2. Run the case and apply a change to the text input field. The background color does not change on exiting the field.



Root Cause



SetStyle action configuration is valid to configure on hover or focus events as the applied styles will be removed on Focus out or Blur. If the SetStyle action is configured on click, it is not possible to roll back the applied style. Hence, it is recommended to use the hover or focus event.


Resolution



Perform the following local-change:
  1. To highlight the fields if they changed, enter the below code in the UserWorkForm:

    <script>
    function changeBGColour(color, event){ 
      var name = event.target.name; 
      document.getElementsByName(name)[0].style.backgroundColor = color; 
    }
    </script>

     
  2. On the control, add the Run script action.
  3. Enter the function name as BGColour.
  4. Pass the parameters as in the below image.

Note: Run Script action must be the final action in the sequence of the actions configured.

 
Suggest Edit

Published November 29, 2018 - Updated October 8, 2020

Did you find this content helpful? Yes No

100% found this useful

Have a question? Get answers now.

Visit the Collaboration Center to ask questions, engage in discussions, share ideas, and help others.

Ready to crush complexity?

Experience the benefits of Pega Community when you log in.

We'd prefer it if you saw us at our best.

Pega Community has detected you are using a browser which may prevent you from experiencing the site as intended. To improve your experience, please update your browser.

Close Deprecation Notice
Contact us