Slobey Posted August 5, 2005 Posted August 5, 2005 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
PatriciaW Posted August 6, 2005 Posted August 6, 2005 How does the initial entry invocation occur? Is it based on another field?
PatriciaW Posted August 6, 2005 Posted August 6, 2005 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.
SlimJim Posted August 6, 2005 Posted August 6, 2005 (edited) When you do the initial entry could you miss out the conversion part of the script and then when the record is committed let the validation calculation do that for you? Edited August 6, 2005 by Guest
Homer Posted August 8, 2005 Posted August 8, 2005 Hi Slobey! As you mentioned; Quote 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
Slobey Posted August 8, 2005 Author Posted August 8, 2005 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?
Slobey Posted August 8, 2005 Author Posted August 8, 2005 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?
Homer Posted August 9, 2005 Posted August 9, 2005 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.
Slobey Posted August 9, 2005 Author Posted August 9, 2005 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
Recommended Posts
This topic is 7138 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 accountSign in
Already have an account? Sign in here.
Sign In Now