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:
- 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>
- On the control, add the Run script action.
- Enter the function name as BGColour.
- Pass the parameters as in the below image.
Published November 29, 2018 - Updated October 8, 2020
Have a question? Get answers now.
Visit the Collaboration Center to ask questions, engage in discussions, share ideas, and help others.