How do I take data from a form and assign it to an INI option?
Use the ~FIELD built-in INI function to extract field data and return it as the value for an INI option. An example of how you can use this involves using the Combined (NA/POL) Export method. Suppose that, in addition to certain WIP record fields, you also want to map several fields directly from the form set into the WIPHEADER record.
< ImpExpCombined >
Field = Key1
Field = Key2
Field = KeyID
Field = ;~FIELD "Insured Name"
Field = ;~FIELD "ZIP_FIELD;;DEC PAGE"
For the Combined Export method, the Field options normally map WIP record fields to the WIPHEADER section of the export file. The first three lines map Key1, Key2, and KeyID from the WIP Record.
Notice how the next two lines start with a semicolon. This indicates you are specifying constant data instead of a WIP record field. In this case, you want the constant data mapped from a field within the form set.
This example shows how you can use the ~FIELD function to get the data for the INI option. All INI built-in function names should be followed by a space. The ~FIELD function supports a quoted parameter string to name the specific field to locate within the form set.
The definition of the field can name a specific section, form, and group (Key2 or Line of Business), separated by semicolons, that contain the requested field. This way, you can make sure you are retrieving a specific field occurrence within the document.
Because object names, like fields, sections, forms, and groups, can sometimes contain spaces or other special characters, you must enclose the entire definition in quotes. The system does not support quoting the individual elements of the search.
~FIELD "Field;Image;Form;Group" <-- a valid field definition.
~FIELD "Field";"Image";"Form";"Group" <- not a valid definition.
If you only name a field, omitting the section, form, and group options, this tells the system to find the first occurrence of any field with the given name in the form set and return that data.
If you name a field and section but omit the form or group, the system first locates sections with that name in the document (on any form) and looks for the field there. Likewise, if you name a form, the form is retrieved and then searched. Naming a group (Key2 or Line of Business) limits the search for the field to that region of the document.
If multiple copies of a field are found, the system selects the first occurrence. To identify a specific occurrence of a field, use a backslash followed by a number. Here is an example:
~FIELD "Insured\2"
This tells the system to look for the second occurrence of the Insured field and return the data from that field. You can also use backslashes to indicate an occurrence for sections and forms. Since group (Key2) names are unique, there’s no need to specify an occurrence.
Note | If you have multiple occurrences of the same field name and those fields contain different types of data, you must specify the section, form, or group name to make sure you get the right data. If, you make the definition very specific, then you leave little variance in what forms or sections can comprise the document. |
Keep in mind that when INI built-in functions resolve data, the resulting data is merged back into the INI option being returned. For example, suppose you have a field named Email on your document and a field named Domain. Suppose these fields contain the following data:
Email = JohnsonR
Domain = Somewhere.COM
If you wanted an INI option to return an email address for your recipient, you could do something like this:
Recipient = ~FIELD "Email"@~Field "Domain"
The result would be:
"johnsonR@Somewhere.COM"
Notice that two items were retrieved from field data and the @ character was a constant defined in the original INI definition. There is no space after the quote that ends the first field definition and the constant data, just like there is no space following the constant data before the second ~FIELD built-in definition. The field's data will replace the INI built-in name used and the field naming definition. The remainder of the line remains intact.
Another way you can use ~FIELD is to get the recipient's email address out of the document. So, a section could be designed to have a section that would have the email information that is picked up by INI option.
< PrtType:EPT >
Recipient = ~FIELD "Email"
Subject = ~FIELD "Subject"
Message = ~FIELD "Message"
Assuming that “EMAIL”, “Subject”, and “Message” are all fields in the document, this would retrieve the values from those fields to provide the mailing information for the EPT print INI options.