| Components | All | New | MacOS | Windows | Linux | iOS | ||||
| Examples | Mac & Win | Server | Client | Guides | Statistic | FMM | Blog | Deprecated | Old | |
MBS FileMaker Plugin Example Databases
Custom Functions to Log Scriptcalls
All examples are included with download of MBS FileMaker Plugin.
Custom Functions to Log Scriptcalls.fmp12
| Overview | |
| Tables | 3 |
| Relationships | 2 |
| Layouts | 3 |
| Scripts | 7 |
| Value Lists | 0 |
| Custom Functions | 3 |
| Custom Menus | 0 |
| File Options | |
| Default custom menu set | [Standard FileMaker Menus] |
| When opening file | |
| Minimum allowed version | 12.0 |
| Login using | Account Name; Account= Admin |
| Allow user to save password | Off |
| Require iOS passcode | Off |
| Switch to layout | Off |
| Hide all toolbars | Off |
| Script triggers | |
| OnFirstWindowOpen | Off |
| OnLastWindowClose | Off |
| OnWindowOpen | Off |
| OnWindowClose | Off |
| OnFileAVPlayerChange | Off |
| Thumbnail Settings | |
| Generate Thumbnails | On; Temporary |
| Table Name |
Statistics
| Occurrences in Relationship Graph |
| TestTable |
5 fields defined, 1 record
| TestTable |
| ScriptCallLog |
18 fields defined, 12 records
| ScriptCallLog |
| ScriptCallCounter |
7 fields defined, 3 records
| ScriptCallCounter |
| Table Name: TestTable - 5 Fields | ||||||||
| Field Name | Type | Options | Comments | On Layouts | In Relationships | In Scripts | In Value Lists | |
| PrimaryKey | Normal, Text | Auto-Enter:
| Unique identifier of each record in this table |
|
|
|
||
| CreationTimestamp | Normal, Timestamp | Auto-Enter:
| Date and time each record was created |
|
|
|
|
|
| CreatedBy | Normal, Text | Auto-Enter:
| Account name of the user who created each record |
|
|
|
|
|
| ModificationTimestamp | Normal, Timestamp | Auto-Enter:
| Date and time each record was last modified |
|
|
|
|
|
| ModifiedBy | Normal, Text | Auto-Enter:
| Account name of the user who last modified each record |
|
|
|
|
|
| Table Name: ScriptCallLog - 18 Fields | ||||||||
| Field Name | Type | Options | Comments | On Layouts | In Relationships | In Scripts | In Value Lists | |
| PrimaryKey | Normal, Text | Auto-Enter:
| Unique identifier of each record in this table |
|
|
|
||
| CreationTimestamp | Normal, Timestamp | Auto-Enter:
| Date and time each record was created |
|
|
|
||
| CreatedBy | Normal, Text | Auto-Enter:
| Account name of the user who created each record |
|
|
|
|
|
| ModificationTimestamp | Normal, Timestamp | Auto-Enter:
| Date and time each record was last modified |
|
|
|
|
|
| ModifiedBy | Normal, Text | Auto-Enter:
| Account name of the user who last modified each record |
|
|
|
|
|
| FileName | Normal, Text | Auto-Enter:
|
|
|
|
|||
| TableName | Normal, Text | Auto-Enter:
|
|
|
|
|||
| LayoutName | Normal, Text | Auto-Enter:
|
|
|
|
|||
| ScriptName | Normal, Text | Auto-Enter:
|
|
|
|
|||
| ScriptParameter | Normal, Text | Auto-Enter:
|
|
|
|
|||
| ScriptResult | Normal, Text | Auto-Enter:
|
|
|
|
|||
| ScriptCallID | Normal, Text | Auto-Enter:
|
|
|
|
|||
| AccountName | Normal, Text | Auto-Enter:
|
|
|
|
|||
| UserName | Normal, Text | Auto-Enter:
|
|
|
|
|||
| IP | Normal, Text | Auto-Enter:
|
|
|
|
|||
| CallStack | Normal, Text | Auto-Enter:
|
|
|
|
|||
| StartTime | Normal, Timestamp | Auto-Enter:
|
|
|
|
|||
| EndTime | Normal, Timestamp | Auto-Enter:
|
|
|
|
|||
| Table Name: ScriptCallCounter - 7 Fields | ||||||||
| Field Name | Type | Options | Comments | On Layouts | In Relationships | In Scripts | In Value Lists | |
| PrimaryKey | Normal, Text | Auto-Enter:
| Unique identifier of each record in this table |
|
|
|||
| FileName | Normal, Text | Auto-Enter:
|
|
|
|
|||
| ScriptName | Normal, Text | Auto-Enter:
|
|
|
|
|||
| Key | Normal, Text | Auto-Enter:
|
|
|
|
|||
| Counter | Normal, Number | Auto-Enter:
|
|
|
|
|||
| CreationTimestamp | Normal, Timestamp | Auto-Enter:
| Date and time each record was created |
|
|
|
||
| ModificationTimestamp | Normal, Timestamp | Auto-Enter:
| Date and time each record was last modified |
|
|
|
||
Relationship: ScriptCallLog!=TestTable
| Table Occurrence | ScriptCallLog | TestTable | |
| Field | PrimaryKey | != | PrimaryKey |
| Source Table | ScriptCallLog | TestTable | |
| Source File | Custom Functions to Log Scriptcalls.fmp12 | Custom Functions to Log Scriptcalls.fmp12 | |
| Allow creation of records via this relationship | Off | Off | |
| Delete related records in this table when a record is deleted in the other table | Off | Off | |
| Sort records |
Off | Off |
Layout Hierarchy
TestLayout
ScriptCallLog
ScriptCallCounter
| Layout Name | Include In Menu | Quick Find | # of Objects | Show Records From | Save record changes automatically | Show field frames when record is active | Show field frames only on current record | Show current record indicator in List View | Used in Scripts | Custom Menu Set | Script Triggers | Theme ID |
| TestLayout | Yes | Yes | TestTable | On | Off | On | Off | [File Default] | 01 | |||
| ScriptCallLog | Yes | Yes | ScriptCallLog | On | Off | On | On | [File Default] | 01 | |||
| ScriptCallCounter | Yes | Yes | ScriptCallCounter | On | Off | On | On | [File Default] | 01 |
Layout Objects: TestLayout
| Field Name: ScriptCallCounter::FileName | |||||
| Field Properties | Coordinates | Field Format | Field Behavior | Quick Find | |
|
| Field Format:
| Field Behavior:
| Yes | |
| Field Name: ScriptCallCounter::ScriptName | |||||
| Field Properties | Coordinates | Field Format | Field Behavior | Quick Find | |
|
| Field Format:
| Field Behavior:
| Yes | |
| Field Name: ScriptCallCounter::Counter | |||||
| Field Properties | Coordinates | Field Format | Field Behavior | Quick Find | |
|
| Field Format:
| Field Behavior:
| Yes | |
| Field Name: ScriptCallCounter::CreationTimestamp | |||||
| Field Properties | Coordinates | Field Format | Field Behavior | Quick Find | |
|
| Field Format:
| Field Behavior:
| Yes | |
| Field Name: ScriptCallCounter::ModificationTimestamp | |||||
| Field Properties | Coordinates | Field Format | Field Behavior | Quick Find | |
|
| Field Format:
| Field Behavior:
| Yes | |
| Field Name: ScriptCallLog::FileName | |||||
| Field Properties | Coordinates | Field Format | Field Behavior | Quick Find | |
|
| Field Format:
| Field Behavior:
| Yes | |
| Field Name: ScriptCallLog::TableName | |||||
| Field Properties | Coordinates | Field Format | Field Behavior | Quick Find | |
|
| Field Format:
| Field Behavior:
| Yes | |
| Field Name: ScriptCallLog::LayoutName | |||||
| Field Properties | Coordinates | Field Format | Field Behavior | Quick Find | |
|
| Field Format:
| Field Behavior:
| Yes | |
| Field Name: ScriptCallLog::ScriptName | |||||
| Field Properties | Coordinates | Field Format | Field Behavior | Quick Find | |
|
| Field Format:
| Field Behavior:
| Yes | |
| Field Name: ScriptCallLog::ScriptParameter | |||||
| Field Properties | Coordinates | Field Format | Field Behavior | Quick Find | |
|
| Field Format:
| Field Behavior:
| Yes | |
| Field Name: ScriptCallLog::ScriptResult | |||||
| Field Properties | Coordinates | Field Format | Field Behavior | Quick Find | |
|
| Field Format:
| Field Behavior:
| Yes | |
| Field Name: ScriptCallLog::AccountName | |||||
| Field Properties | Coordinates | Field Format | Field Behavior | Quick Find | |
|
| Field Format:
| Field Behavior:
| Yes | |
| Field Name: ScriptCallLog::UserName | |||||
| Field Properties | Coordinates | Field Format | Field Behavior | Quick Find | |
|
| Field Format:
| Field Behavior:
| Yes | |
| Field Name: ScriptCallLog::IP | |||||
| Field Properties | Coordinates | Field Format | Field Behavior | Quick Find | |
|
| Field Format:
| Field Behavior:
| Yes | |
| Field Name: ScriptCallLog::CallStack | |||||
| Field Properties | Coordinates | Field Format | Field Behavior | Quick Find | |
|
| Field Format:
| Field Behavior:
| Yes | |
| Field Name: ScriptCallLog::StartTime | |||||
| Field Properties | Coordinates | Field Format | Field Behavior | Quick Find | |
|
| Field Format:
| Field Behavior:
| Yes | |
| Field Name: ScriptCallLog::EndTime | |||||
| Field Properties | Coordinates | Field Format | Field Behavior | Quick Find | |
|
| Field Format:
| Field Behavior:
| Yes | |
| Button Properties | Coordinates | Script/Script Step | ||||
|
| Perform Script [ “Test Script”; Parameter: Get(CurrentTime) ] Scripts: |
||||
| Button Properties | Coordinates | Script/Script Step | ||||
|
| Perform Script [ “Open Custom Functions Dialog” ] Scripts: |
||||
| Button Properties | Coordinates | Script/Script Step | ||||
|
| Perform Script [ “Turn Logging on” ] Scripts: |
||||
| Button Properties | Coordinates | Script/Script Step | ||||
|
| Perform Script [ “Turn Logging off” ] Scripts: |
||||
| Portal Properties | Coordinates | Fields | Options | ||
|
| Field Objects
|
|
||
| Portal Properties | Coordinates | Fields | Options | ||
|
| Field Objects
|
|
||
Layout Objects: ScriptCallLog
| Field Name: ScriptCallLog::FileName | |||||
| Field Properties | Coordinates | Field Format | Field Behavior | Quick Find | |
|
| Field Format:
| Field Behavior:
| Yes | |
| Field Name: ScriptCallLog::TableName | |||||
| Field Properties | Coordinates | Field Format | Field Behavior | Quick Find | |
|
| Field Format:
| Field Behavior:
| Yes | |
| Field Name: ScriptCallLog::LayoutName | |||||
| Field Properties | Coordinates | Field Format | Field Behavior | Quick Find | |
|
| Field Format:
| Field Behavior:
| Yes | |
| Field Name: ScriptCallLog::ScriptName | |||||
| Field Properties | Coordinates | Field Format | Field Behavior | Quick Find | |
|
| Field Format:
| Field Behavior:
| Yes | |
| Field Name: ScriptCallLog::ScriptParameter | |||||
| Field Properties | Coordinates | Field Format | Field Behavior | Quick Find | |
|
| Field Format:
| Field Behavior:
| Yes | |
| Field Name: ScriptCallLog::ScriptResult | |||||
| Field Properties | Coordinates | Field Format | Field Behavior | Quick Find | |
|
| Field Format:
| Field Behavior:
| Yes | |
| Field Name: ScriptCallLog::AccountName | |||||
| Field Properties | Coordinates | Field Format | Field Behavior | Quick Find | |
|
| Field Format:
| Field Behavior:
| Yes | |
| Field Name: ScriptCallLog::UserName | |||||
| Field Properties | Coordinates | Field Format | Field Behavior | Quick Find | |
|
| Field Format:
| Field Behavior:
| Yes | |
| Field Name: ScriptCallLog::IP | |||||
| Field Properties | Coordinates | Field Format | Field Behavior | Quick Find | |
|
| Field Format:
| Field Behavior:
| Yes | |
| Field Name: ScriptCallLog::CreationTimestamp | |||||
| Field Properties | Coordinates | Field Format | Field Behavior | Quick Find | |
|
| Field Format:
| Field Behavior:
| Yes | |
| Field Name: ScriptCallLog::ScriptCallID | |||||
| Field Properties | Coordinates | Field Format | Field Behavior | Quick Find | |
|
| Field Format:
| Field Behavior:
| Yes | |
Layout Objects: ScriptCallCounter
| Field Name: ScriptCallCounter::FileName | |||||
| Field Properties | Coordinates | Field Format | Field Behavior | Quick Find | |
|
| Field Format:
| Field Behavior:
| Yes | |
| Field Name: ScriptCallCounter::ScriptName | |||||
| Field Properties | Coordinates | Field Format | Field Behavior | Quick Find | |
|
| Field Format:
| Field Behavior:
| Yes | |
| Field Name: ScriptCallCounter::Key | |||||
| Field Properties | Coordinates | Field Format | Field Behavior | Quick Find | |
|
| Field Format:
| Field Behavior:
| Yes | |
| Field Name: ScriptCallCounter::Counter | |||||
| Field Properties | Coordinates | Field Format | Field Behavior | Quick Find | |
|
| Field Format:
| Field Behavior:
| Yes | |
| Field Name: ScriptCallCounter::PrimaryKey | |||||
| Field Properties | Coordinates | Field Format | Field Behavior | Quick Find | |
|
| Field Format:
| Field Behavior:
| Yes | |
| Test Script |
| Some sub script |
| Other script |
| Open Custom Functions Dialog |
| Turn Logging on |
| Turn Logging off |
| Refresh window |
| Next Script: [Some sub script] |
| Script Name | Test Script |
| Run script with full access privileges | Off |
| Include In Menu | Yes |
| Layouts that use this script | |
| Scripts that use this script |
|
| Script Definition | |
| Script Steps |
|
| Fields used in this script |
|
| Scripts used in this script | |
| Layouts used in this script |
|
| Tables used in this script |
|
| Table occurrences used by this script |
|
| Custom Functions used by this script | |
| Custom menu set used by this script |
|
| Previous Script: [Test Script] | Next Script: [Other script] |
| Script Name | Some sub script |
| Run script with full access privileges | Off |
| Include In Menu | No |
| Layouts that use this script |
|
| Scripts that use this script | |
| Script Definition | |
| Script Steps |
|
| Fields used in this script |
|
| Scripts used in this script |
|
| Layouts used in this script |
|
| Tables used in this script |
|
| Table occurrences used by this script |
|
| Custom Functions used by this script | |
| Custom menu set used by this script |
|
| Previous Script: [Some sub script] | Next Script: [Open Custom Functions Dialog] |
| Script Name | Other script |
| Run script with full access privileges | Off |
| Include In Menu | Yes |
| Layouts that use this script |
|
| Scripts that use this script |
|
| Script Definition | |
| Script Steps |
|
| Fields used in this script |
|
| Scripts used in this script | |
| Layouts used in this script |
|
| Tables used in this script |
|
| Table occurrences used by this script |
|
| Custom Functions used by this script | |
| Custom menu set used by this script |
|
| Previous Script: [Other script] | Next Script: [Turn Logging on] |
| Script Name | Open Custom Functions Dialog |
| Run script with full access privileges | Off |
| Include In Menu | Yes |
| Layouts that use this script | |
| Scripts that use this script |
|
| Script Definition | |
| Script Steps |
|
| Fields used in this script |
|
| Scripts used in this script |
|
| Layouts used in this script |
|
| Tables used in this script |
|
| Table occurrences used by this script |
|
| Custom Functions used by this script |
|
| Custom menu set used by this script |
|
| Previous Script: [Open Custom Functions Dialog] | Next Script: [Turn Logging off] |
| Script Name | Turn Logging on |
| Run script with full access privileges | Off |
| Include In Menu | Yes |
| Layouts that use this script | |
| Scripts that use this script |
|
| Script Definition | |
| Script Steps |
|
| Fields used in this script |
|
| Scripts used in this script |
|
| Layouts used in this script |
|
| Tables used in this script |
|
| Table occurrences used by this script |
|
| Custom Functions used by this script |
|
| Custom menu set used by this script |
|
| Previous Script: [Turn Logging on] | Next Script: [Refresh window] |
| Script Name | Turn Logging off |
| Run script with full access privileges | Off |
| Include In Menu | Yes |
| Layouts that use this script | |
| Scripts that use this script |
|
| Script Definition | |
| Script Steps |
|
| Fields used in this script |
|
| Scripts used in this script |
|
| Layouts used in this script |
|
| Tables used in this script |
|
| Table occurrences used by this script |
|
| Custom Functions used by this script |
|
| Custom menu set used by this script |
|
| Previous Script: [Turn Logging off] |
| Script Name | Refresh window |
| Run script with full access privileges | Off |
| Include In Menu | Yes |
| Layouts that use this script |
|
| Scripts that use this script |
|
| Script Definition | |
| Script Steps |
|
| Fields used in this script |
|
| Scripts used in this script |
|
| Layouts used in this script |
|
| Tables used in this script |
|
| Table occurrences used by this script |
|
| Custom Functions used by this script |
|
| Custom menu set used by this script |
|
| Function Name | Parameters | Availability | Definition | In Field Definitions | In Scripts |
| CountScriptCall | All accounts | If($$LogScriptCalls; Let ( [ FileName = Get(FileName); ScriptName = Get(ScriptName); // try to insert new record r = MBS( "FM.InsertRecord"; FileName; "ScriptCallCounter"; "Counter"; 1; "ScriptName"; ScriptName; "FileName"; FileName ); // r shows OK or "[MBS] ERROR: (504): Field failed unique value validation test" in case of duplicate // check for error: 504 p = Position ( r ; "(504)" ; 1 ; 1 ); // update existing call on error r = If( p > 0; MBS( "FM.ExecuteFileSQL"; FileName; "UPDATE \"ScriptCallCounter\" SET \"Counter\" = \"Counter\" + 1 WHERE \"ScriptName\" = ? AND \"FileName\" = ?"; 9; 13; ScriptName; FileName ); r) ]; r ); "") |
| ||
| LogScriptCall | All accounts | If($$LogScriptCalls; Let ( [ // query some values about current context FileName = Get(FileName); ScriptName = Get(ScriptName); TableName = Get(LayoutTableName); AccountName = Get(AccountName); LayoutName = Get(LayoutName); UserName = Get(UserName); IP = Get(SystemIPAddress); ScriptParameter = Get(ScriptParameter); // make an unique key for later $ScriptCallID = Get(UUID); // and build call stack $$CallStack = $$CallStack & ScriptName & ¶; // now log it. r = MBS( "FM.InsertRecord"; FileName; "ScriptCallLog"; "ScriptCallID"; $ScriptCallID; "ScriptName"; ScriptName; "FileName"; FileName; "TableName"; TableName; "LayoutName"; LayoutName; "AccountName"; AccountName; "UserName"; UserName; "IP"; IP; "ScriptParameter"; GetAsText(ScriptParameter); "CallStack"; $$CallStack; "StartTime"; Get ( CurrentTimestamp )) ]; r ); "") |
| ||
| LogScriptResult | Result | All accounts | If(not IsEmpty($ScriptCallID); Let ( [ // remove us from call stack $$CallStack = LeftValues ( $$CallStack ; ValueCount ( $$CallStack ) - 1 ); // now updat entry in log to show result. FileName = Get(FileName); r = MBS( "FM.ExecuteFileSQL"; FileName; "UPDATE \"ScriptCallLog\" SET \"ScriptResult\" = ?, \"EndTime\" = ? WHERE \"ScriptCallID\" = ?"; 9; 13; GetAsText( Result ); Get(CurrentTimestamp); $ScriptCallID ) ]; Result ); Result) |
|
| Menu Sets | Menus | In Scripts | In Layouts | Comments |
| [Standard FileMaker Menus] |
|
Download example: Custom Functions to Log Scriptcalls
Used functions: