Jump to content

Help with EXPENSE REPORT Example


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

Recommended Posts

I'm updating my company's Expense Tracking solution, and have borrowed doe of the example content from this older, FMP template file.  There is a feature of this solution, that I cannot reverse engineer for the life of me.

The attached solution has a single DATA table is used in two relationships - one for "Expenses" and one for "Mileage".  The Form view shows the data in two portals, which are filtered by a related field, Type | MATCH FIELD.  When you add a new record to the respective portal, the Type | MATCH FIELD auto-enters one of two values - Expense or Mileage.  I cannot figure out how "Mileage" is auto-entered for that portal??  The calculation is:

 If ( IsEmpty ( Self ) ; "Expense" ; Self ) 

so I see a reference for 'Expense" to be entered.  I have searched for variables, script triggers, etc. and cannot find the answer??

 

Please help.  I would normally create a separate table for the two expense types, but wanted to understand this execution.

 

Expense Report.fmp12

Link to comment
Share on other sites

The field in question is a match field and is populated in the same manner as the other match field. When you create a child record through a relationship, the child match fields automatically inherit the parent match fields values. 

I would have expected a much simpler solution, where there would be only one relationship, and the portals would be filtered by type. Then the child type field would be populated according to the portal where it was created - see: 
https://fmforums.com/topic/81855-getting-more-out-of-filtered-portals-7-creating-new-records-in-filtered-portals/?tab=comments#comment-379712

 

 

Edited by comment
Link to comment
Share on other sites

I understand your explanation, and fully understand how match fields work between parent/child relationships.  My question is specific to how the FMP Sample file executes the insertion of the appropriate value.  Like I mentioned in the initial post, the subject calculation field makes reference to auto-entering "Expense", but I find no reference to "Mileage" in the calculation(s), scripts, or other areas?  For the life of me, I cannot determine how they have executed the functionality of entering "Mileage" into the subject field when a new record is added to the Data | Mileage portal???

I have realized that this is an older explore, that likely doesn't take full advantage of some of the newer features in FMP, but it's killing me that I cannot figure this one out???  If someone can shed some light on this specific example, I would appreciate it.

Link to comment
Share on other sites

The auto-entered calculation on the 'Type | MATCH FIELD' field in the Data table is a red herring. The only time it will be activated is if you create a new Data record in a layout of the Data table. It has no application when you add new records through the portals. You can remove it and the file will continue to populate the correct type according to the portal you used to enter the record.

There is a `TYPE EXPENSES MATCH FIELD` global field in the parent Expenses table. It contains the text "Expense". This field is a match field in the relationship to the `Data | Expenses` TO:

image.png.cfe0fe7654f9a9d7d857d8a58cae5bd3.png

When you create a new record in `Data | Expenses` through this relationship, the _kf_EXPENSE NUMBER KEY FIELD will be automatically populated using the value of the EXPENSE NUMBER PRIMARY KEY from the parent record, AND the Type | MATCH FIELD field will get its value from the global  TYPE EXPENSES MATCH FIELD field. 

Likewise for the other relationship using the other global field TYPE MILEAGE MATCH FIELD which contains the text "Mileage".

 

 

Link to comment
Share on other sites

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