Brian Dunning's FileMaker Custom Functions

GetLayout ( value )

Get layoutid or layoutname from given value

  Average rating: 4.5 (26 votes) Log in to vote

Michael Bijnens   Michael Bijnens
freelance developer
/

Share on Facebook Share on Twitter

  Sample input:
1) GetLayout (layoutname)
2) GetLayout (layoutid)
  Sample output:
1) result will be an ID of layoutname
2) result will be a layoutname of given layoutid

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

get the layoutname or layoutid from given value.( the value can be a layoutid => than it will return the layoutname else the value is a layoutname => than it will return a layoutid )

ALSO USE CF ValuePosition !

 

Comments

arthur   arthur
Jan 5, 2017
work not (FM11)
 
Thomas Siebert   Thomas Siebert
Mar 23, 2017
Does not work here with FMPA 14

If I try to calculate a layout name from layout id I get an offsett of 55 Layouts (the calculated layout is 55 layouts ahead of the layout that should be calculated.

It seems that the list of Layout IDs are not always in the same order as the list of Layout Names.
 
Thomas Siebert   Thomas Siebert
Mar 23, 2017
sorry, seems that I was mistaken.

I did not realize that the Layout ID is not equal to the layout number
 
Udo Bösch   Udo Bösch, Udo R. Bösch mipiano apps
Jul 2, 2017
There are issues, when a layoutname exists more than 1x or layoutname is just a number that exists in id’s too. My suggestion is to change the function to this:

/*
• The value can be a layoutid => then it will return the layoutname else the value is a layoutname => then it will return a layoutid
• If value is found in layoutnames and in id’s then "?" is returned – this can happen, when a layoutname is only a number that exists in the id’s
• If value is not found or found more than 1x in layoutnames then "?" is returned – Avoid layoutname doublettes if you always want to go to the correct layout!
*/

SetzeVar (
[
~names = LayoutNamen ( "" ) ;
~ids = LayoutIDs ( "" ) ;
~count = ElementeAnzahl (FilterElemente ( ~names ; value )) & ¶ & ElementeAnzahl (FilterElemente ( ~ids ; value ));
~unique = HoleWert ( ~count ; 1 ) = 1 UND HoleWert ( ~count ; 2 ) = 0;
~id = HoleWert ( ~count ; 2 ) ≠ 0 UND HoleWert ( ~count ; 1 ) = 0
] ;
Falls (
~unique = Wahr ; HoleWert ( ~ids ; ValuePosition ( ~names ; value ) ) ;
~id = Wahr ; HoleWert ( ~names ; ValuePosition ( ~ids ; value ) ) ;
"?"
)
)
 
Udo Bösch   Udo Bösch, Udo R. Bösch mipiano apps
Jul 2, 2017
Sorry for a bad mistake late at night (it’s 2:49am here).
I copied the function with the German commands in my previous post.

Here it is in English:

/*
• The value can be a layoutid => then it will return the layoutname else the value is a layoutname => then it will return a layoutid
• If value is found in layoutnames and in id’s then "?" is returned – this can happen, when a layoutname is only a number that exists in the id’s
• If value is not found or found more than 1x in layoutnames then "?" is returned – Avoid layoutname doublettes if you always want to go to the correct layout!
*/

Let (
[
~names = LayoutNames ( "" ) ;
~ids = LayoutIDs ( "" ) ;
~count = ValueCount (FilterValues ( ~names ; value )) & ¶ & ValueCount (FilterValues ( ~ids ; value ));
~unique = GetValue ( ~count ; 1 ) = 1 and GetValue ( ~count ; 2 ) = 0;
~id = GetValue ( ~count ; 2 ) ≠ 0 and GetValue ( ~count ; 1 ) = 0
] ;
Case (
~unique = True ; GetValue ( ~ids ; ValuePosition ( ~names ; value ) ) ;
~id = True ; GetValue ( ~names ; ValuePosition ( ~ids ; value ) ) ;
"?"
)
)
 

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: