beretta819
asked on
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.
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.
ASKER
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)
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)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.