Populate Value in Form Grid with Parent Form Value

Introduction

When working with forms that contain Form Grids, you might need to populate a field in a popup form (opened from within a Form Grid) with a value from the parent form. This script allows you to automatically transfer a value from the parent form to a field in the popup form, ensuring consistency and reducing manual data entry.

How does it work?

This script retrieves the value from a field in the parent form and sets this value to a corresponding field in the popup form. The window.parent.document object is used to access the parent form’s values. By specifying the mainFormField and fieldId, you can ensure the value is correctly populated into the desired field in the popup.

To implement this feature, follow the steps below:

  1. Replace "courseName" with the field ID of the parent form from which you want to retrieve the value.
  2. Replace "course" with the field ID in the popup form where the value should be set.
  3. Add the following script to the popup form’s Custom HTML section:
    <script type="text/javascript">
        $(document).ready(function(){
            var mainFormField = "courseName";
            var fieldId = "course";
     
            //get value from parent form
            var value = $('[name='+mainFormField+']:enabled', window.parent.document).val();
     
            //store the value to a field
            $('[name='+fieldId+']:enabled').val(value);
        });
    </script>
Created by Julieth Last modified by Aadrian on Dec 13, 2024