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.

Featured Replies

Is there a way to clear all globals in a table? I have a table that contains all of my global variables. I would like to be able to use a script that would clear them all out as the first step. I have tried:

Show All Records

Delete All Records

but the nothing was cleared.

I know that this works:

Set Field [GLOBALS::color_g;""]

Set Field [GLOBALS::type_g;""]

etc. etc.

but I have so many, it would be nice to have a cleaner way. I have searched the forum, but not found an answer that worked.

thanks

Hi

This script may work, but you have to perform it while in a layout showing all ( and alone ) your global fields.

Set Variable [ $count ; Value: ValueCount ( FieldNames ( Get ( FileName ) ; Get ( LayoutName ) ) ) ]

Loop

Exit Loop If [ not $count ]

Go to next field

Set Field [ [color:red]<> ; "" ]

Set Variable [ $count ; Value: $count - 1 ]

End Loop

Commit Records/Requests [ ]

As you discovered, global field values are retained even when you delete all records. Saving a clone however, will clear them out.

One advantage of global variables is they all disappear when the file closes.

Try this...

http://fmforums.com/forum/showpost.php?post/179234/

  • Author

Thank you one and all.

Daniele,

Thanks, I will try it. Where you have the <>, do I just leave that blank?

John,

I see from your file it works, but how? What is it doing? How is it clearing the globals? I like it and looked at the scripts, but don't understand how you did it.

- I did some more digging and see it is through an auto-calc. Pretty clever. Thanks. Some of my globals are created with auto-calcs and look-ups from other fields. I will have to see if I can make this work in combination with them.

Fitch,

I have various relational links that the globals are using. From what I was able to read, the variable rout wasn't recommened. But from what you are saying, I could have just created a "$$colors" instead of setting up the "colors" field in the globals table. Is that right? I will have to play with that. It sounds much simpler. But, then how would I clean it out? Perhaps using the "$colors"? Again from reading it looks like that would clean itself out as soon as the script is finished. Is that right? That might do the trick also.

thanks again to all!

Edited by Guest
updated

Where you have the <>, do I just leave that blank?

Yes.

Global fields can do several things that global variables can't, including:

- display on a layout

- drive a relationship

- access from other files

You could use $$colors. It would clean itself up by disappearing when you close the file. I'm not sure how you envision using script variables, but yes, they disappear once the script has completed.

Another note about defining variables: you can use a Let function to set/clear a group of variables, which may be easier to manage. E.g.:)

Set Variable( $x ; 

 Let( [ 

   $$color = "red" ; 

   $$color[2] = "white" ; 

   $$color[3] = "blue" ; 

   $$etc = "ok"  

   ] ; 

 "" )

 )

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.