Brian Dunning's FileMaker Custom Functions

GetLayoutID ( layout )

Gets the layout ID of current or named layout

  Average rating: 4.1 (34 votes) Log in to vote

Ulf Carlsson   Ulf Carlsson - Show more from this author
Studentlitteratur AB
http://www.studentlitteratur.se

Share on Facebook Share on Twitter

  Sample input:
GetLayoutID ( "current" )
  Sample output:
6

  Function definition: (Copy & paste into FileMaker's Edit Custom Function window)

Use: Gets the Layout-ID of current layout if parameter layout="current" or of the layout which name is in parameter layout

Problem: You use some kind of navigation that want to switch to another layout when a button is pressed, but you want to be able to change both layout names and layout order without the solution breaks.

Solution: Use the function GetLayoutID in combination with the function GetLayoutNumberFromID to be able to do navigation between layouts without your application breaks if layouts change names or order.
In other words: Where you save which layout name or layout number to go to, save the layout id instead and then look up which number the layout has at the moment with function GetLayoutNumberFromID ( layoutID ).

 

Comments

Robert   Robert, Luxembourg Europe
Sep 30, 2010
Hello

Thanks for your function, but it is a little buggy.

Example:

Layout="Complaint"
LayoutNames="Complaints Test¶Blabla¶Complaint"



Function will return the ID of the 1st value but should return the ID of the 3'd value.


Solution:
replace: theLayoutNames = LayoutNames ( Get ( FileName ) );
with:theLayoutNames = "¶" & LayoutNames ( Get ( FileName ) ) & "¶";

replace:theLayout = If ( layout ="current" ; Get ( LayoutName ) ; layout );
with=theLayout = "¶" & If ( layout ="current" ; Get ( LayoutName ) ; layout ) & "¶";

replace:Position ( theLayoutNames ; theLayout ; 1 ; 1 ) ) ;
"¶" ) + 1 ;
with:Position ( theLayoutNames ; theLayout ; 1 ; 1 ) ) ;
"¶" ) ;


Bye
 
Roman Hofstetter   Roman Hofstetter, Zurich
Aug 30, 2011
This function doesn't work, if you have a Layout named "Example1 Overview" and a Layout named "Example1". If you search for "Example1", the script step Position() will now the position of "Example1 Overview" and you get the wrong ID.
Solution: Check if the Layoutname is on the beginning or the end. Otherways search for ¶Layoutname¶. Like that you're sure the whole name is identical.
 
Thomas Parker   Thomas Parker, Stone & Wood
Dec 29, 2020
I've found a bug that this script doesn't work if it is the last layout in the list. If this happens, it returns no result - just blank. Can anyone verify this?
 
Menno van Beek   Menno van Beek, Van Beek Zakelijke Software
Dec 29, 2020
I would simplify the function a bit:
Let ( [
name = ¶ & If ( IsEmpty ( layout ) ; Get ( LayoutName ) ; layout ) & ¶ ;
names = ¶ & LayoutNames ( "" ) & ¶ ;
line = PatternCount ( Left ( names ; Position ( names ; name ; 1 ; 1 ) ) ; ¶ )
] ;
If ( line ; GetValue ( LayoutIDs ( "" ) ; line ) )
)
 

Log in to post comments.

 

Note: these functions are not guaranteed or supported by BrianDunning.com. Please contact the individual developer with any questions or problems.

Support this website.

This library has been a free commmunity resource for FileMaker users and developers for 20 years. It receives no funding and has no advertisements. If it has helped you out, I'd really appreciate it if you could contribute whatever you think it's worth: