xmlAllFields ( )

Function stats

Average user rating
5.0000
37
213
9999
Support
FileMaker 8.5 +
Date posted
23 March 2009
Last updated
18 December 2010
Version
Recursive function
Yes

Author Info
 Fabrice

74 functions

Average Rating 4.4

author_avatar



 

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.3 - Dec 2010
- major performance improvement
- bug fix (stored and unstored calcs options were not responding correctly).

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 ;

    _fieldType = FieldType ( $cf_fileName ; $cf_field ) ;
    $cf_value = Case (
                    not $cf_storedCalc and LeftWords ( _fieldType ; 1 ) = "storedcalc" ; "" ;
                    not $cf_unstoredCalc and LeftWords ( _fieldType ; 1 ) = "unstoredcalc" ; "" ;
                    not $cf_globals and PatternCount ( _fieldType ; "global" ) ; "" ;
                    not $cf_summaries and PatternCount ( _fieldType ; "summary" ) ; "" ;
                    not $cf_containers and PatternCount ( _fieldType ; "container" ) ; "" ;
                    Let ( _fieldValue = GetField ( $cf_field ) ;
                        Case ( not $cf_empty and IsEmpty ( _fieldValue ) ; "" ;
                            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: 18 December 2010
    Version: 2.2

*/
// ===================================

 

Comments

Genx
25 March 2009



Verryyyy niiiice!! But yes, very handy, awesome work.
  General comment
bensamgold
14 April 2014



Awesome function! Now with FileMaker 13 could easily add a Base64 for the container fields

       Let ( _fieldValue = If ( PatternCount ( _fieldType ; "container" ) ; Base64Encode ( GetField ( $cf_field ) ) ; GetField ( $cf_field ) ) ;
     Feature request