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

Script Trigger catching Tab and enter key strokes


Bobg
 Share

Recommended Posts

When my script trigger runs what is the logic to capture a Tab or enter key stroke. Also I

have a summary calculation in a field that does not run. Is there a way to trigger a summary

calc while I'm in the script of the script trigger?

 

Thanks

Bob Green

Link to comment
Share on other sites

Code (Get (TriggerKeystroke)) returns a number. Tab is a 9. Enter (the real Enter key, the one on the numerical keypad at far right of your keyboard) is 10. RETURN (the key sitting above your Shift key that you hit to make a hard return, erroneously labeled "Enter" on most PC keyboards) is a 13.

 

To obtain a summary value you can use the GetSummary (NameOfASummaryFieldHere; BreakField). If it's a grand total you want you use the name of the summary field a second time where it asks for BreakField.

Link to comment
Share on other sites

Thanks. That's exactly what I needed to know. My problem now is how do I

enter commands like, GetSummary (NameOfASummaryFieldHere; BreakField) and

(Get (TriggerKeystroke)) into my script trigger? It doesn't seem to offer me those

options in my script window.

 

Bob Green

Link to comment
Share on other sites

I don't know what you mean by "enter them into my script trigger".

 

The triggered script itself should have IF statements. It should exit if some conditions are not met, without doing anything. It gets triggered either way but only DOES STUFF if the relevant trigger keystroke is found etc etc etc.

Link to comment
Share on other sites

When I am in my edit script window the vertical scroll window has

subject areas like Control, Navigation, Editing, Fields, Records, Found

Sets, Windows, Files, Accounts, Spelling, Open Menu Item, and Miscellaneous.

None of the GetSummary or Get (TriggerKeystroke) commands are listed in

the window for me to use. How do I enter them into my script if I can't click

on them in the left vertical window?

 

Bob Green

Link to comment
Share on other sites

Thanks John,

Almost makes me want to buy version 11 just to use the OnObjectValidate command. I never heard of Six Fried Rice before.

Seems like a good resource. Thanks for the tip.

 

Bob

Link to comment
Share on other sites

When I am in my edit script window the vertical scroll window has

subject areas like Control, Navigation, Editing, Fields, Records, Found

Sets, Windows, Files, Accounts, Spelling, Open Menu Item, and Miscellaneous.

None of the GetSummary or Get (TriggerKeystroke) commands are listed in

the window for me to use. How do I enter them into my script if I can't click

on them in the left vertical window?

 

Bob Green

 

 

They aren't script steps, they're functions.

 

You HAVE scripted before, yes? You realize that functions are up on top (or manually keyed in from memory), not selected from the left pane?

 

 

Examples of functions: Get (Current Date), Get (FoundCount), Get (TriggerKeystroke), List, Sum, Average, IsValid, IsEmpty, etc etc et

Link to comment
Share on other sites

Almost makes me want to buy version 11 just to use the OnObjectValidate command. I never heard of Six Fried Rice before.

Seems like a good resource. Thanks for the tip.

 

Bob

 

If I remember correctly, you would need FM Pro 10 Advanced or 11 Advanced to be able to create Custom Functions.

Link to comment
Share on other sites

Hi Josh,

 

I lived in Rochester for 40 years after leaving RIT and opening my own business.

I'm not trying to write a function I'm trying to write a script trigger. I think AHunter3

has confused what I asked or I didn't ask it correctly.

 

Bob Green

Link to comment
Share on other sites

Bob Green...hmmm. That name sounds familiar. You do teaching of some kind, correct? Or racing? Both, maybe?

 

Ahunter3 was pointing out the use of functions within the If statements in the scripts. Because the script will always execute with a given event, defined by the name OnLayoutLoad or OnObjectEnter etc, you trap for the execution of specific tasks based on tests. The basic idea is this:

  1. Script fires (it will always fire with the given event. ie - OnObjectKeystroke fires with every keystroke)
  2. If the user hit Tab, Enter or Return
  3. Then do this
  4. If not, Exit Script.

I can but together the exact syntax if you need me to. But I need to be sitting in front of FM to do that. Just ask and I'll do it when I get home later tonight.

 

Edit: Think of it this way. Script Triggers use Scripts. Scripts use script steps. Some script steps use the calculation dialog. The calculation dialog uses Functions. It's all connected. :chuncky:

Link to comment
Share on other sites

Yes Josh, that would be great. Thanks. I owned a business in Rochester called Sentry Color Labs.

The only teaching I did was connected to live theatre. I taught ten to fourteen hour courses on major

plays like Les Miserables , Phantom of the Opera, Miss Saigon, etc. I've taught for the Downstairs

Cabaret Theatre and The Rochester Auditorium Theatre.

I'm headed out for dinner with friends. I'll check back in around midnight tonight and see if you could get to it.

 

Bob Green

Link to comment
Share on other sites

I just wrote a long explanation and lost it. Maybe I’ll start writing in a word processor to play it safe! OK, I’m not trying to use a function.

What I’m trying to do is to force a summary field to recalc, if that is the correct word. Here is the set up and there are two problems.

 

1. I’m in a portal

2. I have written a script trigger to place the cursor into a new field when the user tabs or uses the enter key or enters a valid date with a drop down calendar.

3. The original field is called SaleDate

4. When the user enters a date I’m finding that the portal does different things if the user hits enter and hits tab. When the user hits tab my script trigger does not run. I want it to run! When the user hits enter it does run. I want it to run! When it runs it does everything correctly. However; I have a field, in the table that is a summary field that does not recalculate. (It counts the number of the fields in the found set of SalesDate that are not empty) This would inform the user that another line item has sold. If the user clicks out of the portal it does forces the recalc of the summary field but I need it to recalc.

5. Here is the script that runs when the trigger activates:

 

If [Case(Line Items::SaleDate”” and Line Items::Sold Price=””;1=1)]

Commit Records/Requests[No dialog]

Go to Field [Line Items:: Sold Price]

 

Once I place the user in the Sold Price field I will require them to enter an acceptable price for the sale

then another script trigger will run to place them in a drop down list answering where the Line item was sold.

(which store, etc.) I require the user to answer these three question when the line Item is sold but I need the

summary field to recalc. and I need the script trigger to run when either the tab, enter or the user clicks on the drop down calendar

Link to comment
Share on other sites

I need the script trigger to run when either the tab, enter or the user clicks on the drop down calendar

 

Let's start with this part.

 

Get RID of the idea that the script can be set to only fire when the user tabs, uses enter key, or clicks the dropdown calendar. You can't set that up as a condition of triggering or not triggering a script.

 

Instead, if your existing triggered script is not triggering properly when someone tabs, attach a different script as a script trigger at the layout level, OnLayoutKeystroke.

 

Then IN THAT SCRIPT ITSELF you check to see if the user did not tab. If the keystroke wasn't a tab, exit script. If it was a tab, commit recs and perform your original script.

 

If

... Exit Script

End If

Perform Script [YourOriginalTriggeredScript]

 

 

 

 

PS:

 

 

If [Case(Line Items::SaleDate”” and Line Items::Sold Price=””;1=1)]

 

That isn't logically wrong but it's truly awful to read. It's like going around saying "It isn't true that [b]Bobg[/b] isn't not a non-FileMaker developer". Just write:

 

If [Line Items::SaleDate ≠ "" and Line Items::Sold Price=""]

 

 

So anyway, your triggered script makes that assessment and if the condition is true (user left Sold Price empty), you DO STUFF. Commit recs and assess whether or not there are empty Sold Price fields in portal rows that have a SaleDate. If so, go to that portal row and go to Line Items::Sold Price field.

 

 

 

Onwards to the summary field that isn't updating. You do not WANT a summary field there. You want a CALCULATION field, not in the portal table but in the parent table.

 

result type "number" defined as Count (Line Items::Sold Price)

 

It will update the moment you commit the portal records. There is no way to update it before records are committed. Your original triggered script should do a Commit Records and then you know how many line items have Sold Price values.

Link to comment
Share on other sites

This thread is quite old. Please start a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share



×
×
  • Create New...

Important Information

Terms of Use