TroubleShooter Posted September 4, 2018 Report Share Posted September 4, 2018 Hi, I have been customizing my Caspio App using custom Javascript, however, doing so does not trigger my rules. Perhaps giving a mock scenario would better explain the situation:. Given I have three Input fields: Alpha, Omega, and Sigma, I have a Caspio Rule that says if Omega contains 'man', hide Sigma. This works well when manually doing inputs directly to Omega. However, I have an on("input") listener that syncs the value of Alpha and Omega. When I type 'Iron-man' on Alpha, it also appears on Omega, but Sigma is not being hidden. I am hoping someone can help. Many Thanks in advance. Quote Link to comment Share on other sites More sharing options...
DefinitelyNot31337 Posted September 4, 2018 Report Share Posted September 4, 2018 Hello @TroubleShooter, It seems that Caspio's implementation on Rules only runs when the criteria element fires the input event (for text fields), and NOT when the value has been changed in the DOM. In that case, we can just programatically dispatch that event. See the example below. (I used jQuery to simulate the input event, but this implementation will work on vanillla (plain) Javascript) <script type="text/javascript"> var omega = document.querySelector('#InsertRecordOmega') var event = new Event('input', { 'bubbles': true, 'cancelable': true }); $('#InsertRecordAlpha').on("input", function() { omega.value = this.value; omega.dispatchEvent(event); }); </script> It works for me. I am certain that you can make it work too ;). Happy hacking! Regards, DN31337 Quote Link to comment Share on other sites More sharing options...
BFuchs Posted September 12, 2019 Report Share Posted September 12, 2019 Hi, @DefinitelyNot31337, I have a virtual calculated field as follows. CASE WHEN --'[@authfield:No_Auto_Emails]' = 'Yes' AND [@field:Status] = 'Completed' then (select NotificationEmail from Caregivers where TimeAttendancePIN = '[@authfield:Nurse_UserName]' ) End I have tried the following and didn't popup anything on the alert. // set status to complete $('input[name$="Status"]').val('Completed'); document.querySelector('input[name$="Status"]').dispatchEvent(new Event("change")); var Virtual1_textContent = $("span[id^='cbParamVirtual1']").text(); alert(Virtual1_textContent); // <---- checking with an alert you get the right value Any idea? Thanks Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.