Jump to content

Eventscript script Parameter


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

Recommended Posts

Hi,

I am using eventscript for one of my solutions and I seem to have a problem.

This is the current field calc:

Case(not IsEmpty(Servings Conv Entry);

S4HU_EventScript(Get(FileName); "CONVERT / ENTER RECIPE" ; "Convert Entry" )

&

Servings Conv Entry)

This is basically a recipe conversion script that when you change the qty in the field "servings conv Entry", the script converts all the ingredients to match. That part works great.

The problem is the script parameter. The "servings conv entry" field is used in the same script if triggered by a button with a different script parameter (Initial entry of recipe has "Enter" as a script parameter). When this button is clicked it runs the script and then runs it again with the "Convert Entry" parameter. Can I stop this?

I tried this calc:

if(get(scriptparameter)= "Enter";

Servings Conv Entry;

Case(not IsEmpty(Servings Conv Entry);

S4HU_EventScript(Get(FileName); "CONVERT / ENTER RECIPE" ; "Convert Entry" )

&

Servings Conv Entry)

That didn't help.

What can I do to prevent this script from running twice?

Any help is greatly appreciated.

Thanks

Link to comment
Share on other sites

I hadn't had enough coffee when I asked that original question. Here is another (possibly equally dumb) suggestion. Is there any way that you can turn off validations when you click on the other button ... e.g. try Commit Records/Requests with Skip data entry validation at the end of the script that is invoked by the Button. It seems like it is that validation that is causing the double invocation.

Link to comment
Share on other sites

Hi Slobey!

As you mentioned;

The "servings conv entry" field is used in the same script

This is probably causing the double-trigger since this field will fire a script every time it will receive an update of his content, including through script-steps like "set field", "Insert Text", "calculated result" and so forth.

A quick and effective way to fix at-the-very-source this behaviour is to use the ;) Get ( ScriptName ) function.

You can place it directly into the trigger calculation of your field and that should look like this :

// First, provide to FMPro with the information he is expecting (here an "auto-enter" + "Calculated value" option)

Servings Conv Entry  & 



// If the field contains something AND if the target-script isn't currently running

If ( not IsEmpty( Servings Conv Entry ) and Get( ScriptName ) ≠ "CONVERT / ENTER RECIPE";



// Then trigger the script

S4HU_EventScript( Get (FileName); "CONVERT / ENTER RECIPE" ; "Convert Entry" );



// Else do not trigger the script

"")

And uncheck the "Do not replace existing value of field" checkbox.

Then, it is necessary to be careful if you rename your target-script in Scriptmaker. If the case arises, do not forget to make the script-name correction in your trigger-calculation accordingly.

HTH

Link to comment
Share on other sites

Thank you all so much for replying. I tried homers solution and ran into a problem. I filed to tell you that it is in fact a subscript that enters into that field, so I tried to use the subscript name in the get(scriptname) step and it didn't seem to work. When I ran the script debugger, I noticed that as soon as I enterd the subscript a new active script appeared in the bottom of the screen, before any script steps in that subscript were executed. What up with that?

Link to comment
Share on other sites

I may have more going on here. I double checked the script debugger and I was wrong the active script is not added at the time of entry into the subscript. However, when I take out the get(scriptname) step, 2 additional scripts appear in the active script window of the debugger and when I use the get(scriptname) step only one appears, why would 2 appear with one set field step?

Link to comment
Share on other sites

It is strange that there is double launching of the script with only one "Set Field." Is it possible that your trigger-field would also include a validation rule with use of EventScript?

Another solution, if you are certain that your trigger cannot be thrown while another script is already under execution, you can also try this condition:

...

If ( not IsEmpty( Servings Conv Entry ) and Get( ScriptName ) = "";

...

This way, the trigger-field will only fire your target script if no other script is currently running.

Link to comment
Share on other sites

I'm still trying to figure this out but I found a cheap solution. I simply put a halt script step as my last script step and that cancels out the pending script triggered by the field.

Thanks for all your help I really appreciate it

Link to comment
Share on other sites

This topic is 6859 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.