Jump to content

fmstandards disable/enable Triggers - How ?


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

Recommended Posts

Hi,

I'm aksing myself how I could make the trigger functionality of the fmstandards package work.

When I call the CF TriggersAreActive, I get True(1) as a result (in the Data Viewer or inside a Set Variable script step). When I call TriggersDisable and then TriggersAreActive again, I still get True(1), so Triggers are still active.

I could simply use a $$ variable to save the trigger state, but I don't want to, because that can lead to problems using subscripts.

What am I missing?

Thanks a lot for your help,

Gary

 

Link to comment
Share on other sites

Looks like they use several global variables: 

$$~TRIGGERS_SCRIPTS, $$~TRIGGERS_DISABLE, and $$~DISABLETRIGGERS

You should be seeing those in your data viewer.

I don't work with those functions, but I use a similar method.

Link to comment
Share on other sites

26 minutes ago, gczychi said:

Anyone from fmstandards listening?

Probably not. Although most of them are members, they come and go as their spare time allows. I sent you a Private Message over 4 hours ago, and I see you haven't read it yet.

Link to comment
Share on other sites

I use those functions in my solutions. I usually just use a script vairable, $triggerStatus, and use a set variable step to call the custom functions. Set Variable $triggerStatus = TriggersDisable, and $triggerStatus = TriggersEnable. Just remember to use the functions before any halt script steps or where necessary in any if statements. 

Link to comment
Share on other sites

Petrowsky hangs out on the FileMaker facebook group. Bante frequents community.filemaker.com . 

It seems like this is explained pretty well here:

http://filemakerstandards.org/display/bp/Suppressible+Triggered+Scripts

Basically, you set a global variable when you want to suppress triggers. And in your triggered scripts, you put at the top something like:

If[$$triggersOFF]
Exit Script
End If

That's really all there is to it. 

Link to comment
Share on other sites

Here are two examples of using the FMStandards scheme. One is a script that runs on the script trigger OnRecordLoad. It runs if TriggersAreActive, but exits if not TriggersAreActive.

58d8388d60a91_ScreenShot2017-03-26at3_52_42PM.png.8ebcf0384cdd2af118c184f379706840.png

 

The other is part of a script that creates a new window, but I do not wish the OnRecordLoad script to run; so I disable the triggers before opening the new window, and then re-enable the triggers after going to my target layout.

58d8388cb204e_ScreenShot2017-03-26at3_51_39PM.png.af78db3d35e38df360bfe6a57fd2ea84.png

Link to comment
Share on other sites

On 3/24/2017 at 11:17 PM, gczychi said:

When I call the CF TriggersAreActive, I get True(1) as a result (in the Data Viewer or inside a Set Variable script step). When I call TriggersDisable and then TriggersAreActive again, I still get True(1), so Triggers are still active.

I could simply use a $$ variable to save the trigger state, but I don't want to, because that can lead to problems using subscripts.

Others have commented on the usage of the functions, so I won't repeat that.

The behavior of the Triggers* functions you describe sounds like a bug, but I can't reproduce it. Can you post the script where you saw that behavior?

Link to comment
Share on other sites

Thanks, Jeremy,

 

1) Out-of-the-box Standards.fmp12 file from Standards

2) Data Viewer «TriggersAreActive»; result 1

3) Data Viewer «TriggersDisable»; result 0 (see screen shot)

4) Data Viewer «TriggersAreActive»; result 1

 

Gary

 

 

 

Dataviewer.jpg

Link to comment
Share on other sites

TriggersDisable is designed to be called by a script. It won't disable triggers without a script running to help developers avoid shooting themselves in the foot. What you're seeing in the Data Viewer is how it's designed to work.

Link to comment
Share on other sites

Oops…

Thanks for the explanation.

It's my habit of testing everything in the data Viewer before copying it into the scripts — saves me a bit of work during debugging.

Thanks so much,

Gary

 

Link to comment
Share on other sites

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