January 24, 200719 yr (Hope this is in the right place...) I want a way to enter a number in field1, then have that number automatically added to field2, then have the field1 reset to have no value. I'm learning my way around FM, but I'm still pretty green when it comes to scripts. Thanks!
January 24, 200719 yr If the fields are from the same table or related tables then: Set Field [ field2; field2 +field1 ] Set Field [ field1; "" ] Commit Record [] Otherwise, you have to set a variable or global field with the value of field1, go to a layout from the second table and then, Set Field [ field2; $variable + field2 ] or Set Field [ field2; globalfield + field2 ] Commit Record []
January 24, 200719 yr Add an auto-enter formula to field 1: Let( $$new value = field 1, "" ) and to field 2 Case( field 1 or True, field 2 + $$new value ). Both auto-enters must overwrite the existing value. I haven't tested this, so be careful.
January 24, 200719 yr Author If the fields are from the same table or related tables then: Set Field [ field2; field2 +field1 ] Set Field [ field1; "" ] Commit Record [] Otherwise, you have to set a variable or global field with the value of field1, go to a layout from the second table and then, Set Field [ field2; $variable + field2 ] or Set Field [ field2; globalfield + field2 ] Commit Record [] Perfect! Simply, and exactly what I needed. So I guess I'll ask the last question: Is there a way to set the scrip to run as soon as I've entered a value into Field 2, instead of me running the script manually?
January 24, 200719 yr To run a script upon exiting a field, you can use a plugin like EventScript. Also you can take a look at Mikhail's post. These are number fields with calculted values, but I must warn you that you will not be able to clear out the second field without clearing out the global variable as well. Also, as he said, keep in mind that it hasnt been fully tested so its buggy.
January 25, 200719 yr I have modified Mikhail's suggestion slightly, and I believe that should work, including clearing the result. Scripted or not, I don't think this is very useful without leaving a trail of entries. AutoSum.fp7.zip
January 25, 200719 yr Very nice Michael. I didnt realize that the local variable values could be passed that way. Very informative. Thanks for that.
January 25, 200719 yr Very nice Michael. I didnt realize that the local variable values could be passed that way. Well I have, here: http://www.kevinfrank.com/download/county-highlight-in-portal.zip But indeed :thumbup: :thumbup: , it's one of those things that doesn't heureka for me, but rather a sneak in to my mind ...there are still some time left until I throw it after everything i sheer exicement. --sd
January 25, 200719 yr Hey Søren, But Mikhail and Kevin's techniques use global variables to accomplish this. I did not know you could do it with a Local one as well as Comment has shown.
January 25, 200719 yr Author I have modified Mikhail's suggestion slightly, and I believe that should work, including clearing the result. Scripted or not, I don't think this is very useful without leaving a trail of entries. Wow, that's an even better solution. Thanks! This is perfect. In this case, I don't need a trail of entries, though I can certainly think of many times when that would be wise.
January 25, 200719 yr But Mikhail and Kevin's techniques use global variables to accomplish this. I did not know you could do it with a Local one as well as Comment has shown. Yeah - They're apparently kept until a script is fired? It kind of follow what could be seen in the "inspector"... --sd
January 25, 200719 yr But Mikhail and Kevin's techniques use global variables to accomplish this. I did not know you could do it with a Local one as well as Comment has shown. Me neither. Great to know this. Thanks, Comment ???
January 27, 200719 yr Simple and genial ! I have modified a little the calc of "Sum": Let ( [ trigger = Entry ; value = $entry ; $entry = "" ] ; Sum + [color:red]Evaluate( value ) ) so now I can enter a calc into the "Entry" field too.
Create an account or sign in to comment