In my database script I am checking to see if a user has a profile document when first opening the application. To do this I am using Set pdoc = db.GetProfileDocument(“user_profile”,session.UserName), then checking for setting on the profile document if found. The GetProfileDocument command creates a profile record even if one does not exist. I don’t want to create one if one doesn’t exist and I have not found a way to avoid creating a blank profile record. I have tried:
If pdoc.IsNewNote Then
Call pdoc.Remove(True)
End If
but this does not seem to work. Any help to prevent creation of a profile document when one does not exist and or to be able to delete it right after the check if new and or blank after the check would be very much appreciated.
Why don’t you want to create a profile document for each user? I assume you are checking a field on the profile document to see if it contains a specific value. In that case, the field would be blank on new profile docuemnts, and have a value for the users that in your logic would have a profile document.
If you have such a large number of users that you are afraid that you will have too many blank documents (perhaps you have 10,000 users but only 50 who need a profile document to store some information). Then the easiest would be to just duplicate the functionality with a view where you perform a lookup against the name, and where you display one document per user with profile document:
Create a form “UserProfile” with two fields, one for the user name and one for the value you want to get.
Create a view “LookupUserProfile”, with the first column containing the user name and categorized.
In your code, you just do a view.GetDocumentByKey(session.CommonUsername)
Not very complicated, just a few more lines more than using the GetProfileDocument() method.