Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.
Juggernaut

Can variables be used in auto-enter?

Featured Replies

Can global variables be used to provide an auto-entered text string during a record create?

I've tried every combination I can think of to specify the Auto-Enter of a predetermined value ($$CurrentText). Simply placing $$CurrentText in the Data option indeed causes "$$CurrentText" to be placed in the field, but not the contents of the variable. Placing it in a calculation doesn't work either, nor with any combination of "replace existing". If I make the calculation read: $$CurrentText & "TEST" the word TEST shows up, so the evaluation is taking place. BTW, Data Viewer displays the proper text string in the variable before and after the record create.

Is this a limitation in the use of global variables? -- or have I just missed something?

Thanks in advance for any help.

Hi

AE $$CurrentText as calculation works with me, but the global variable must be definited before creating a new record.

I can only think to suggest you to check the name of the variable.

Edit: you can even force the re-evaluation with something like:

Evaluate( Quote ( $$CurrentText ); AutoEnterField )

  • Author

Thanks for the response. I've double-checked the name. And I've even tried wrapping the field in a GetAsText[] operation just to do something different, but nothing is returned in the field (... which, BTW, is indexed. I wonder ... )

Maybe tomorrow I can prepare a test file to try on other systems (v7 and v8).

Thanks again.

$$Variables only exists for fm8+ and works only within the jurisdiction of one file. Use Get Script Result from an Exit Script to deal with trespassing.

--sd

  • Author

I am using the separation model -- and the record that's being created from the GUI is in the database file. Could that explain why it doesn't work for me? In other words, does this situation qualify as the two files you referred to?

Yes.

  • Author

So is there a way to bypass this limitation? -- or is it considered a brick wall? (BTW, I did not understand what Soren was suggesting.)

It's not quite clear when, where and why you set your variable/s. Here's one possible way:

Script in file Main:

Set Variable [ $$myVar; Value:"whatever" ]

Perform Script [ “Receive Variable” from file: "Data"; Parameter: $$myVar ]

Script “Receive Variable” in file Data:

Set Variable [ $$myVar; Value:Get ( ScriptParameter ) ]

Now both files have the same variable, with the same value.

Some cool trickery can be observed here:

http://www.fmforums.com/forum/attachment.php?attid/5922/

...however does it undermine the rigidness of separation model, when having scripts in both are becoming manditory :nahnah:

--sd

Since $$global variables can't be referenced outside the file they're defined in, you can either pass the variable with a script as mentioned above, or simply use a global field instead. Global fields still have their uses.

  • Author

Thank you each for your replies. Since my usage is fairly simple (tag each created record with a machine-dependent value) I'll just drop back to placing it in a global field (which, ironically, is where it started out). Variables are so "cool" that I began using them for all kinds of little things -- which led me across a line I didn't know existed.

I'll explore the other examples you provided to gain more insight.

Thanks again.

Create an account or sign in to comment

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.