Title
Need help : User Logs into a blank data entry form to create new record only
Post
I am a beginner with FMP 11.
I've done hours of searching for a couple days, while at the same time fiddling around with the actual FMP database itself. But I can't seem to grasp the concept of what I'm finding to figure out how I would apply it to my situation.
I'll try to keep this simple. I have a Customers table, and a Sales Rep table. There is a SalesRep field in the Customers table that I use to relate the two tables. I've created accounts for each Sales Rep to access the database (but the account name is not the actual Sales rep name). I know it has something to do with defining custom privilege sets, but I can't seem to get it right. What I want is that when a Sales Rep logs into the database, that he/she is brought to a blank New Customer layout form that is prepopulated with the Sales rep's information such as id, name, phone number, etc. I want it so this new customer layout form is the only layout/table/form that Sales reps have access to. The sales rep would simply fill out any new customer information and commit the record. But I want it so that they cannot view or access any other Customer record. The purpose of the form would be for a Sales Rep to create new customer records only, and have that new customer record related to the Sales Rep whose account is loggin in.
Can someone please explain it simply enough so that I can understand the concepts I need to make this happen, and then explain it again in specific details so that I can try to walk through it step by step?
First a little background reading should help. If you have not already done so, please see "Editing record access privileges" in FileMaker Help and check out this particular sub section: "Entering a formula for limiting access on a record-by-record basis".
In this case, we need a lock expression that only enables the sales rep to see the current record only.
What is not clear to me is why you don't want the sales rep to see records they have entered previously, but that's a function of your business practices more than the database design. You might, however, need a way for a SalesRep to be able to re-open and edit their most recently created record if they discover that they've made a mistake only after they have committed the record.
There are several ways you can set a flag that limits them to the current, newly created record only. I'm going to use a method that allows you to unlock a record for salesRep access should you discover that you need to in order to enable the SalesRep to correct errors.
If you don't have a field like this in your table already, define an auto-entered serial number field to uniquely identify each record. I'll call it CustomerID for the purpose of this example. Define a global number field, gCurrentCustID. Now use this record access formula to control access:
( CustomerID = gCurrentCustID )
If there are non sales rep users that do need access, you can change it to:
( CustomerID = gCurrentCustID ) or ( get ( AccountPrivilegeSetName ) = "PrivilegeSetNameInQuotes" )
When the Sales Rep clicks the button to access this layout for new customers, run this script:
New Record/Request
Set Field [Customers::gCurrentCustID ; Customers::CustomerID]
That creates a new record with access permitted.
Add a Save Button that does this script to lock the record when the SalesRep has completed the record:
Set Field [Customers::gCurrentcustID ; "" ]
If you need to unlock a record for SalesRep access, you can write a script that asks for a manager password in a Show Custom Dialog and then uses set field to assign the current customerID value back to the global gCurrentCustID field.