Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 5029 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

Hi all,

I have a custom function that returns the layoutID.

How do I have to write a navigation script to go to a given layout based on the ID of the layout, instead of the hard coded name of the layout.

The Go to Layout function gives only two possibilities: Layout Name by calculation or Layout Number by calculation.

TIA

Posted

Not sure what you want here. If your layoutID is the same number as the layout number then you have no problem. If not then I guess you need a table to correlate the two, but why?

Posted

The layoutID is not the same as the layout number.

The layout number is the number f the layout in the layout order list and can change if the order is changed.

The layoutID is generated by FileMaker and will never change.

I try to avoid hardcoding layout names in my scripts.

Thus want to use the layoutID.

Posted

The Go to Layout function gives only two possibilities: Layout Name by calculation or Layout Number by calculation.

Not exactly - there is a third option, where you simply select the layout's name from a list. This is actually the default option - and it doesn't hard-code the layout's name: if you modify the layout's name, the script step will change to follow.

Posted

No, that is not what I said. You CAN calculate the layout's number from its ID, by finding the position of the ID in the result of LayoutIDs() function. However, that's what the Go to Layout script step does anyway, so I don't see why you need to do this yourself.

Posted

Then our journey ends here.

My idea is based on this article:

http://www.dbservices.com/articles/using-filemaker-table-layout-ids-in-scripts-and-calculations

Posted

Where I use them now is not important.

I like to have a way to never use them again and use the IDs instead.

It looks to me as a better way of coding.

Posted

Hi,

I use this in a system I am developing. See http://www.kevinfrank.com/demo-files.html for the technique file "Absolute Layout References" for the details. Basically two custom functions are used one to read the ID and one to get the layout number for the ID to navigate. Ray Cologon also has a demo file related to this http://www.nightwing.com.au/FileMaker/demos9/demo915.html He calls it UNBREAKABLE, so I believe it to be good practice to use a similar technique.

HTH,

Tim

Posted

This is a waste of time.

FileMaker ALREADY grabs the layout ID as part of the standard Go to Layout script step. As with almost everything Filemaker does in scripting, IDs are used but mostly they are not visible to the user.

This would ONLY be be relevant if you use the "go to layout" using the "layout name by calculation ..." option.

Posted

My 2 cents.

Not hard-coding is a terrific goal. Self-documenting scripts are, too.

Using the technique to grab the internal layout IDs seems like the way to go. However, let's take a simple nav script.

Go to Layout (layoutby calc, 1)

OK. It goes to Layout 1. What layout is that? How will you know?!

But Go to Layout (Contact_form) is explicit. AND, as pointed out above, change the name from Contact_form to Contact_entry, and it will still work! It's not hard-coded.

Often you need to add more scripts steps, for example,

If ($result = 5)

Go to Layout (Contact_list)

else

Go to Layout (Contact_form)

endif

this is a much easier script to maintain than:

Go to Layout by calc (

If (

$result = 5; 1; 3)

which is buried within the calc.

Your choice.

  • 6 months later...
Posted

Just decided I want to not hard code layout names in my scripts and find Fabrice's generalized custom function to unwieldy. A search brought up this thread.

I don't understand the resistance to not hardcoding layout names. I don't want this feature for Go To Layout... but for handling scripts.

For example, I want to use a custom menu for deleting records. But the rules are different for each layout. I could have separate custom menus for each layout or I could have a script that looks like:

If[ Get ( LayoutName ) = "People" ]

Perform Script [Delete People]

Else If [Get ( LayoutName ) = "Programs"]

Perform Script [Delete Programs]

End If

But what if I change the layout name?

If[ LayoutIDFromName ( Get ( LayoutName ) ; 1 ) = 12 ]

#12 is People Layout

Perform Script [Delete People]

Else If [ LayoutIDFromName ( Get ( LayoutName ) ; 1 ) = 16 ]

#16 is Program Layout

Perform Script [Delete Programs]

End If

I've had this disagreement before and I've seen similar custom functions, though I can't recall where, but this is what I wrote this morning. The CF needs exception handling (null/invalid parameters, etc) and hasn't been thoroughly tested yet.

/*LayoutIDFromName ( name ; occurrence )

by David Jondreau */

Let([

file = Get ( FileName ) ;

names = ¶ & LayoutNames ( File ) & ¶ ;

name = ¶ & name & ¶ ;

pos = Position ( names ; name ; 1 ; occurrence ) ;

leftText = Left ( names ; pos ) ;

valPos = ValueCount ( leftText ) ;

result = GetValue ( LayoutIDs ( File ) ; valPos )

];

result

)

This topic is 5029 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.