Script: Finding a record marked with a field equal to AccountName

  • Follow


Hi all,

I have to make a Web interface where the user has to input data on his
record only.
So I marked the record with a field containing his AccountName.

When the user logs in, FM should position on his record only, and the user
could enter data. Navigation will be impossible because there are no
buttons, just the "commit" to save (and to be safe other records are "no
access" using a privilege rule with AccountName).

The difficult part seems to position the layout at the open event, using a
script.

- I tried to use the Goto Record, but it seems it accepts only a number.
- I tried to enter the find mode, then setting the account field equal to
GetAccountname and then performing the find, it works on the client but NOT
ON THE WEB.

Some hints?

Ciao,

E.



0
Reply Ag 10/27/2004 5:43:57 PM

I have written several web apps using V7.  The following works well.

Go to the file menu
Define Accounts & Priv.
Create an account with a custom set of privileges
In the Data Access and Design area
Select the Record Combo box
Create a Custom Privilege
Set the View Tabl to Limited
Enter the following code: (where User is a field you created to store the 
Users Login Name)
User = Get ( AccountName ) or User ="" or IsEmpty ( User )

Then, write a script so when the user logs in it automatically finds all 
records with the users name.

Hope this helps.
Paul

"Ag" <nospam-nonono@libero.it> wrote in message 
news:2ua56dF28a2q8U1@uni-berlin.de...
> Hi all,
>
> I have to make a Web interface where the user has to input data on his
> record only.
> So I marked the record with a field containing his AccountName.
>
> When the user logs in, FM should position on his record only, and the user
> could enter data. Navigation will be impossible because there are no
> buttons, just the "commit" to save (and to be safe other records are "no
> access" using a privilege rule with AccountName).
>
> The difficult part seems to position the layout at the open event, using a
> script.
>
> - I tried to use the Goto Record, but it seems it accepts only a number.
> - I tried to enter the find mode, then setting the account field equal to
> GetAccountname and then performing the find, it works on the client but 
> NOT
> ON THE WEB.
>
> Some hints?
>
> Ciao,
>
> E.
>
>
> 


0
Reply Paul 10/28/2004 1:47:46 PM


Thanks Paul for your reply,

(I'm back in office now)

I already did the privilege setup allowing only the logged on user to access
his records.

My problem is the script.
The difficult part seems to position the layout at the open event, using a
script.

- I tried to use the Goto Record, but it seems it accepts only a number.
- I tried to enter the find mode, then setting the account field equal to
GetAccountname and then performing the find, it works on the client but NOT
ON THE WEB.

There will be only one record per user, so a Find will be enough.
(on the web interface I will disable the navigation buttons to avoid the
annoying thing of seeing the other records with the <no access> message)

I will work on it and post my solution if I will find one!

Ciao!

Enrico.


"Paul" <pzspam@rogers.com> wrote in message
news:k7CdnfIulZMYZR3cRVn-vQ@rogers.com...
> I have written several web apps using V7.  The following works well.
>
> Go to the file menu
> Define Accounts & Priv.
> Create an account with a custom set of privileges
> In the Data Access and Design area
> Select the Record Combo box
> Create a Custom Privilege
> Set the View Tabl to Limited
> Enter the following code: (where User is a field you created to store the
> Users Login Name)
> User = Get ( AccountName ) or User ="" or IsEmpty ( User )
>
> Then, write a script so when the user logs in it automatically finds all
> records with the users name.
>
> Hope this helps.
> Paul


0
Reply Ag 11/4/2004 10:53:19 AM

Hi out there,

As promised, I reply to myself:

So, there is one record for each user, with a field equal to the account
name.

The problem is how to let the user to access his record without seeing the
others.

The first thing is to set up the privileges to read only his record (see
previous messages).
The second is how to position the user on his record, if the record doesn't
exist must be created.
Navigation buttons are suppressed, so no previous/next will be possible.
Here follows how I did.

I open the layout with the following script.

Go To Layout [LayoutName]
Set Error Capture [On]
Show all Records
Go To record [First]
Loop
    Exit Loop If [layout::UserName=Get(AccountName)]
    Go to Record [Next; Exit after last]
End Loop
If [Layout::UserName=""]
    NewRecord
End If

The "Search" loop seems something primitive since I'm supposed to use a
database-like tool, but I couldn't find out anything better.
Important, this works on the Web publishing side.

Comments or suggestions are welcome.

Enrico.


0
Reply Ag 11/4/2004 1:47:40 PM

Ag wrote:

> Go To Layout [LayoutName]
> Set Error Capture [On]
> Show all Records
> Go To record [First]
> Loop
>     Exit Loop If [layout::UserName=Get(AccountName)]
>     Go to Record [Next; Exit after last]
> End Loop
> If [Layout::UserName=""]
>     NewRecord
> End If
> 
> The "Search" loop seems something primitive since I'm supposed to use a
> database-like tool, but I couldn't find out anything better.


Why not just do this with a find:

Set Error Capture [On]
Enter Find Mode []
Set Field [layout::UserName; Get(AccountName)]
Perform Find []
If [Get(FoundCount)=0]
	New Record
End If

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Howard Schlossberg              (818) 883-2846
FM Pro Solutions       Los Angeles, California

FileMaker 7 Certified Developer
Associate Member, FileMaker Solutions Alliance
0
Reply Howard 11/4/2004 4:21:33 PM

Thanks, now it works.

I said that the find method doesn't work on the web interface, but now it
works.

In fact the first time, today, it didn't work and displayed just a white web
page, but next attempts went ok.
I don't know why and what I did before, but thanks a lot!

Enrico.


"Howard Schlossberg" <howard@antispahm.fmprosolutions.com> wrote in message
news:10okloelnje9n44@corp.supernews.com...
> Ag wrote:
>
> > Go To Layout [LayoutName]
> > Set Error Capture [On]
> > Show all Records
> > Go To record [First]
> > Loop
> >     Exit Loop If [layout::UserName=Get(AccountName)]
> >     Go to Record [Next; Exit after last]
> > End Loop
> > If [Layout::UserName=""]
> >     NewRecord
> > End If
> >
> > The "Search" loop seems something primitive since I'm supposed to use a
> > database-like tool, but I couldn't find out anything better.
>
>
> Why not just do this with a find:
>
> Set Error Capture [On]
> Enter Find Mode []
> Set Field [layout::UserName; Get(AccountName)]
> Perform Find []
> If [Get(FoundCount)=0]
> New Record
> End If
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> Howard Schlossberg              (818) 883-2846
> FM Pro Solutions       Los Angeles, California
>
> FileMaker 7 Certified Developer
> Associate Member, FileMaker Solutions Alliance


0
Reply Ag 11/9/2004 2:12:14 PM

5 Replies
280 Views

(page loaded in 0.039 seconds)

Similiar Articles:













7/28/2012 7:37:34 AM


Reply: