Sunday, October 19, 2008

EXAMPLE: Six Fields Moved To A Related Record

From Dwayne Wright - Certified FileMaker 9 Developer
WEB: www.dwaynewright.com
EMAIL: info@dwaynewright.com
TWITTER: dwaynewright

In this example, we have two tables called Table A and Table B. Our goal is to take the 6 data fields in a Table A record and make an individual record for each in Table B. This isn’t a “silver bullet” technique but an illustration of how you can use a combination approach to meet your programming needs. In particular, this example is done via a combination of techniques including concatenation, parsing, create new record, get function and a looping script.



SETTING OUR BIG TEXT FIELD
Our first step is to set one text field equal to all the contents of the fields in the tab order and separate each value with a carriage return.

Here at the script steps for this process with a brief description of what we are doing.

Set Field [ Table_A::Big Text; "" ]
This is to initialize the text field for our script by setting it to empty.

Go to Layout [ “Example” (Table_A) ]
This is our first field in the tab order.

Go to Field [ Table_A::Field A ]
This sets the big text field equal to the first field that our cursor is within.

Set Field [ Table_A::Big Text; Get(ActiveFieldContents) ]
The counter is a global number field. We will be counting each field we enter into. This is used to compare how many fields we have been in ... to how many fields we want to be in. When they match, we exit the script.

Set Field [ Table_A::Counter; 1 ]
The process between the Loop and End Loop will repeat until we achieve the requirements of the Exit Loop If script step.

Loop
Go to Next Field
Set Field [ Table_A::Big Text; Table_A::Big Text & "¶" & Get(ActiveFieldContents) ]
Here we are setting the Big Text field equal to itself plus a carriage return ( for the new value) and the contents of the current field.

Set Field [ Table_A::Counter; Table_A::Counter + 1 ]
This is used to set the counter equal to itself plus one. This is how we count each field that we do in the loop.

Exit Loop If [ GetAsNumber(Table_A::Counter) = 6 ]
In this example, we want to do 6 fields in the tab order. If you wanted to do 148, you would set it to 148. FYI... make sure your tab order is set correctly before running the script.

End Loop
Each Loop script step requires an End Loop script step as a matter of proper syntax.

SETTING OUR RELATED RECORDS

Now that we have our big text field ready, we need to create our related values. This is done by setting up a related portal with the Auto Create Related Records option checked. This means the last row in the portal will always be empty, waiting for you to create a related record.

Our script to creating the related records will include the following steps.

Loop
The process between the Loop and End Loop will repeat until we achieve the requirements of the Exit Loop If script step.

Go To Portal Row [ Last ]
This takes us to the last portal row, which is ready for us to create a related record within.

Set Field [ Info, Case( PatternCount(Big Text, "¶") ≥ 1, Left(Big Text, Position(Big Text, "¶", 1, 1)),Big Text)]
Here we are setting the field in the newly created related record equal to the top row of the Big Text field. We do this by looking for the first carriage return and setting the related field equal to everything left of the carriage return. If there is no carriage return left ( which will be the case on the last piece of information ), we set the field equal to the big text field.

Set Field [ Big Text, Case( PatternCount(Big Text, "¶") ≥ 1, Right(Big Text, Length(Big Text) - Position(Big Text, "¶", 1, 1)), "")
Here we are slicing the top row off of the Big Text field because we have already placed it into a related record. We do this by seeing where the first carriage return occurs and setting the field equal to everything to the right of it. If there is no carriage return left ( which will be the case on the last piece of information ), we set the field equal to empty.

Exit Loop If [ IsEmpty( Big Text ) ]
When we have emptied the field, we want to loop to stop.

End Loop
Each Loop script step requires an End Loop script step as a matter of proper syntax.


An example file can be downloaded at ...
http://www.dwaynewright.com/blogfiles08/Parse6.zip
=
More info about the author and FileMaker in general, contact me at info@dwaynewright.com.

© 2008 - Dwayne Wright - dwaynewright.com

The material on this document is offered AS IS. There is NO REPRESENTATION OR WARRANTY, expressed or implied, nor does any other contributor to this document. WARRANTIES OF MERCHANT ABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY DISCLAIMED. Consequential and incidental damages are expressly excluded. FileMaker Pro is the registered trademark of FileMaker Inc.
====================== ADVERTISEMENT ==============================
Click Here To See The FileMaker Book (via a blog) homepage!
===================================================================

Saturday, October 11, 2008

EXAMPLE: Split Screen

From Dwayne Wright - Certified FileMaker 9 Developer
WEB: www.dwaynewright.com
EMAIL: info@dwaynewright.com
TWITTER: dwaynewright

In this example, we show you a portal on the left side of the screen with only the user name and a button to get more detail. On the right side of the screen, you can see the comments about a particular user. Clicking the More Details button allows you to see the details on the right.


This is very easy to setup. Our portal is of the universal / constant variety. You could use any portal you want here including a filtered portal. On the right, the fields are from a second relationship. A global field for the parent key and then the record id for the child file on the right side of the relationship.

The button in the portal row simply populates the global field with the record id you had chosen.

An example file can be downloaded at ...
http://www.dwaynewright.com/blogfiles08/SplitScreen.zip
=
More info about the author and FileMaker in general, contact me at info@dwaynewright.com.

© 2008 - Dwayne Wright - dwaynewright.com

The material on this document is offered AS IS. There is NO REPRESENTATION OR WARRANTY, expressed or implied, nor does any other contributor to this document. WARRANTIES OF MERCHANT ABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY DISCLAIMED. Consequential and incidental damages are expressly excluded. FileMaker Pro is the registered trademark of FileMaker Inc.

Friday, October 10, 2008

FILEMAKER: Split Screen With Portal And Detail View

From Dwayne Wright - Certified FileMaker 9 Developer
WEB: www.dwaynewright.com
EMAIL: info@dwaynewright.com
TWITTER: dwaynewright

As you know by now, it is quite common for a portal row to have a button that runs a GTRR operation. This typically is done because the user needs to see more information about a child record than what is shown in the portal row. The problem with this is that the user may get confused by two or more screens flipping back and forth. So you may want to create a single screen that still shows more information about a related child record.

With a split screen effect, the user sees is one screen with a portal on the left and the record details on the right. When the user clicks a portal row, the details of the portal row selection appears on the right. This is like using a GTRR script step except that you never leave the screen. Some users get very confused by multiple files and screens in a FileMaker database.

Under the hood, when a portal row is selected, it sets a primary key field that allows you to see it’s detail in the split screen format.

=
More info about the author and FileMaker in general, contact me at info@dwaynewright.com.

© 2008 - Dwayne Wright - dwaynewright.com

The material on this document is offered AS IS. There is NO REPRESENTATION OR WARRANTY, expressed or implied, nor does any other contributor to this document. WARRANTIES OF MERCHANT ABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY DISCLAIMED. Consequential and incidental damages are expressly excluded. FileMaker Pro is the registered trademark of FileMaker Inc.

====================== ADVERTISEMENT ==============================
To check out the online FileMaker Crosswords, please visit http://www.dwaynewright.com/crossword.html
===================================================================

Friday, October 3, 2008

FILEMAKER: E-Mailing Information In A Portal

From Dwayne Wright - Certified FileMaker 9 Developer
WEB: www.dwaynewright.com
EMAIL: info@dwaynewright.com
TWITTER: dwaynewright

We all know that email is the hottest new way to communicate since the paper and pencil. FileMaker has some basic email operations built in and of course you can also use plug-ins for more functionality.

The problem with e-mailing portal data is that it is spread out to 2 or more records. At the very minimum, we has the record in the primary file and the record in the child file. So what we need to do is combine all this information into a single field. Think of it as an assembly operation where you may need to combine a few scripts running in multiple files.

If you have FileMaker 8.5 or higher, the List function can be quite handy in gathering multiple related data that is displayed in a portal.

Another technique quite popular, global fields used with the SET Field script steps are great for providing a method to combine different pieces of text. You can script it so that all the child records are placed nicely into a global field. At the end of the operation, you will want to place the combined text string into either a standard text field or a global field that is suitable for e-mailing.

***Note: You can also use Copy, Copy Record, Copy All Records script steps to get information from related fields. I tend to stay away from all Copy related script steps because I don’t like interacting with the computers clipboard and I don't like the layout specific limitations it has. ***

Here are some links to other posts that might be of interest in regards to this topic...
The List Function
=
More info about the author and FileMaker in general, contact me at info@dwaynewright.com.

© 2008 - Dwayne Wright - dwaynewright.com

The material on this document is offered AS IS. There is NO REPRESENTATION OR WARRANTY, expressed or implied, nor does any other contributor to this document. WARRANTIES OF MERCHANT ABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY DISCLAIMED. Consequential and incidental damages are expressly excluded. FileMaker Pro is the registered trademark of FileMaker Inc.
====================== ADVERTISEMENT ==============================
For more information on the Virtual One On One Training, please visit http://www.dwaynewright.com/training.html
===================================================================