Difference between revisions of "Custom Field Type: Special - Advanced Data Table"
(→Access to the data within an entire XML section) |
(→Access to the data within an entire XML section) |
||
Line 82: | Line 82: | ||
To display the section when there are '''no''' variables references within the section itself: | To display the section when there are '''no''' variables references within the section itself: | ||
− | :<font size=3>@xml.fieldname.sectionname.html@</font> | + | :<font size=3>@xml.fieldname.'''sectionname.html'''@</font> |
To display the section when there are variables referenced within the section itself: | To display the section when there are variables referenced within the section itself: | ||
− | :<font size=3>@ | + | :<font size=3>@xml'''pre'''.fieldname.'''sectionname.html'''@</font> |
===Access to the data within the XML field=== | ===Access to the data within the XML field=== |
Revision as of 09:35, 3 June 2016
![](/images/7/7e/PlayingCard-XML-Ac.jpg)
Contents
General Description
The XML Field Type is used to store a block of XML.
Field Options
Option | Description | Format |
---|---|---|
Custom Field ID | The unique ID number associated with the custom field. | Not Applicable |
Field Type | The list of available Field Types. | @fieldtype@ |
Field Name | The name of the field, used internally to reference the user's input; | @fieldname@ |
Caption | The leading question or prologue before the field. | @caption@ |
Display Order | The order (relative to other fields) in which this field is displayed. | @displayorder@ |
Description | Definition and general description of the custom field. Will not be displayed. | @description@ |
- XSL Template: see XSL Template page for instructions.
- XML Tag Mapping: see XML Tag Mapping page for instructions.
- XML Javascript Function: see XML Javascript Function page for instructions.
- Button Options: see Uploading to an XML Custom field page for instructions.
- Custom Field Ids: See Custom Field IDs for instructions.
- Button Label: Text to be displayed on the field's button. If no text is entered, the system will use a default label.
- Tool Tip: When the user hovers their mouse pointer over the caption of a field, the text in this section will appear.
- On New Record: Controls how the field should be displayed until record has been saved once.
- Always Display: Field will be exposed both before and after the record is saved.
- Hide on New Record: Field will be hidden until record is saved.
- Only Show on New Record: Field will be exposed until record is saved, and then it will be hidden. This option is useful for fields that provide instructions for filling out forms before saving.
Options
General Options
- Appear Mandatory: Makes the field appear as though it is a required field. Typically used in conjunction with browser scripts, JavaScript Validation or Submit Logic that perform validation.
- Track Changes: Keeps track of changes made to this field.
- Enable Builder: see XML Section Builder.
Enable KML: Used to upload a KML file which is used to display geographic data on a map.
- Disable Field From Global Search: Selecting this option means that the contents of this field will not be displayed in Global Search results.
Value Storage
- Value Storage: Enables linking two different custom fields to the same user data. See Value Stores To page.
The XML stored in this field can be:
- Copied and Pasted from a source file.
- Stored into the field from a workflow process using the SmartSimple Integration Server.
- Used with other Web Service types processes.
Example
Here is an example of XML field called mypasta which stores a recipe (Note that although this stores only one, multiple recipes could be stored in the same block of XML):
<?xml version="1.0" encoding="UTF-8"?> <recipe> <title>Beef Parmesan with Garlic Angel Hair Pasta</title> <Author> <Firstname>Wendy</Firstname> <Lastname>Houston</Lastname> <Address> <Street>148 Peter Street</Street> <postalcode>L7Y 2P5</postalcode> </Address> </Author> <ingredients> <ingredient amount="1.5" unit="pound">Beef cube</ingredient> <ingredient amount="2" unit="kg">Italian Pasta</ingredient> </ingredients> <preparation> <step order='1'> <description>Preheat oven to 350 degrees F (175 degrees C).</description> </step> <step order='2'> <description>Mix all ingredients.</description> </step> <step order='3'> <description>Put everything into oven.</description> </step> <step order='4'> <description>Done.</description> </step> <step order='5'> <description>Find a phone number of the closest take out restaurant.</description> </step> </preparation> <comment> Make the meat ahead of time, and refrigerate over night, the acid in the tomato sauce will tenderize the meat even more. If you do this, save the mozzarella till the last minute. </comment> <nutrition calories="1167" fat="23" carbohydrates="45" protein="32"/> </recipe>
Variables
Access to the data within an entire XML section
Uses standard SmartSimple variable references.
To display the section when there are no variables references within the section itself:
- @xml.fieldname.sectionname.html@
To display the section when there are variables referenced within the section itself:
- @xmlpre.fieldname.sectionname.html@
Access to the data within the XML field
Uses standard SmartSimple variable references.
- @xml.field name.parentnodename.nodename.nodevalue@
- @xml.#fieldid#.parentnodename.nodename.nodevalue@
- @xml.field name.parentnodename.nodename.attribute(attributename)@
- There may not be a parent node, or there may be multiple parent nodes, depending on how the XML is formatted.
Formatting node values
- @xml.field name.parentnodename.[# ~comma(nodename.nodevalue)~ #]@
- This will return a numeric nodevalue with comma formatting (i.e. 1000 will be displayed as 1,000)
- @xml.field name.parentnodename.currency(nodename.nodevalue)@
- This will return a numeric nodevalue in currency format. (See also Displaying a Number Value as Currency.)
Date formatting node values
The available syntax for date formats are as follows: ~formatdate(Date.nodevalue)~ >> returns the date in the user's date format ~year(Date.nodevalue)~ >> returns the year from the date ~month(Date.nodevalue)~ >> returns the month from the date ~monthname(Date.nodevalue)~ >> returns the month name from the date ~day(Date.nodevalue)~ >> returns the day from the date ~dayweek(Date.nodevalue)~ >> returns the day of week from the date
Examples:
Where there is a single entry of 2014-12-02 in an XML field
FORMAT: @xml.fieldname.Expenses-Static.row[# ~formatdate(col4.nodevalue)~ #]@
YEAR: @xml.L1-XML Budget.Expenses-Static.row[# ~year(col4.nodevalue)~ #]@
MONTH: @xml.L1-XML Budget.Expenses-Static.row[# ~month(col4.nodevalue)~ #]@
MONTHNAME: @xml.L1-XML Budget.Expenses-Static.row[# ~monthname(col4.nodevalue)~ #]@
DAY: @xml.L1-XML Budget.Expenses-Static.row[# ~day(col4.nodevalue)~ #]@
DAYWEEK: @xml.L1-XML Budget.Expenses-Static.row[# ~dayweek(col4.nodevalue)~ #]@
FORMAT: 2014-12-02
YEAR: 2014
MONTH: 12
MONTHNAME: December
DAY: 02
DAYWEEK: Tuesday
Counting nodes
- @xml.field name.parentnodename.nodename.nodecount@
For child records
- @xml.fieldname.nodename[# ~nodevalue~ ~attributes(attribute name)~ #]@
- @xml.fieldname.nodename[# ~childnodename.nodevalue~ ~childnodename.attributes(attribute name)~ #]@
To return the actual XML code from the field
- @fieldname.xmlvalue@
- Important: XML node names are case sensitive.
Variable Examples
Created By @xml.mypasta.Author.Firstname.nodevalue@ @xml.mypasta.Author.Lastname.nodevalue@
- Result: Created By Wendy Houston
@xml.mypasta.Author.Address.Street.nodevalue@ @xml.mypasta.Author.Address.postalcode.nodevalue@
- Result: 148 Peter Street L7Y 2P5
@xml.mypasta.title.nodevalue@ @xml.mypasta.comment.nodevalue@ Calories=@xml.mypasta.nutrition.attributes(calories)@
- Result:
Beef Parmesan with Garlic Angel Hair Pasta
Make the meat ahead of time, and refrigerate over night, the acid in the tomato sauce will tenderize the meat even more. If you do this, save the mozzarella till the last minute.
Calories=1167
Ingredients Name - amount - unit @xml.mypasta.ingredients.ingredient[#~nodevalue~ - ~attributes(amount)~ - ~attributes(unit)~#]@
- Result:
Ingredients
Name - amount - unit
Beef cube - 1.5 - pound
Italian Pasta - 2 - kg
Steps Order Description @xml.mypasta.preparation.step[#~attributes(order)~ ~description.nodevalue~#]@
- Result:
Steps
Order Description
1 Preheat oven to 350 degrees F (175 degrees C).
2 Mix all ingredients.
3 Put everything into oven.
4 Done.
5 Find a phone number of the closest take out restaurant.
To format as currency:
@xml.Budget.source.category-total.currency(cash.nodevalue)@
To format as currency with euro symbol "€":
@xml.Budget.source.category-total.currency_eur(cash.nodevalue)@
To create multiple lines in a table for each node that exists:
@xml.budget.funding-source.requested[# <tr> <td> </td> <td class="answer border">Requested from the program</td> <td class="answer border"><div align="right"> ~currency(cash.nodevalue)~</div></td> <td class="answer border">~status.nodevalue~ </td> <td class="answer border">~field.nodevalue~ </td> </tr> #]@
Reporting
To extract an XML element in a report using the XML field, using the mypasta XML example above, add the XML field to the report and add following to the Calculated Field in the Report Builder:
ExtractValue([this], '/recipe/title')
This will display the value "Beef Parmesan with Garlic Angel Hair Pasta" in the report.
ExtractValue([this], '/recipe/Author/Address/Street')
This will display the value "148 Peter Street" in the report.
Further MySQL syntax to extract values from XML can be found at MySQL XML Functions Note: this is an external website.