Jump to content
gczychi

fmstandards disable/enable Triggers - How ?

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

 

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

Yes, I have seen them also, but how did they intend to use it?

Anyone from fmstandards listening?

Thanks

 

Share this post


Link to post
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.

Share this post


Link to post
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. 

Share this post


Link to post
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. 

Share this post


Link to post
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

Share this post


Link to post
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?

Share this post


Link to post
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

Share this post


Link to post
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.

Share this post


Link to post
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

 

Share this post


Link to post
Share on other sites

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

  • Similar Content

    • By Scott Pon
      Environment: FM13 with FM13 Server, mix of Windows 7 and 10.
      Is there a way to set a script trigger on if this portal row is new? IE, a script to run if this new child/portal record is new.  
      We have a parent record, and portal to Children records.  The children records have 2 fields: Profile Name and Process type.  Our user would like to enter a new child record (profile name and process type).  if the process type already exists, we will need to archive the existing record (matching the profile type).  There is more bI want to start with this first.
      I see script triggers to the layout "OnRecordCommit", but no similar script trigger for portals.  Any ideas on how to handle this?  Or am I going to have to add a button to go to another screen to accomplish this?
      Thanks.  I hope i gave enough info for you to help me.
       
    • By dav1089
      Hello,
      I want to create a script trigger which opens a layout based on account name ,create new record and put cursor in first field of the new record
      Now, I was able to direct user to specific layout and also created new record using New Record/Request function but somehow it doesn't put cursor in the first field , instead it selects whole record .
      Note: I also have script triggers attached to first and second field which runs on exiting the fields. (I don't think they affect anyways , but just mentioned to give idea)
    • By CRexen
      Hello everyone
       
      I am currently working on a database, which HR-Managers can access via WebDirect using login-information, to accede or resign their employees.
       
      I have made 6 possible option types for the HR-employees to enter data into, set by an unique ID, but with the use of the same fields.
       
      So...
       
      X fields with option type 1 (Accede)
      Y fields with option type 2 (Resign)
      Z fields with option type 3 (Maternity leave / leave)
      .. Etc. 6 option types in total.
       
      Now, based on my project description, a couple of the fields will have to be validated / not empty, which the HR-manager is prompted to enter before the record can be committed.
       
      Now, I am aware of FileMaker has it's own Field Validation, but I think the built in feature is bonkers..... (Sorry FileMaker..) 
       
      Therefore I was thinking of making a script to each of the different fields, which needs validation, and is this even a good solution
       
      Question one; how do I do this, the most easily? Is it possible?
      I have 8 required fields for validation, fields are global.
       
      Fields such as; Company Name, HR-manager name, HR-manager e-mail, employee SSN, employee name, employee surname etc. 
       
      I don't want the scripts to interfere with the other option types ( X, Y, Z ) which each is set by an unique ID, as well as fields, although the fields used in these option types are from the same table.
       
      Please see attached images of my setup.
       
      Hope you can help me, for the best possible solution.
      If you need more information, let me know.
       
      /Cheers
       
      P.S. The language/text on the layout is Danish, although shouldn't be considered an issue for understanding my problem.



    • By Yogi Bear
      Hello,
      We have a simple Filemaker solution which tracks stock we order from suppliers (Item ID (unique Key), Description, Category, Invoice, Serial Number, Date, etc) which we used to track stock and print labels from. (Table: Stock Items)
      I would like to make an improvement to this by adding a stock take functionality. As we barcode the items and print the Item ID I would like someone to be able to walk around the shop and scan each barcode and then we can generate reports from there. The barcode scanner is setup to add a carriage return at the end of the scan to move on to the next line.
      I have setup a table called "Stocktake". We just want to enter the Item ID and then other fields can be looked up. (see attached screenshot).
      The issue I have is that I struggle for FM to create new records. What I have setup is created a script which makes a new record, and sets the focus to the field Stocktake:Item_id
      - New Record/Request
      - Go to Field [Stocktake::Item_ID]
      I have then added a trigger to the Item_ID field which on "OnObjectSave" runs this script.
      I have two problems:
      1. If I type in a stocknumber the record is entered into the table, the script runs (can check it using tools), a new record is created but when the script finishes the focus is not on the Item_ID field. In fact there is no field that has focus applied. However, if I manually click on "New Record", or manually run the script the focus is on the field Item_ID for entry for the next item.
      2. I notice that the record only is recorded if I press "Enter" on my numeric keypad. If I press "Enter" on the main keyboard it will not save the record. I am aware that on a Mac these keys are treated differently. What do I need to configure here? The scanner we use for barcodes has been configured to add a carriage return but this appears to be the same one as the main enter key and does not enter records.
      I must just be doing something simple wrong. If anyone could give me some guidance it would be greatly appreciated.

      Platform is Filemaker 12 Advanced running on Windows.

    • By Dana G
      Purpose:  To capture the contents of a field before it is changed.  Compare the before to the after.  Highlight the after and screen capture then export.
       
      I can't get past the first sentence and it's getting frustrating because it seems extremely simple.
       
      1 Field:  OnDeck_t (text)  -  The OnDeck_t field data = On
      2 Field:  OnDeck_before (Where I want to capture the OnDeck_t before it's changed)
       
      I have an OnObjectEnter script trigger on the OnDeck_t field that runs this script:
      Set Field By Name [substitute (Get (ActiveFieldName); "_t"; "_Before"); Get (ActiveFieldContents)]
       
      If I do this it works fine.  (But I don't want it hard coded.  I will be using it for all the fields on the layout):
      Set Field [OnDeck_before; Get (ActiveFieldContents)]
       
       
      I have divided the Substitute (Get (ActiveFieldName); "_t"; "_Before") and Get (ActiveFieldContents) into separate lines in Data Viewer and both return expected results.  Why doesn't it work when it's part of a 'Set Field by Name' script step?
       
      Thanks.
×

Important Information

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