Jump to content
Salesforce and other SMB Solutions are coming soon. ×

How to trigger script on field exit?


davidelkus
 Share

Recommended Posts

I am using Filemaker and earlier to track customer orders. I would like to trigger a script to run once the user exits a field. Specifically, I would like to enter today's date in field "creditcardprocessingdate" once the user selects "paymentstatus"=processed in a pop-up options menu.

 

Thank you,

David

Link to comment
Share on other sites

Hi David,

 

You don't necessarily need script to do it. You can use Auto-Enter on the creditcardprocessingdate with:

 

Case ( paymentstatus = "Processed" , Status ( CurrentDate ) )

 

However, if User changes their mind and changes paymentstatus to something else, it won't remove the date. But you could also have field-level validation on the paymentstatus field, something like:

 

paymentstatus "Processed" and not creditcardprocessingdate or

paymentstatus = "Processed" and creditcardprocessingdate

 

You would set strict validation and require they remove the date, either manually or by clicking a button (which would blank the date). Script-step would be: Insert Calculated Result [ creditcardprocessingdate , "" ]. Provide a message (under validation tab) telling them they must fix it.

 

If this isn't something you can live with then you will need an event-trigger plugin to fire upon field exit. I've used scripts attached to popup menu (Windows) but I've heard the process (script attached to popup list) doesn't work well for Mac.

 

LaRetta smiley-smile

Link to comment
Share on other sites

Hi LaRetta

 

from your post: "I've used scripts attached to popup menu (Windows) but I've heard the process (script attached to popup list) doesn't work well for Mac."

 

Are you saying that a script can be executed from a popup menu, if so can you explain or an example, I'm working in Windows?

 

 

Thanks,

BLevey

Link to comment
Share on other sites

Well, it's been awhile since I've used vs. 6 and I don't have 6 here to refresh my memory.

 

The best idea is to look on the NightWing Enterprises website - that's where I got the idea originally. Either popup script menu or popup layout menu will do the trick - they both show how to use popup to fire script. You will notice that the popups are stacked and work on both platforms (testing platform to pop the correct one).

 

http://www.nightwing.com.au/FileMaker/demos3.html#d6

 

Now ... if you're Windows only (I believe) the loop can be skipped. In fact, I know I've used them without loop. But if they ever MAY be fired on Mac then I think it's best to be safe and implement them as a set. In that way you'll never be caught off guard. smiley-smile

 

LaRetta

Link to comment
Share on other sites

Thank you for the suggestions.

 

I like LaRetta's first suggestion, however I don't know how to force the user to change the value if the paymentstatus is changed (without my shipping manager putting his foot through the monitor).

 

Nightwings solution looks interesting. Since it is always looping, does it require lots of systems resources to operate?

 

Thank you for the terrific recommendations.

Link to comment
Share on other sites

Thanks LaRetta, this works for me.... I'm using it to select layout instead of having several button for navigation, just one popup menu to select the layout to goto, had to modify the script a bit, but it works... thanks agian and thanks to Nightwing for all their wonderful stuff...

 

Blevey

Link to comment
Share on other sites

Hi David,

 

"I don't know how to force the user to change the value if the paymentstatus is changed (without my shipping manager putting his foot through the monitor). "

 

Well, we can't control your shipping manager. But FM will control the User. If validation is set to Strict, Do Not Allow User to Override, the User can't do anything else until they 1) click your button to remove the date, 2) change the date themselves or 3) revert the record to Processed. If your Shipping Manager can't follow the business rules, well then ...

 

Looping scripts on popups are no big deal. After all, how long is a popup popped? I've used scripted popups on some real dawgs and haven't noticed a problem. And on Windows, the popup menu will STAY popped (without loop) until the User makes a choice. I suggest including both popups because, well, I put a windows-solution-only in effect on this last design. The owner swore we would NEVER have a Mac person. Guess what? Yep, we hired a Mac Sales Manager who brought in his own system. Adding the functionality after-the-fact is harder than adding it to begin with and FM is, after all, cross-platform.

 

I would suggest trying both methods. You'll have your answers quickly enough. And if neither fits your needs, the NightWing site also has a link for a FREE event trigger plugin. And NightWing wouldn't recommend trash.

 

There is another option ... change your process. Whenever I've found a process to be clunky, it's usually an indication that a different approach might work better. Example: Our orders are put into a shipping queue and locked from further modification. Script prints a list of those orders flagged to be paid by credit card then stores that count in variable (or global). After person enters payments (or after upload to credit card center), script will loop set all payments (date card charged) in one whack. Script is heavy in validation and error trap (and protects from record locking) and when orders are put in shipping queue, the physical ship date is also set (so we can rerun a process if system crashes and we lose global contents). Finally, script verifies that count of orders to be charged to credit card matches orders set with DateCardCharged.

 

There are many ways to get things done. If you can't go through (that shipping manager, smile), simply go around. smiley-laughing

 

LaRetta

Link to comment
Share on other sites

Hi Blevey,

 

You have 79 posts but still haven't updated your profile with your OS or FM version? You aren't going to get accurate help without providing that information. Oh Really!

 

"had to modify the script a bit"

 

I'm unsure why. But then, since I don't know your OS or FM version, I couldn't even make a reasonable guess.

 

Anway, here is a greatly simplifed (and much uglier) example. Forget the guts of the file - it was for another purpose. It stores the VL contents in global and performs a find - firing after User makes selection. And ... NO LOOP REQUIRED. The loop is necessary when the solution is xplat. This is a WINDOWS ONLY and vs. 7/8 (sorry Mac folks, it probably won't work right for you). I don't own a Mac (yet) so couldn't even test it.

 

LaRetta

Link to comment
Share on other sites

Hi Blevely,

 

I finally had a moment to peruse your file. I can turn your 21-line script into 5. Try this:

 

Allow User Abort [ Off ]

Go To Field [ Select/perform RXO Menu One::gMenu ]

Pause/Resume Script [ Duration (seconds): 1 ]

Commit Records/Requests [ skip data entry validation; no dialog ]

 

... this is the fun part ...

 

Go To Layout [ LayoutName by Calculation = RXO Menu One::gMenu ]

 

Just make sure your value list stays in synch with your layout names.

 

LaRetta smiley-smile

Link to comment
Share on other sites

Hi LaRetta,

 

Wow.... I know there's always easier ways of doing things, just didn't think it was that easy... thanks... I just need to think more abstractly... One question, why the commit recoreds/request script step... ?

 

Thanks,

Bob

Link to comment
Share on other sites

Commit Records/Requests isn't always necessary. But it is safe. And if one were opening another window or moving to a related record, the cursor could remain in the prior field and produce record-locking issues in multi-user.

 

I noticed you used Go To Field[]. In prior versions, we had Exit Record/Request. Commit Records/Requests replaces both. When I script, I always visualize where that cursor is and, when finished with a record, I pull my cursor up (so to speak) if I've entered a field.

 

LaRetta smiley-smile

Link to comment
Share on other sites

 Share



×
×
  • Create New...

Important Information

Terms of Use