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

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

Recommended Posts

Posted

First post, so hope I am placing it in the correct forum area. Please advise if I need to post it elsewhere.

I have two related files, using FileMaker Pro Advanced 18 –

 

“ComixFile” which is a ‘main’ file, listing comics containing multiple tables, with the following as the most used –

Series

Issue

Story

 

“ComixCollection” with is a ‘collection’ file, also containing  multiple tables, with the following as the most used ––

SeriesCC

IssueCC

StoryCC

I have a separate button bar on each table to perform various tasks such as go to related records. It works well, but a pain when I want to add additional scripts, especially when I add new tables to each file.

I wanted to replace both button bars with a single “card” button bar with a table named “Navigation” in the “ComixFile” file. This works fine with “ComixFile” tables but does not work with “ComixCollection” as the context changes when the popover opens and appears to go to the “ComixFile” tables. I have attempted using a custom function to trap the layout name or the file name to show which table I am using (to force the script to work on the “ComixCollection” table) but it does not appear to work, as the card is (probably quite correctly!) using the “ComixFile” table for context.

I’ve even tried a linked “Navigation” and “NavigationCC” table but still do not get scripts to work from “ComixCollection”.

Example: I am using StoryCC and want to use the card to go to Series. In my original setup I had a script that went to the related table in “ComixFile” using the button bar -

Series View (from CC)
If [ Get ( LayoutName ) = "IssueCC"and IssueCC::SeriesID ≠ "" ]

Go to Related Record [ From table: “IssueCC_Series_SeriesID”; External; Using layout: “Series” (series) ]

[ Show only related records; New window ]

End If

Attempting to use this with the extra step of using a script step to open the “Navigation” popover in “ComixCollection”, then selecting a button to use the script with the first step being to close the “Navigation” window, results in what I have mentioned above.

Series View (from CC)
Close Window
[ Name: "Navigation"; Current file ]
If [ Get ( LayoutName ) = "IssueCC"and IssueCC::SeriesID ≠ "" ]

Go to Related Record [ From table: “IssueCC_Series_SeriesID”; External; Using layout: “Series” (series) ]

[ Show only related records; New window ]

End If

At some stage (and I haven’t been able to replicate it(!), I managed to get “ComixFile” to open, but it did not open at the related record/s.

Whew. So, I suppose the question is:

Can I create a SINGLE card/file/table (in ComixFile) which if when required go BACK to the ComixCollection table and layout and then perform the correct script from that context?

Hoping this isn’t sounding as clear as mud…

Posted

Why use two different FileMaker files? Why not use a single file? It will probably solve most of these issues.

Posted
43 minutes ago, OlgerDiekstra said:

Why use two different FileMaker files? Why not use a single file? It will probably solve most of these issues.

 

Hello Olger,

Good question!

However, I keep a separation of data between the two as I do new data dumps (replacing data and adding new data) into “ComixFile”.

“ComixCollection” is far more ‘static’ as it shows the collection.

The entire database was developed with this intentional ‘separation’ in mind.

I think the solution may be in my previous post:


Can I create a SINGLE card/file/table (in ComixFile) which if when required go BACK to the ComixCollection table and layout and then perform the correct script from that context?

Trouble is… how the heck do I do that?

Posted

You can set the secondary database in the primary as an EDS (external data source, file->manage->external data source), and then add tables from the secondary to the schema in your primary. Once you added the EDS, you can create a new TO in your relationship schema and use the dropdown menu to select a different data source (it defaults to the current file).

Then the tables from the secondary can be used (almost) the same as if they were located in the primary DB. You still can't use scripts or layouts from the EDS in your primary DB though, but you can manipulate the data in the EDS from your primary DB.

Posted

Hello Olger,

Once again, thanks for replying.

The two files are already set up as EDS and have multiple relationships - in particular to reference the tables mentioned in my original post.

I need a script ‘request’ invoked in the card layout from the secondary DB (which seems to be bringing the primary DB to the foreground) to ‘go back’ to the secondary DB to invoke the script to weave its magic within the secondary DB.

My problem seems to be the context of the script trying to then stay in the primary DB. I’ve tried various scripts in the primary DB to capture the name/layout of the originating request (from the secondary DB) but not having success.

I’m thinking I’m missing something basic here but can’t quite work out how to do it.

Posted (edited)

Why do you need to go to the EDS database? Any script you're running there uses data that you can already access from your primary DB. All you'd need to do is recreate any relationship you don't yet have in the primary DB, duplicate scripts, and you're done.

But, if you really want to do as described, you can invoke scripts (perform script step) to invoke a script from the other DB and pass parameters to it. I generally use JSON (unless it's just one or two parameters) to pass data from one script to another, as it's easier to control. Similar to selecting a table from another data source in the schema you can select scripts from another data source when selecting a script to perform.

So you can invoke a script from the primary DB to the secondary, passing any data as needed (remember, global vars from one DB aren't available when invoking another DB so you'll have to pass that along as well), do what you need in the secondary DB and as the last step invoke a script from the primary DB again.

Alternatively, you could use FMP URLs to invoke another DB. https://fmhelp.filemaker.com/help/18/fmp/en/index.html#page/FMP_Help/opening-files-url.html

 

Edited by OlgerDiekstra
Posted

Hello Olger,

I’m enjoying our ‘private’ (one-on-one) conversation 😀

I do already have relationships going both ways because the scripts need the context of where they are coming from to grab the required data. That works either direction in the primary (1) or secondary (2) DB.

Examples of scripts that have always worked:

I’m in an Issue in (2) and want to go to the related Issue record in (1). Alternatively, I’m in an Issue in (1) and want to go to the related Issue record in (2)

Or:

I’m in an Issue in (2) and want to go to the related Series record in (1).

Or:

I’m in a Story in (2) and want to go to the related Issue (or Series) record in (1).

Using Data Viewer, I’ve checked Get (File Name) to see context. When I am (2) it shows (2) as the File Name. When I open the card window invoking the Navigation (card) layout from (1) the File Name shows (1) even though the card is opened from within the (2) file’s window. I believe FileMaker is correct in doing this, so I have no argument with them over this behaviour.

Here’s what I am attempting to do:

I punch the “Navigation” button and in the Card Window that opens, press the “Issues” button (which has a heap of If statements in it based on Layout Name)

i.e.

From (1) Series; Issue; Story

Or, if from (2) IssueCC;

I need this:

The scripts for the “Issue” button MUST know if I pulled the Navigation (card) layout originally from (1) or (2) to use the correct If Statement.

I *think* that may mean passing a variable or custom function between the two files, but that’s where I don’t (yet) have a skill level. I have not yet tackled JSON, and not sure if FMP URLs would do what I require as marked in bold above.

Also, I've followed your advice (Ha! I said I was missing something basic) and now have a script replicated in (1) to perform the script from (2) - but that requires its own button in the Navigation Card. I'm wanting that script to work based on that darned If Statement.

Posted
1 hour ago, Charge Daily said:

I’m enjoying our ‘private’ (one-on-one) conversation 😀

Yeah, sometimes you get the extra special one on one treatment, and sometimes you get knocked back and forth by everyone. 😛

 

1 hour ago, Charge Daily said:

I punch the “Navigation” button and in the Card Window that opens, press the “Issues” button (which has a heap of If statements in it based on Layout Name)

Are those layout names hard coded in your script? So if you change a layout name your script breaks?

1 hour ago, Charge Daily said:

The scripts for the “Issue” button MUST know if I pulled the Navigation (card) layout originally from (1) or (2) to use the correct If Statement.

You can get the name of the current database using Get( Filename ) and pass that as a parameter to a script when you invoke using the Perform script command.

In the invoked script you can get the parameter by setting a variable and retrieving the supplied parameter:

Set variable [ $PARAM; Get( ScriptParameter ) ]

You can then use $PARAM to make decisions in your if statements.

1 hour ago, Charge Daily said:

I *think* that may mean passing a variable or custom function between the two files, but that’s where I don’t (yet) have a skill level. I have not yet tackled JSON, and not sure if FMP URLs would do what I require as marked in bold above.

Also, I've followed your advice (Ha! I said I was missing something basic) and now have a script replicated in (1) to perform the script from (2) - but that requires its own button in the Navigation Card. I'm wanting that script to work based on that darned If Statement.

You can invoke a script from a navigation button (you can either use a single command or specify a script), and in a script you can invoke another script using the Perform Script step. When you invoke a script from a button you also have the option to specify a parameter (such as Get( Filename ) ).

Screenshots of your scripts, layouts go a long way to help. If at all possible upload a demo file either with dummy data, or remove parts that are not relevant to the issue at hand, it makes it much easier to understand what your trying to do.

 

  • 2 weeks later...
Posted

As I suspected, I had the context (and script step ordering) wrong.

First, thanks to Olger for his responses which put me back on track.

Second, answers to Olger’s questions/observations:

1: “Are those layout names hard coded in your script? So if you change a layout name your script breaks?”

Response: Yes. They are hard coded. Layout names are logical and work to their two original data sources which are refreshed by ongoing data dumps. There is no need to ever change layout names.

ComixCollection is a relatively ‘static’ file as once data is entered, it rarely changes. Any corresponding table names have “CC” as a suffix. Thus, “Issue” appears in ComixFile and “IssueCC” appears in ComixCollection.

2: “You can get the name of the current database using Get( Filename ) and pass that as a parameter to a script when you invoke using the Perform script command.”

Response: You’ll see below that I went with Get (LayoutName) instead as I needed the layout’s name to enable the correct script step to occur.

3: “You can invoke a script from a navigation button (you can either use a single command or specify a script), and in a script you can invoke another script using the Perform Script step. When you invoke a script from a button you also have the option to specify a parameter (such as Get( Filename ) ).”

Response: Yes. The ‘aha!” moment came when you pointed out I needed to invoke scripts from ComixFile to go back to ComixCollection.

Here’s my solution – maybe it’s not elegant, but I can make it cleaner at a later date.

There was never any problem pulling up a Navigation card when in the main (ComixFile) file as, when the script called for the card to close upon pressing the relevant script button it always looked at the current window’s LayoutName to perform the correct script step/s. The problem came when invoking the Navigation card (which is part of the ComixFile file) from ComixCollection.

To resolve it, I used the following script on the Navigation button In ComixCollection to set the current (ComixCollection) LayoutName in the related “Navigation” and “NavigationCC” table, then go to the (ComixFile) Navigation Card and allow the user to select a button to navigate to where they wanted to go.

Navigation (CC): Navigation from CC
Set Variable
[ $$Layout_name; Value:Layout_Name ]

Go to Layout [ “NavigationCC” (NavigationCC) ]
Set Field [ NavigationCC__Navigation__ID_g::Layout Name; $$Layout_Name ]
Go to Layout [ original layout ]
Perform Script [ “Navigation From CF” from file: “ComixFile”; Parameter: $PARAM ]

At the Navigation Card the user selects a relevant button to run the script below.

Script step order was the other area I needed to fix. The first step MUST be to see if the originating layout was a CC (ComixCollection) layout. If so, it needs to go back to ComixCollection to perform the script to go back to ComixFile to display the correct related record/s.

The next script step (the first elseif) works on the current layout after checking the LayoutName on the Navigation Card. (Obviously, I also set the LayoutName when entering the Navigation card from within the ComixFile file).

Views: Issue View
If
[ Navigation::Layout Name = "IssueCC" ]

Close Window [ Name: "Navigation"; Current file ]

Perform Script [ “Issue View (from CC)” ]
Else If [ Navigation::Layout Name = "Issue" and (Get ( ActiveModifierKeys ) = "8") ]

Adjust Window

[ Resize to Fit ]

Go to Layout [ “Issue” (Issue) ]

Show/Hide Toolbars

[ Lock; Show ]
Else If [ Navigation::Layout Name = "Issue" ]

Close Window [ Name: "Navigation"; Current file ] Adjust Window

[ Resize to Fit ]

Go to Layout [ “Issue” (Issue) ]

Show/Hide Toolbars

[ Lock; Show ]
Else If [ Navigation::Layout Name = "Issue (List)" ]

Close Window [ Name: "Navigation"; Current file ]
Go to Related Record [ From table: “Issue”; Using layout: “Issue” (Issue) ]

[ Show only related records ]

Adjust Window

[ Resize to Fit ]
Else If [ Navigation::Layout Name = "Story" ]

Close Window [ Name: "Navigation"; Current file ]
Go to Related Record [ From table: “story__Issue__issue_id”; Using layout: “Issue” (Issue) ]

[ Show only related records ]

Go to Layout [ “Issue” (Issue) ]

Set Window Title [ Current Window; New Title: Issue::Issue_details ]

Show/Hide Toolbars

[ Lock; Show ]

Adjust Window

[ Resize to Fit ]
Else If [ Navigation::Layout Name = "Story (List)" ]

Close Window [ Name: "Navigation"; Current file ]
Go to Related Record [ From table: “story__Issue__issue_id”; Using layout: “Issue” (Issue) ]

[ Show only related records ]

Go to Layout [ “Issue” (Issue) ]

Show/Hide Toolbars

[ Lock; Show ]

Adjust Window

[ Resize to Fit ]
Else If [ Navigation::Layout Name = "Series" ]

Close Window [ Name: "Navigation"; Current file ] 31 August 2019 14:40:46

ComixFile.fmp12 - Issue View -1-

Views: Issue View
Close Window
[ Name: "Navigation"; Current file ]

Go to Related Record [ From table: “series__Issue__id”; Using layout: “Issue” (Issue) ] [ Show only related records ]

Set Window Title [ Current Window; New Title: story::series_name ] Show/Hide Toolbars

[ Lock; Show ]

Adjust Window

[ Resize to Fit ]
Else If [ Navigation::Layout Name = "Series (List)" ]

Close Window [ Name: "Navigation"; Current file ]
Go to Related Record [ From table: “series__Issue__id”; Using layout: “Issue” (Issue) ]

[ Show only related records ]

Show/Hide Toolbars

[ Lock; Show ]

Adjust Window

[ Resize to Fit ]
Else If [ Navigation::Layout Name = "Quick Entry" ]

Close Window [ Name: "Navigation"; Current file ]
Go to Related Record [ From table: “Issue”; Using layout: “Quick Entry” (Issue) ]

[ Show only related records ]

Go to Layout [ “Issue” (Issue) ]

Show/Hide Toolbars

[ Lock; Show ]

Adjust Window

[ Resize to Fit ]
Else If [ Navigation::Layout Name = "Reports" ]

Close Window [ Name: "Navigation"; Current file ]

Go to Layout [ “Issue” (Issue) ]

Show/Hide Toolbars

[ Lock; Show ]
Else If [ Navigation::Layout Name = "Cover Images (scrolling)" ]

Close Window [ Name: "Navigation"; Current file ]

Go to Layout [ “Issue” (Issue) ] End If

Whew! I’m back on track. Having a single navigation table makes life so much easier for when I add new tables/functions.

And again, thanks to Olger for pointing me in the correct direction.

This topic is 1910 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.