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

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

Recommended Posts

Posted

I'm wondering if there is a way to script a layout clear. A way that would allow a clearing of all of the fields in a layout that doesn't require you to write clear field A, clear field B, etc. Better yet, a script that would start on a specific field and tab clear, tab clear. I have and am writing clears this way. It's a major pain especially with big layouts.

Posted

Yes, there is. It can be a little tricky for a new starter, but not really that difficult.

The first thing you need is a global field <<NameTemp>>. Then you need to create the following script:

Freeze Window

Go to Next Field

Select All

Cut

Set Field NameTemp

Calculation Status( CurrentFieldName)

Loop

Go to Next Field

Exit Loop If Calculation Status( CurrentFieldName) = Field_Name_Temp

Clear Select entire contents

End Loop

Ok! All you need to do now is figure out how to start this script, i.e. a button called clear all fields, or something like that. The advantages of this script are that it will clear all fields on a layout, regardless of which layout or how many fields. Because it uses the tab order of the layout to move from field to field, it will not try to delete any calculating fields, so no silly error messages. I use this script a lot in search mode, it allows a user to reset a search form very quickly.

Just one word of warning: DO NOT place your global field on the layout, or you will get an endless loop. Or if you do want it on the layout for test reasons, make sure you remove it from the tab order.

Hope this helps,

Rigsby

Posted

Hi

I don't think there is a way to do this. Although the fields you want to clear have to be on the current layout, FM probably doesn't have what youre looking for because the layout that contains fields could also be present on other layouts and if they are cleared on one layout, they will be cleared in the entire db.

Ken

Posted

I want to preface this by noting I have been using FM pretty much since it came out. But I haven't been a good student - only learning what I needed to get the problem solved.

While understanding the gist of your script (though "Freeze Window" probably needs to be more present in my scripts, but that's another post I'll need to do) I need to ask a question that makes the newbie attachment seem very appropriate.

1. Go to Next Field

2. Select All

3. Cut

4. Set Field NameTemp

Calculation Status( CurrentFieldName)

5. Loop

6. Go to Next Field

7. Exit Loop If Calculation Status( CurrentFieldName) = NameTemp

8. Clear Select entire contents

9. End Loop

In step 4 after I specify Set Field to = NameTemp, does "Calculation Status( CurrentFieldName)" mean I specify the calculation result blank?

A similar question to number 7, "NameTemp" is the only thing in the specify calculation result.

I appreciate your help and understanding.

mb

An afterthought, will this script have any problems with un-tabbed portals?

Posted

If you have to manually exit the script, then you have misunderstood the function of the global field. Here a better explanation:

1. Freeze Window

(This simply makes everything tidier, and speeds up the script)

2. Go to Next Field

(This tells your cursor to simply enter the next field in the tab order, if you are not in a field it will enter tab 1. Lets say the field is called COMPANY)

3. Select All

(Selects the entire text in the current field)

4. Cut

(Removes the text from the field)

5. Set Field NameTemp Calculation Status( CurrentFieldName)

(This sets your global field to the name of the field where the cursor is (in this case COMPANY), and FM has just removed the text. If you want you could put this step after step 2)

6. Loop

(Now we start to loop through the fields)

7. Go to Next Field

(This moves the curser to the next field in the Tab order. So if we are in tab 1, it will go to 2. Important here is that if we are in the last tab, it will spring to 1)

8. Exit Loop If Calculation Status( CurrentFieldName) = NameTemp

(This IF checks the name of the current field, and if the name is the same as the data entered in NameTemp, it exits the loop and thus the script)

9. Clear Select entire contents

(If the names do not match, the field is cleared, and the loop continues)

10. End Loop

(Is clear)

A problem could occur if you only have one field on the layout. The next field step can cause FM to exit the current field. Otherwise, you should not need to exit this script manually. If you do, then you have got something wrong.

To answer your question about the calculation in more detail:

NO, you do not set the NameTemp field to BLANK, or the script will loop endlessly. You have to set the TempName to the name of the current field. This is done with a status flag: Status( CurrentFieldName). So, if you use this step, and the cursor is in a field called COMPANY, NameTemp will be set to the value COMPANY. I would guess that this is where you have gone wrong with the script. I don

  • 2 weeks later...
Posted

I really appreciate the step-by-step directions. I couldn't figure out why it still wasn't working. I tried it on a couple of different layouts and the problems seems it doesn't work with repeating fields. Thanks again for your time, and I'm sorry for the delay in responding.

mb

Posted

Young Grasshopper understands! The global field holds the field name and the Loop clears all fields within the tab order until it comes back to the first field. It would have been fine if a repeating field wasn't in the first tab order.

I don't have any calc fields in the layouts where this will be used, but I'm assuming the this script will fail in that situation because a calc field cannot be cleared and therefore will produce an error message. Can a script ignore an error message and continue on and complete a script? I appreciate everybody's time and expertise.

  • 8 months later...

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