Dev_RelationInfo ( )

Function stats

Average user rating
130
433
9999
Support
FileMaker 10.0 +
Date posted
10 June 2020
Version
1
Recursive function
Yes

Author Info
 Weetbicks

1 functions

Average Rating None

author_avatar



 

Function overview

Prototype

Dev_RelationInfo  ( _field;   _record )


Parameters

_field  a reference to related field whose relationship you wish to learn about


_record  optionally a record number whose values you wish to preview (if the relationship is valid)


Description

Tags:  relationship   developer   design  

This function will give you the following:

• Source FIle
• Source TO Name
• Source Table Name
• Target TO Name
• Target Table Name
• A listing of every predicate used in the relationship
• The evaluated field values of the LHS predicates
• If a record number is supplied, the evaluated field values of the RHS predicates for that record.

Examples

Sample input

DEV_RelationInfo ( RelatedContacts::id ; 1 )


Sample output

==================================================================================
File:                MyTestDatabase
Source TO:        Home
Source Table:        Interface
Target TO:        RelatedContacts
Target Table:        Contacts
==================================================================================

Home::zconst_ACTIVE = RelatedContacts::zrec_status
        Active = Active

----------------------------------------------------------------------------------
Home::contacts_KEY_search_lower <= RelatedContacts::zkey_primary
        Digi <= Digital Fusion

----------------------------------------------------------------------------------
Home::contacts_KEY_search_higher >= RelatedContacts::zkey_primary
        Digizzz >= Digital Fusion

----------------------------------------------------------------------------------
Home::contacts_KEY_search_IDs_contact = RelatedContacts::zkey_ids
        All = All¶1 386DW J4NJB W96XH BG5C7


----------------------------------------------------------------------------------
Home::contacts_KEY_IDs_contact = RelatedContacts::zkey_ids
        All = All¶1 386DW J4NJB W96XH BG5C7


----------------------------------------------------------------------------------

 

Function code


// Initialise on first running the list of relationships to recurse

If ( IsEmpty ( $DEV_relationships ) ;

    Let ( [
        ~field = Substitute ( If ( PatternCount ( _field ; "::" ) > 0 ; _field ; GetFieldName ( _field ) ) ; "::" ; "¶" ) ;
        $DEV_relatedTO = GetValue ( ~field ; 1 ) ;
        $DEV_relatedTable = ExecuteSQL ( "SELECT BaseTableName FROM FileMaker_Tables WHERE TableName = ?" ; "" ; "" ; $DEV_relatedTO ) ;
        $DEV_relationInfo = RelationInfo ( "" ; $DEV_relatedTO ) ;
        $DEV_relationships = Middle ( $DEV_relationInfo ; Position ( $DEV_relationInfo ; "Options:" ; 1 ; 1 ) + 9 ; 9999 ) ;
        $DEV_counter = 1 ;
        $DEV_total = ValueCount ( $DEV_relationships )
            
    ] ;
        ""
    )
)


&


If ( $DEV_counter > $DEV_total ;

    Let ( [
        ~result = $DEV_result ;
        $DEV_result = "" ;
        $DEV_relationships = "" ;
        $DEV_relationInfo = "" ;
        $DEV_counter = "" ;
        $DEV_relatedTO = "" ;
        $DEV_relatedTable = "" ;
        $DEV_total = ""
    ] ;
        ~result
    )

;

    Let ( [
        ~this = GetValue ( $DEV_relationships ; $DEV_counter ) ;
        ~thisList = Substitute ( ~this ; [ " = " ; "¶" ] ; [ " < " ; "¶" ] ; [ " > " ; "¶" ] ; [ " <= " ; "¶" ] ; [ " >= " ; "¶" ] ; [ " X " ; "¶" ] ; [ " <> " ; "¶" ] ) ;
        ~thisField = GetValue ( ~thisList ; 1 ) ;
        ~thisTO = GetValue ( Substitute ( ~thisField ; "::" ; "¶" ) ; 1 ) ;
        ~relatedField = GetValue ( ~thisList ; 2 ) ;
        ~thisValue = Evaluate ( ~thisField ) ;
        ~relatedValue = If ( not IsEmpty ( _record ) ; Evaluate ( "GetNthRecord ( " & ~relatedField & " ; " & _record & " )" ) ; "" ) ;
        ~relatedValue = If ( ~relatedValue = "?" ; "(no record)" ; ~relatedValue ) ;
        $DEV_counter = $DEV_counter + 1 ;


        // Header Information
        $DEV_Result = If ( IsEmpty ( $DEV_Result ) ;

        List (
                "==================================================================================" ;
                Substitute (
                    GetValue ( $DEV_relationInfo ; 1 ) ;
                    "Source:" ;
                    "File:" & "                "
                ) ; " " ;
                "Source TO:" & "            " & ~thisTO ;
                "Source Table:" & "        " & ExecuteSQL ( "SELECT BaseTableName FROM FileMaker_Tables WHERE TableName = ?" ; "" ; "" ; ~thisTO ) ;
                " " ;
                "Target TO:" & "            " & $DEV_relatedTO ;
                "Target Table:" & "        " & $DEV_relatedTable ;
                "==================================================================================" ;
                "¶"
            )

        ; $DEV_result ) ;


        $DEV_result =
            List (
                $DEV_result ;
                TextStyleAdd ( ~this ; Bold ) ; " " ;
                "        " &
                If (
                    IsEmpty ( _record ) ;
                    ~thisValue ;
                    Substitute (
                        ~this ;
                        [ ~thisField ; ~thisValue ] ;
                        [ ~relatedField ; ~relatedValue ]
                    )
                ) ; "¶----------------------------------------------------------------------------------¶"
            )
    ] ;
        DEV_RelationInfo ( _field ; _record )
    )
        
)

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

    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/433

    Prototype: Dev_RelationInfo( _field; _record )
    Function Author: Weetbicks (http://www.fmfunctions.com/mid/130)
    Last updated: 10 June 2020
    Version: 1

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

 

 

 

 

 

 

 

Top Tags

Text Parsing  (33)
List  (32)
Date  (30)
XML  (27)
Format  (23)
Sql  (22)
Dev  (20)
Debug  (17)
Layout  (15)
Interface  (15)
Text  (14)
Variables  (13)
Filter  (12)
Design  (11)
Layout Objects  (11)
Array  (8)