Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

How to enter date and then execute script?


This topic is 6368 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

From the other threads, I've put together a script that will automatically find records between two dates using fields (startdate and enddate). I would like the script to be executed automatically when the user changes the dates. To accomplish this, I tried making the field a button that executes that script; however, once I added the script to that button, it no longer allows one to type in to the field. Instead, it seems to just keep executing the script every time I put the cursor over the button to type. Is there a way to allow me to enter my date in the field and then automatically execute the script when I tab on to the next field?

Thanks ahead for responses, Brad

Posted

Brad

FM cannot do this natively (up 'til now anyaway).

Search for a plugin called Eventscript. It is downloadable FOC and will help you achieve what you want, which is 'event - driven' scripting.

Phil

Posted

If you don't want to use a Plugin one option might be to have the script start with a Go To Field step being the start date field then have the script go to the next field being Finish date. Then use the go to object step to select the button. Then when the user hits enter it will perform the script.

It's an option although not as nice as event scripting, but allows you to avoid using a plugin.

Michael

Posted

Thanks both for your replys so far, but I've tried both solutions and must be doing something wrong with the syntax:

Let's try troubleshooting the plugin first.

My field for the first date is called "Ledger Start" and my Script is called "Ledger Date Range Filter". My button triggers the field "Ledger Start" which is set to calculate a date and looks like this

= S4HU_EventScript( Get(Ledger Start) ; Ledger Date Range Filter ; {OptionalScriptParameters} )

This however gives me an error that it cannot find the field "Ledger Date Range Filter".

Help!

Posted

The first parameter should be the name of the FILE, not the field; the script name needs to be in quotes; and if you have no optional parameters then the 3rd param should be a pair of empty quotes:

S4HU_EventScript( Get(FileName) ; "Ledger Date Range Filter" ; "" )

You would put this calc in the field validation or possibly the auto-enter options of your Start and End fields.

"My button triggers the field" -- doesn't make any sense. You wouldn't use a button -- or else what would be the point of the plug-in? -- the script will trigger when you change the date and exit the field.

Script trigger plug-ins are wonderful tools, but you must be careful using them or you can get into all kinds of trouble.

Posted

Thanks Fitch. I follow most of that except for the File Name. Am I just referring to the file name of my database file? I tried that and got an invalid parameter. Here is what I typed (as well as variations by typing the full path of the file):

S4HU_EventScript ( Get(my database.fp7); "Ledger Date Range Filter"; "")

I get an invalid parameter error.

Posted

Did you try it the way I wrote it? Get(FileName) is a function that returns the name of the database that contains the script you want to run. It's generally a good idea to use the function so that you don't have to worry about the calc breaking when someone renames a file. However, you can type in the file name directly, just enclose it in quotes:

S4HU_EventScript ( "my database.fp7" ; "Ledger Date Range Filter"; "")

Look at the example file that comes with the plug-in, that might help.

Posted

I tried the most recent way you typed it, and I think I actually understand how it is working now. However, I have a nagging message each time: ""Ledger Start" is defined to contain only specific values. Allow this value?"

I entered the line as a calculation in the validation. I tried checking and unchecking some of the other options to no avail. Per your ealier suggestion, I also tried putting the calulation in the auto-enter part, but then it did not work at all.

Thanks for your help.

Posted

I believe your problem is probably that you need to concatenate the field name onto the end of the trigger calc. This should work with both validation and auto-enter. Auto-enter is what you really want to use though, because validation only triggers when the record is committed, whereas auto-enter triggers when you exit the field. Once again I counsel you to take a closer look at the example file that came with the plug-in and read the documentation carefully. Normally I would not recommend a beginner even attempt to use a script trigger plug-in.

Posted

That worked. Thank you. I'm usually the first to tell someone to "read the manual", but some of this stuff was so far over my head that I could not follow the manual. I'm learning quick though and have already found multiple uses for this script trigger plug-in.

This topic is 6368 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.