Custom Code Running Twice | Community
Skip to main content
February 2, 2022
Solved

Custom Code Running Twice

  • February 2, 2022
  • 1 reply
  • 962 views

I have custom code that is being triggered by a drop down event on the main page. When I tried testing out the library for functionality it worked, but when I tested it again by closing and reopening the drop down it cached the script causing it to run twice, and oddly breaking the functionality. It's using Core - History Change event, could that be causing the issue or is this likely caused by something else I'm not aware of?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by yuhuisg

If you're able to use the History Change event, then that means the dropdown is causing the browser's navigation history to be updated every time the dropdown is opened and/or closed. So every time the navigation history gets updated, the History Change event gets triggered, and your Rule runs accordingly.

Furthermore, it sounds like you want to the dropdown open to be tracked for the first time only, and not subsequent times. To limit the number of times that the Rule runs, you can consider using the Core > Max Frequency condition:

 

1 reply

yuhuisg
Community Advisor
yuhuisgCommunity AdvisorAccepted solution
Community Advisor
February 3, 2022

If you're able to use the History Change event, then that means the dropdown is causing the browser's navigation history to be updated every time the dropdown is opened and/or closed. So every time the navigation history gets updated, the History Change event gets triggered, and your Rule runs accordingly.

Furthermore, it sounds like you want to the dropdown open to be tracked for the first time only, and not subsequent times. To limit the number of times that the Rule runs, you can consider using the Core > Max Frequency condition: