Control rule sets field value on a field that also has a control rule
If I change one drop down control, I have a rule to set the value on a radio button. On that radio button is a rule that is supposed to hide a few fields and change some mandatory / non mandatory fields.
It seems that using the Set Field Value in the first control does not trigger a change event for the second Field. Shouldn't this work?
-
hi Laura,
Within eForms, we are limited to the actions set listed. With your scenario, we will set the value of the radio button, not trigger it's rules. That said, once we set the value of the radio button, we can trigger the rule through a helper method.
Let me know if this works for you.
Lucas
-
Thank you. I was looking at the helper methods but didn't see a lot of examples on how to use them. I don't know if I'm reading your example correctly.
So the syntax is
eFormHelper.triggerControlRule({FieldID: "InternalName"}, function(r){});
what is the function(r){} doing?
I added for the 4 radio button that I'm updating their values and I want to launch the rules related to each but when I look at the form in preview and change the Type of Change to "Change Vendor" and the Reason for Modification to "EXTEND" the radio buttons update from NO to YES but rules on each do not fire. If I unhide these radio buttons and click them manually they make the changes I'm looking for, so I know the rules are good but can't seem to programmatically get them to fire.
-
I would think function(r){} is where you can put a function to store the result somewhere or do something with it. Like found here: https://documentation.agilepoint.com/00/appbuilder/cloudjsPrintForm.html
if (result.isSuccess) { // Functionality goes here } else { // logs the hold exception object console.log(result.error); }
Note that recommend making a JS file in the shared folder so that you can reuse those calls in other forms/rules and update them better in the future. -
Okay that makes sense. But in the first example that Lucas Drege supplied is there something I'm missing in the setup? Do I just put that script into the rule? Or do I need to create a JS script?
I did only what you see in screen shot and when I run demo of form I don't see anything change.
I'm not very java savy but I have slept at a Holiday Inn. :)
-
I think there is a much easier way to do this. You can create a simple one-line JavaScript function that triggers the change event for a control.
Below is the syntax. In this example, the internal name of the field I want to trigger the change event for is "CompanyNumber":
function triggerCompanyChange()
{
$('#CompanyNumber').change();
}Then in your rule for the drop-down, after you set the value for the radio button, you simply execute this JS function. It will trigger the change event for the target field and the rules for that field will then be executed.
-
I am have a need for something similar (simpler?). On an e-form, I have two lookups.. the SITE and the DEPARTMENT. when a user selects a company site (MI, OH,GA) I would like to refresh the DEPARTMENT lookup. I have the SQL all built and everything works fine when testing the query. However, when a run the form, I need to trigger a refresh of the DEPARTMENT lookup based on a change in the SITE value.
How should I do this?
-
You can accomplish this by setting up a separate Auto-Lookup on your form for populating the DEPARTMENT list when the value of the SITE field changes.
Here is an example from one of my applications where the user first selects a Vendor from a drop-down list. After they select the Vendor, the Auto-Lookup executes and populates a drop-down list of Contacts for the selected vendor:
You have to use the Auto-Lookup control so that you have access to the options that control when the Auto-Lookup executes. If you have your lookup defined in your DEPARTMENT field, those lookups only execute at form load time.
Note in my example, that the Auto-Lookup is bound to my "ContactName" drop-down list and I have told it to execute when the value of the "SLVendor" field changes ("SLVendor" is the internal name of the Vendor drop-down list).
Please sign in to leave a comment.
Comments
13 comments