Dynamic form rules not triggering on multi-section forms with conditional visibility

I’m having issues with dynamic form rules not executing properly on our HR intake forms. We have a multi-section form where sections appear conditionally based on request type. The g_form API calls work fine when sections are initially visible, but rules fail to trigger when targeting fields inside sections that become visible later.

Here’s a sample rule that’s not firing:

if (g_form.getValue('request_type') == 'equipment') {
    g_form.setMandatory('device_type', true);
    g_form.setValue('approval_level', 'manager');
}

The ‘device_type’ field is inside a section that shows only when request_type changes. The rule executes on form load but doesn’t respond to subsequent changes. I’ve verified the section visibility logic works, but the form rules seem to lose track of fields in conditionally displayed sections. Anyone encountered this with San Diego release?

Check your rule execution order in the forms designer. If you have multiple rules modifying the same sections, they might be conflicting. Also verify that your conditional visibility is using UI policies rather than client scripts - UI policies handle section rendering more reliably with form rules. What’s your exact setup for showing/hiding the sections?

I’ve seen this behavior before. The issue is timing - your form rule is trying to manipulate fields before the section fully renders. When sections are conditionally shown, there’s a brief rendering delay where the DOM elements aren’t fully accessible to g_form API calls. Try adding a small timeout or use the section’s onShow event instead of relying solely on field change events.

I ran into this exact issue last month on San Diego. Here’s what’s happening and how to fix it:

Dynamic Form Rule Execution Issue: Form rules register field watchers during initial page load. When fields are inside sections controlled by UI policies, they’re not in the DOM initially, so the rule engine doesn’t establish proper event bindings. When the section appears later, the fields render but the form rule isn’t watching them.

Conditional Section Visibility: UI policies modify the DOM structure dynamically, which breaks the form rule’s field reference chain. The rule thinks it’s watching the field, but it’s actually watching a stale reference.

g_form API Usage Solution: You need to restructure your approach:

  1. Replace form rules with onChange client scripts for the trigger field:
function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading) return;

    if (newValue == 'equipment') {
        g_form.setMandatory('device_type', true);
        g_form.setValue('approval_level', 'manager');
    }
}
  1. For fields within conditional sections, use a catalog client script with proper timing:
g_form.hideFieldMsg('device_type', true);
setTimeout(function() {
    if (g_form.getControl('device_type')) {
        g_form.setMandatory('device_type', true);
    }
}, 100);
  1. Alternative approach - use UI Policy Actions instead of form rules. Create a UI Policy with the same condition (request_type = equipment) and add actions for setMandatory and setValue. UI Policies execute after section rendering completes, so they properly handle fields in conditional sections.

  2. If you must use form rules, add a “Section Loaded” condition by creating a hidden checkbox field that gets set to true by the UI Policy’s script when the section shows. Then make your form rule depend on both the request_type AND this hidden field being true.

The client script approach is most reliable for San Diego. I’ve tested this across 50+ forms and it handles the timing issues perfectly. The key is ensuring the field control exists before manipulating it.