Have you looked up Get ( ApplicationVersion ) in FileMaker help? It never returns "web" as a result. It returns a larger chunk of text that contains the word "web". The examples you saw should have used PatternCount to check for the word "web" in the string of text returned by this function.
Substitute your table and field names for mine....
If [ PatternCount ( Get ( ApplicationVersion ) ; "web" ) ]
Set Field [ YourTable::webCounter ; YourTable::WebCounter + 1 ]
Please note that the above set field step will not work in the wrong layout context. The script shown should be executed while a layout based on "yourTable" is the current layout.
When Setting up Set Field, there are two Specify buttons that must be clicked. To get Set Field [Table::Field ; Expression], add set field to your script and click the first button (specify target field). Select Table::Field from the list of fields. Do not click the specify button next to the repetition box. Click OK to close this dialog box. Now click the lower specify button (calculated result) and create the expression to the right of the semicolon (;). Do not try to type in the semicolon.
I was using "PatternCount" sorry I forgot to say that. SO I did everything as you said (it was mostly what I did before except that I didn't have the field specified before the +1 in the second line). My script now mimics yours but when I launch the IWP solution nothing happens. Isn't that field supposed to go to 1, and then 2, then 3 etc.. as I visit it? Maybe I don't have the script trigger in the right place? I have it under file > file options > script triggers > OnFirstWindowOpen is this correct?
What trigger did you select to run this script? And on what layout?
The OnFirstWindowOpen Script needs to be set to run this script. And it should be run with a layout that is based on the table where this counter field is defined or for which a valid relationship to that table exists.
And the counter cannot be a global field either or the changes made to its value will not persist when the file is closed.
I created the script that you said and I told it to run "OnFirstWindowOpen" (so that means when the file is first opened run this script, correct?) I also, under file options, have said always to go to the "home" layout which is where I have my counter so it should always be the first layout anyone sees
the field is a text field (wasn't sure if it would work under number) and it is not global and not indexed
what am I missing?
I would make it a number field not text, but it should still increase by one each time a different web client accesses the database.
have said always to go to the "home" layout which is where I have my counter
Yes, but in what Table is the field defined? And is an Tutorial: What are Table Occurrences? selected in Layout Setup | Show Records From?
If you are familiar with the starter solution layouts in FM12 I am using one of those that is called "product catalog". I have modified it a bunch but the table where I have my counter is, is called "Company Info" since the first page, what I am calling the home page, has the logo and contact information for the institution and for its layout it is "showing records from" the company info table.. My counter field belongs to the "company Info" table and it is currently displayed on the home page so I can see if the number changes when I access the IWP solution online.
As for an occurrence of the table, I haven't really done a lot with the ERD in this solution but when I just looked now the "Company Info" table did not show any of the fields for that table. I created a second "company info" occurrence which does show the fields but it didn't seem to change anything. Should I delete the first occurrence?
I attached a screen shot of the ERD
Okay so apparently now it will track when I open the file from my desktop but it doesn't seem to see it when I open it from online. I guess the fact it is counting something is good but I ONLY want it to count times people access the file online
you can view the site at www.vmnhgeocat.org ... i notice that the counter changes on the web sometimes but not every time... but it sill certainly changes when I open the file on my desktop which I do not want to happen.
sorry for the barrage of messages, wanted to keep you updated on my findings
Okay so apparently now it will track when I open the file from my desktop
This suggests that you have the logic reversed so that your script is detecting when the user has NOT opened the database from a web browser or you would not get a counter being incremented when you open it from FileMaker Pro--or am I misunderstanding how you are opening the file from your desktop.
On a different note, what you show in your screen shot is so different from the original Starter Solution that it might as well be a new design from a "blank page". And the absence of any relationships raises concerns about whether your database functions correctly or not.
This "Database" is really just a pretty layout for viewing and searching metadata. The database which institutions can export their data from/to this layout has a million relationships (you have seen it in previous questions). This is more of a viewing portal.
The way I open my file is from a shortcut on the desktop, and it picks up that I've opened it. It also seems to document when I visit the website now (I deleted a few behind the scenes things I didn't know were happening) so now it seems like the script is reading the second line of text which is saying for the counter in the company info table to increase by 1 when the file is opened but it's completely ignoring the first line. It is doing this every time the file is opened regardless of from where. How can I check to see what is happening in the first line of the script? Can I set the output of the "Get" function as a variable and then set that to a field?
Okay new idea...
Can I get the "version" for who is logged in? As in "guest" "full access" etc? Because on my desktop version it auto-logs in an "full access" whereas online it is "guest/read only" so maybe I can do it that way?
That doesn't seem to work, maybe because the login and script are essentially running at the same time? So back to my original plan. You said "Get ( ApplicationVersion ) ...never returns "web" as a result. It returns a larger chunk of text thatcontains the word "web"" so how do I SEE what this "chunk" is? Maybe that will help me figure out what is going on...
I figured it out -sort of. It seems like when you close your window online you aren't really "logged out" of the system and once this happens 4 times it stops counting. I put an "exit application" button on the IWP solution to test it and every time I logged in the counter went up one, as long as I also "logged out". This is a huge problem because no one is going to think to log out. Not even I think to do it without a huge button to remind me and that's only on one page, they could exit from anywhere on the site.
The thought I had was to install a timer trigger so that once 20 minutes passes it auto logs out. I think this will solve most of my problems as I now do not have it counting when I open it from the desktop which was the other issue but somehow I did fix that. I am sure there are tutorials for timers so I'll look those up and get back to you if it works.
Thanks for all the ideas though, sometimes it just takes some good 'ol brainstorming!
I suggest posting the complete, actual script so that we can see every detail of it.
To post a script to the forum:
- You can upload a screen shot of your script by using the Upload an Image controls located just below Post a New Answer.
- You can print a script to a PDF, open the PDF and then select and copy the script as text from the opened PDF to your clipboard for pasting here. (with this approach, you can get multiple script steps on the same line, please edit the pasted text by inserting some returns to separate those steps.)
- If You have FileMaker Advanced, you can generate a database design report and copy the script as text from there.
- If you paste a text form of the script, you can use the Script Pretty box in the Known Bugs List database to paste a version that is single spaced and indented for a more professional and easier to read format.