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

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

Recommended Posts

Posted

(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!

Posted

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 []

Posted

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.

Posted

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?

Posted

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.

Posted

Very nice Michael. I didnt realize that the local variable values could be passed that way.

Very informative. Thanks for that.

Posted

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: :thumbup: :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

Posted

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.

Posted

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.

Posted

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

Posted

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.

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