2 Replies Latest reply on Dec 18, 2015 7:24 AM by jbroderick57

    Issue setting a global field from one layout to another with portal involved




      Apologies up front for a lengthy set up on what is probably a simple solution - perils of self-learning.


      I have a file which acts as a work order system for repairs of small equipment, such as iPhones.


      There are these tables involved in my question (there are more like Vendor, etc. but they aren't pertinent):





      Items (Parts and Labor descriptions for repairs)

      Line Items - portal is used on the Invoice layout - pretty standard


      Each customer could have more than one device and so each invoice could also show a different device if the customer brings a device in for repair.


      I created a portal on the Invoice layout for the Equipment to be shown (just two portal rows) - shows Equipment unique ID (FileMaker unique serial), Color, Equipment Type, Carrier, Serial number (actual).


      I also created a Global field for Equipment Type to enable a drill down of the parts from the Items, based on the Equipment Type (iPhone 5S for example).


      The sequence of creating the Invoice is - create Customer, create Equipment record related to Customer, Create Invoice related to Customer with specific piece of Equipment.  Each step is scripted from layout to layout  Customer>>>Equipment>>>Invoice


      I created a script which creates a variable based on the Equipment Type from the Equipment table - (Equipment::Equipment Type). When the invoice is created, the Invoice::gEquipment Type global field is set on the Invoice layout. I used a global because I've seen filtering done for value lists using this method.


      Here's what happens and my question.


      Let's say there are two pieces of equipment for John Doe.  One is iPhone 5C and the other is iPad Air 2, in that order.


      When I hit the Create Invoice button and the script creates the invoice record along with setting the global, it will always display the first equipment piece in the portal - iPhone 5C, even if the iPad Air 2 was the equipment piece selected.


      Also, the global will show whatever description was in the equipment when the invoice was created but will change the same field in all of the invoice records.  Maybe I shouldn't use a global here and just filter it from the Equipment::Equipment Type showing in the portal row?


      Sorry again for the long description.


      What's the best way to accurately show the current selected equipment on the invoice while still keeping it related to the customer?

      What is the best method to set a field (will probably use for a PatternCount style filter) for the value list drill down for Type to limit the parts to the correct parts for the type?

        • 1. Re: Issue setting a global field from one layout to another with portal involved

          Two pieces of information that I think will be helpfull:


          A global field, as you've discovered, has the same value regardless of what record you are on. It's this characteristic that makes it attractive for filtering, since when you set, for instance, begin and end dates into globals, they'll be set as you go from record to record.


          (Other "oddities" include: You can set or retrieve it from any table, even if you're not related or even if there's no record for the global to be in. The value is unique to the user session, which means two users can have different values in the same global field. The default value in a global field is the value that was in the field the last time it was closed while hosted in fmpro. Also, you can set and retrieve values in globals while in find mode, and they won't affect the search criteria. Globals are a really powerful tool... but they are also pretty unusual, so it'll be worthwhile for you to learn more about them.)


          Another is that if you have a relationship to multiple records, and show a field via relationship, but outside the context of a portal, you'll get the first related record. To see all related records, you need a portal.




          Chris Cain


          • 2. Re: Issue setting a global field from one layout to another with portal involved

            Thanks for the clarification.  It's been a while since I had time to work on this and I appreciate your teaching.


            As far as getting the correct equipment on the Invoice form, I did abandon the global definition of that field -  I can see from your description that this isn't the best method to set the equipment information and for the sake of training someone to use it, I felt that a one line portal with a scroll bar was a little kludgey in this iPad app, although the portal did work, as suggested.


            Since the equipment description was really only for reference on the invoice copy and there is a separate table and invoice for equipment for searches, etc., I did a cheat and created equivalent fields in the Invoice table and then set variables from Equipment and set fields to the Invoice fields.  Probably not a good long term approach for all solutions and I'm aware of that.


            Later, I think I will spend the time necessary to learn and create the proper table occurrences to enable showing the equipment on the invoice copy so there is less code and better conventions followed.