Filemaker 13 Pro - Script to verify user makes entry into portal

Hi All;
I have a layout (user) with a portal to a join table. On the layout is a button that runs some script. I need to make sure that the user has made an entry into the portal before allowing the script to run. If they click the button without an entry, show a dialog reminding them it is required.

I tried an isempty script looking at the join table, but it does not work if the user has not attempted an entry. (ie no entry at all - or entry is made and then deleted.)

I assume that another way would be to search the join table to see if the ID from the new record on the user layout is there, but I can't find an example to lead me down that path.

Thanks in advance for any help.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Will LovingPresident, Dedication Technologies, Inc.Commented:
Your script may need look at several conditions to ascertain if the user has made an entry. The example below assumes that

1. "RelatedTable" is the table being displaying the portal
2. That RelatedTable has a serial number field I've called "Related Record ID"
3. That RelatedTable has auto-enter fields for "CreatedUser" and "CreatedDate"
4. That the user is logged in using their own person login credentials rather than generic credentials
5. That the portal is sorted on a relationship level so that the most recent entry is at the top

If [

// No records in portal...
count( RelatedTable:: Related Record ID ) = 0 or

// First record in portal was not created by this user...
RelatedTable::CreatedUser <> Get ( AccountName ) or

// First record in portal created by this user, but not today...
( RelatedTable::CreatedUser = Get ( AccountName ) and RelatedTable::CreatedDate <> Get ( CurrentDate ) )


Show Custom Dialog [ "You must create an entry before leaving this layout..." ; "OK" ]

Of course if someone might make multiple entries on a given date then you'll need to refine this a bit. One way to do that would be to have their access to this screen be scripted such that you set a flag and pause the script while they do or do not make an entry. Assumedly you have a button that is used to create a new portal entry (which is much preferred over letting them scroll to the bottom of the portal) so you can use that and the Delete portal record button to update a script variable like $EntryMade. When they try to exit the layout by clicking "Continue" the script continues and checks the value in $EntryMade to see that they made an entry and didn't delete it.

So, a couple of many possible ways of solving this.
beretta819Author Commented:
Thank you...

To be more specific I have a "User" table, a "Discipline" table, and a Join table between the two. The User layout is to create new user accounts where the Admin will add a new user and choose their discipline from the portal that is attached to the join. I don't ever want them to be able to add a user without choosing that user's discipline(s).

Both the user and discipline tables have ID primary keys that end up in the join table.

There will never be duplicate users, so I only need to check to see if the users P-ID is present in the join. (So USER 5 will have multiple discipline IDs so the 5 will show many times.) So I just need to know that the 5 exists in the join. (I think)
Will LovingPresident, Dedication Technologies, Inc.Commented:
Instead of switching layout for new user entry, you might consider making a popover with some global entry fields: First, Last, five Discipline fields using popup menu with a value list that has the Discipline ID and the name but only shows the name. When the person entering hits a Continue button, a validation check looks for both name fields and at least one Discipline selected. If it's missing you loop the user back into the popover with a dialog saying what's missing. If it's good to go, then the script creates the new USER record, captures the ID and then creates the Discipline records and clears the globals.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
FileMaker Pro

From novice to tech pro — start learning today.