Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Detect field value change in adaptive forms

SeanLapointe
Level 4
Level 4

Hello,

 

Is there a way to determine if the value of a field has been changed in an adaptive HTML form other than having a hidden field with the initial value in it that gets compared when the Value Commit event is triggered?

1 Accepted Solution
radzmar
Correct answer by
Level 10
Level 10

Hi, you can add event listeners to various events. As an example: This script in the initialize event of the guide root panel will cause, that every change in your form is reported into the console of the web browser.

 

guideBridge.on("elementValueChanged" , function(event, payload) {
     console.log("The value of object '" + payload.target.name + "' has been changed from '" + payload.oldText + "' into '" + payload.newText + "'.");
});

View solution in original post

5 Replies
radzmar
Correct answer by
Level 10
Level 10

Hi, you can add event listeners to various events. As an example: This script in the initialize event of the guide root panel will cause, that every change in your form is reported into the console of the web browser.

 

guideBridge.on("elementValueChanged" , function(event, payload) {
     console.log("The value of object '" + payload.target.name + "' has been changed from '" + payload.oldText + "' into '" + payload.newText + "'.");
});

View solution in original post

SeanLapointe
Level 4
Level 4

payload.oldText returns 'undefined' for every change. I was trying to avoid using hidden fields, but I guess I don't have much of a choice. 

SeanLapointe
Level 4
Level 4

I was able to set some variables for the original values in the guide panel init that persisted when the event fired. This works great, thanks!

PulkitJain
Employee
Employee

@SeanLapointe 

Usually button clicks or field exit events can be used to validate the rules so you can check for the  (field value change AND value of the field against the set default value of the hidden field) here.