Control rule sets field value on a field that also has a control rule

Comments

13 comments

  • Avatar
    Lucas Drege

    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.

    Documentation Link

     

    Let me know if this works for you.

     

    Lucas

    0
    Comment actions Permalink
  • Avatar
    Hansen, Laura A

    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.

    0
    Comment actions Permalink
  • Avatar
    Nik

    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. 
    0
    Comment actions Permalink
  • Avatar
    Hansen, Laura A

    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.  :)

    0
    Comment actions Permalink
  • Avatar
    Karl Makatenas

    Try changing all of your "ctrlField27x" to "fieldId".

    0
    Comment actions Permalink
  • Avatar
    Hansen, Laura A

    Thanks, I feel like I probably am getting the syntax wrong.  I've changed it to

    eFormHelper.triggerControlRule({fieldID: "HideTerms"}, function(r){});

    No error it just doesn't trigger.  I'm putting in a ticket.  I'm in a pinch to complete.  Thanks everyone for your input.

    0
    Comment actions Permalink
  • Avatar
    Karl Makatenas

    JavaScript is case-sensitive.  Try changing "fieldID" to "fieldId".

    0
    Comment actions Permalink
  • Avatar
    Hansen, Laura A

    OMG!  So I guess we file that under total rookie mistake eh?  

    Thank you that worked!!!  

    Thank you KARL!

    0
    Comment actions Permalink
  • Avatar
    Karl Makatenas

    Lucas actually taught me something, so thank him :)

    1
    Comment actions Permalink
  • Avatar
    Loren Bratzler

    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.

    0
    Comment actions Permalink
  • Avatar
    Paul Horvath

    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? 

    0
    Comment actions Permalink
  • Avatar
    Loren Bratzler

    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).

    1
    Comment actions Permalink
  • Avatar
    Paul Horvath

    Thank you!

    0
    Comment actions Permalink

Please sign in to leave a comment.