A newer version of this content is available on ReWorkflow ReSource.
Suppose you have a form with a student's address and a parent's address. You might wish to allow the student to check a box to duplicate the address.
Using this method, the relationship's address block will disappear when the student selects to copy the address. The address will be copied to the relationship record via hidden fields that use calculation formulas.
Create the following fields with the following settings:
Export Key | Calculation Formula |
sys:relationship:country | @sys:address.country |
sys:relationship:street | @sys:address.street |
sys:relationship:city | @sys:address.city |
sys:relationship:region | @sys:address.region |
sys:relationship:postal | @sys:address.postal |
This script will attach caculation formulas to each element of your destination address block. In this example, we're assuming our source address block is sys:address and our destination address block is sys:relationship:address.
This method is harder to understand but allows you to keep using nice-looking address blocks.
var source_address = "sys:address" var destination_address = "sys:relationship:address" var sa2 = "@" + source_address var da2 = "[data-export='" + destination_address + "']" $(da2 + " select[id$='_country']").attr("data-formula", sa2 + ".country"); $(da2 + " textarea[id$='_street']").attr("data-formula", sa2 + ".street"); $(da2 + " input[id$='_city']").attr("data-formula", sa2 + ".city"); $(da2 + " select[id$='_region']").attr("data-formula", sa2 + ".region"); $(da2 + " input[id$='_postal']").attr("data-formula", sa2 + ".postal"); Form.initializeCalculatedFields();