Function overview
Prototype
xmlAllFields (
_fileName; _layoutName; _empty_boolean; _storedCalcs_boolean; _unstoredCalcs_boolean; _globals_boolean; _summaries_boolean; _containers_boolean )
Parameters
_fileName if empty, current file name is used
_layoutName if empty, current table occurrence name is used
_empty_boolean default is True : log empty values
_storedCalcs_boolean default is True : log stored calculations
_unstoredCalcs_boolean default is True : log unstored calculations
_globals_boolean default is True : log global fields
_summaries_boolean default is True : log summary fields
_containers_boolean default is True : log container fields
Description
Tags:
XML
Returns all fields of a layout or a table occurrence, with their name, ID and content, as a XML string.
Examples
Sample input
on a layout with two fields : Name_First and Name_Last :
xmlAllFields ( "" ; "" ; "" ; "" ; "" ; "" ; "" ; "" )
Sample output
<FIELD>
<NAME>myTable::Name_First</NAME>
<ID>1065116::14</ID>
<DATA>John</DATA>
</FIELD>
<FIELD>
<NAME>myTable::Name_Last</NAME>
<ID>1065116::15</ID>
<DATA>Smith</DATA>
</FIELD>
Function code
/*
xmlAllFields ( _fileName ; _layoutName ; _empty_boolean ; _storedCalcs_boolean ; _unstoredCalcs_boolean ; _globals_boolean ; _summaries_boolean ; _containers_boolean )
by Fabrice Nordmann, 1-more-thing
http://www.1-more-thing.com
v.1.2 - Feb 2010
- worked around a FileMaker issue: FieldNames sometimes inserts empty values in the list
- parameters are now real boolean
v.1.1 - Oct 2009
- if layout name is empty, takes the current table name (was taking current layout name)
- Bug fix : improved filtering of field types
v1 - March 2009
Returns all fields of a layout or a table occurrence, with their name, ID and content, as a XML string.
Parameters:
- if _fileName is empty, current file name is used
- if _layoutName is empty, current table name is used. _layout name can take a layout name or a table occurrence name. If a layout is named after a table occurrence, the layout has priority.
- boolean parameters are True by default. Setting them to False allows omitting certain fields : empty, stored calculations, unstored calculations, globals, summaries, and containers.
Required Custom Functions:
- xmlSet http://www.fmfunctions.com/fname/xmlset
- FM_Name_ID http://www.fmfunctions.com/fname/fm_name_id
*/
Let ([
$cf_fileName = Case ( not IsEmpty ( _fileName ) ; _fileName ; Get ( FileName ))
; $cf_layoutName = Case ( not IsEmpty ( _layoutName ) ; _layoutName ; Get ( LayoutTableName ))
; $allfields = Substitute ( FieldNames ( $cf_fileName ; $cf_layoutName ) ; "¶¶" ; ¶ )
; $cf_counter = $cf_counter + 1
; $cf_empty = GetAsBoolean ( _empty_boolean )
; $cf_storedCalc = GetAsBoolean ( _storedCalcs_boolean )
; $cf_unstoredCalc = GetAsBoolean ( _unstoredCalcs_boolean )
; $cf_globals = GetAsBoolean ( _globals_boolean )
; $cf_summaries = GetAsBoolean ( _summaries_boolean )
; $cf_containers = GetAsBoolean ( _containers_boolean )
];
Case (
$cf_counter > ValueCount ( $allfields ) ; Let ([ $cf_counter = "" ; _result = $cf_result ; $cf_result = "" ; $cf_field = "" ; $cf_value = "" ; $cf_TOname = "" ; $allfields = "" ; $cf_empty = "" ; $cf_storedCalc = "" ; $cf_unstoredCalc = "" ; $cf_globals = "" ; $cf_summaries = "" ; $cf_containers = "" ]; _result ) // last recursion : clear variables, return result
; Let ([
$cf_field = GetValue ( $allfields ; $cf_counter )
; $cf_TOname = GetValue ( List ( Left ( $cf_field ; Position ( $cf_field ; "::" ; 1 ; 1 ) - 1 ) ; Get ( LayoutTableName )) ; 1 )
; $cf_field = Case ( $cf_TOname = Get ( LayoutTableName ) ; $cf_TOname & "::" ) & $cf_field
; _fieldValue = GetField ( $cf_field )
; _fieldType = FieldType ( $cf_fileName ; $cf_field )
; $cf_value = Case (
not $cf_empty and IsEmpty ( _fieldValue ) ; ""
; not $cf_storedCalc and PatternCount ( _fieldType ; "storedcalc" ) ; ""
; not $cf_unstoredCalc and PatternCount ( _fieldType ; "unstoredcalc" ) ; ""
; not $cf_globals and PatternCount ( _fieldType ; "global" ) ; ""
; not $cf_summaries and PatternCount ( _fieldType ; "summary" ) ; ""
; not $cf_containers and PatternCount ( _fieldType ; "container" ) ; ""
; xmlSet ( "FIELD" ; "¶ " & xmlSet ( "NAME" ; $cf_field ) & "¶ " & xmlSet ( "ID" ; FM_Name_ID ( $cf_TOname ; "T" ; "" ; "" ) & "::" & FM_Name_ID ( $cf_field ; "F" ; "" ; "" )) & "¶ " & xmlSet ( "DATA" ; _fieldValue ) & ¶ )
)
; $cf_result = List ( $cf_result ; $cf_value )
];
xmlAllFields ( _fileName ; _layoutName ; _empty_boolean ; _storedCalcs_boolean ; _unstoredCalcs_boolean ; _globals_boolean ; _summaries_boolean ; _containers_boolean )
)))
// ===================================
/*
This function is published on FileMaker Custom Functions
to check for updates and provide feedback and bug reports
please visit http://www.fmfunctions.com/fid/213
Prototype: xmlAllFields( _fileName; _layoutName; _empty_boolean; _storedCalcs_boolean; _unstoredCalcs_boolean; _globals_boolean; _summaries_boolean; _containers_boolean )
Function Author: Fabrice (http://www.fmfunctions.com/mid/37)
Last updated: 04 February 2010
Version: 2.1
*/
// ===================================
/*__LITBR__xmlAllFields ( _fileName ; _layoutName ; _empty_boolean ; _storedCalcs_boolean ; _unstoredCalcs_boolean ; _globals_boolean ; _summaries_boolean ; _containers_boolean )__LITBR____LITBR__by Fabrice Nordmann, 1-more-thing__LITBR__http://www.1-more-thing.com__LITBR____LITBR__v.1.2 - Feb 2010__LITBR__ - worked around a FileMaker issue: FieldNames sometimes inserts empty values in the list__LITBR__ - parameters are now real boolean__LITBR__v.1.1 - Oct 2009__LITBR__ - if layout name is empty, takes the current table name (was taking current layout name)__LITBR__ - Bug fix : improved filtering of field types__LITBR__v1 - March 2009__LITBR____LITBR____LITBR____LITBR__Returns all fields of a layout or a table occurrence, with their name, ID and content, as a XML string.__LITBR____LITBR__Parameters:__LITBR__- if _fileName is empty, current file name is used__LITBR__- if _layoutName is empty, current table name is used. _layout name can take a layout name or a table occurrence name. If a layout is named after a table occurrence, the layout has priority.__LITBR__- boolean parameters are True by default. Setting them to False allows omitting certain fields : empty, stored calculations, unstored calculations, globals, summaries, and containers.__LITBR____LITBR__Required Custom Functions:__LITBR__- xmlSet http://www.fmfunctions.com/fname/xmlset__LITBR__- FM_Name_ID http://www.fmfunctions.com/fname/fm_name_id__LITBR____LITBR__*/__LITBR____LITBR____LITBR____LITBR__Let ([__LITBR__ $cf_fileName = Case ( not IsEmpty ( _fileName ) ; _fileName ; Get ( FileName ))__LITBR__ ; $cf_layoutName = Case ( not IsEmpty ( _layoutName ) ; _layoutName ; Get ( LayoutTableName ))__LITBR__ ; $allfields = Substitute ( FieldNames ( $cf_fileName ; $cf_layoutName ) ; "¶¶" ; ¶ )__LITBR__ ; $cf_counter = $cf_counter + 1__LITBR__ ; $cf_empty = GetAsBoolean ( _empty_boolean )__LITBR__ ; $cf_storedCalc = GetAsBoolean ( _storedCalcs_boolean )__LITBR__ ; $cf_unstoredCalc = GetAsBoolean ( _unstoredCalcs_boolean )__LITBR__ ; $cf_globals = GetAsBoolean ( _globals_boolean )__LITBR__ ; $cf_summaries = GetAsBoolean ( _summaries_boolean )__LITBR__ ; $cf_containers = GetAsBoolean ( _containers_boolean )__LITBR__];__LITBR__Case (__LITBR__ $cf_counter > ValueCount ( $allfields ) ; Let ([ $cf_counter = "" ; _result = $cf_result ; $cf_result = "" ; $cf_field = "" ; $cf_value = "" ; $cf_TOname = "" ; $allfields = "" ; $cf_empty = "" ; $cf_storedCalc = "" ; $cf_unstoredCalc = "" ; $cf_globals = "" ; $cf_summaries = "" ; $cf_containers = "" ]; _result ) // last recursion : clear variables, return result__LITBR__ ; Let ([__LITBR__ $cf_field = GetValue ( $allfields ; $cf_counter )__LITBR__ ; $cf_TOname = GetValue ( List ( Left ( $cf_field ; Position ( $cf_field ; "::" ; 1 ; 1 ) - 1 ) ; Get ( LayoutTableName )) ; 1 )__LITBR__ ; $cf_field = Case ( $cf_TOname = Get ( LayoutTableName ) ; $cf_TOname & "::" ) & $cf_field__LITBR__ ; _fieldValue = GetField ( $cf_field )__LITBR__ ; _fieldType = FieldType ( $cf_fileName ; $cf_field )__LITBR__ ; $cf_value = Case (__LITBR__ not $cf_empty and IsEmpty ( _fieldValue ) ; ""__LITBR__ ; not $cf_storedCalc and PatternCount ( _fieldType ; "storedcalc" ) ; ""__LITBR__ ; not $cf_unstoredCalc and PatternCount ( _fieldType ; "unstoredcalc" ) ; ""__LITBR__ ; not $cf_globals and PatternCount ( _fieldType ; "global" ) ; ""__LITBR__ ; not $cf_summaries and PatternCount ( _fieldType ; "summary" ) ; ""__LITBR__ ; not $cf_containers and PatternCount ( _fieldType ; "container" ) ; ""__LITBR__ ; xmlSet ( "FIELD" ; "¶ " & xmlSet ( "NAME" ; $cf_field ) & "¶ " & xmlSet ( "ID" ; FM_Name_ID ( $cf_TOname ; "T" ; "" ; "" ) & "::" & FM_Name_ID ( $cf_field ; "F" ; "" ; "" )) & "¶ " & xmlSet ( "DATA" ; _fieldValue ) & ¶ )__LITBR__ )__LITBR__ ; $cf_result = List ( $cf_result ; $cf_value )__LITBR__ ]; __LITBR__ xmlAllFields ( _fileName ; _layoutName ; _empty_boolean ; _storedCalcs_boolean ; _unstoredCalcs_boolean ; _globals_boolean ; _summaries_boolean ; _containers_boolean )__LITBR__)))__LITBR____LITBR__// ===================================__LITBR__/*__LITBR____LITBR__ This function is published on FileMaker Custom Functions__LITBR__ to check for updates and provide feedback and bug reports__LITBR__ please visit http://www.fmfunctions.com/fid/213__LITBR____LITBR__ Prototype: xmlAllFields( _fileName; _layoutName; _empty_boolean; _storedCalcs_boolean; _unstoredCalcs_boolean; _globals_boolean; _summaries_boolean; _containers_boolean )__LITBR__ Function Author: Fabrice (http://www.fmfunctions.com/mid/37)__LITBR__ Last updated: 04 February 2010__LITBR__ Version: 2.1__LITBR____LITBR__*/__LITBR__// ===================================
Login or register to comment
Create a new account with fmcustomfunctions.com or login to post a comment.
Comments
24 March 2009