Danny Dawson Posted April 26, 2006 Posted April 26, 2006 I am trying to set up an AuditLog system. In the interest of experimentation I have tried to implement this in a db that has the data file and the interface file separated. The idea is that log will contain modifications from all tables in the data file so you need to capture the name of the table as well as the name of the field that has been modified. The Custom Function is in the data file. It is triggered when one of the defined fields in the data table is modified. The code in the function is: Let([ $$RecID= Get (RecordID); $$Fnm = Get(ActiveFieldName); $$TableName = Get(ActiveFieldTableName); $$Fval = GetField($$Fnm); $$Nval = If(Length($$Fval); $$Fval; "[null]")]; If(Length($$Fnm); LogField+1; LogField) I then run a script in the data file that creates a new record in the Log table and populates the fields with the variables. The problem that I am having is the $$TableName = Get(ActiveFieldTableName) part does not return the correct value, it returns log instead of the table name of the modifed field. The strange thing is that the Get(ActiveFieldName) part works correctly as does getting the value from the Active Field Name. It works perfectly if you go to the data file and modify a field but fails when the field is modified via the interface file. Is this a bug with Get(ActiveFieldTableName)?? or am I missing something? Is there another way of capturing the name of the table that a field belongs too? Any advice would be very welcome. Thanks
Matt Haughton Posted April 28, 2006 Posted April 28, 2006 Hi Danny I'm not sure if this is a bug, at first glance it seems it is, but this is an issue of context when the calculation is evaluated. FileMaker help states - "If the current calculation is stored and you specify its context, this function will be evaluated based on that context; otherwise, it will be evaluated based on the context of the current window." Now Get ( ActiveFieldName ) actually works as you'd expect, but Get ( ActiveFieldTableName ) seems to be getting the table of the context in Log. Is this calculation being evaluated at any point later in the script? E.g. Set Field [ TheField ; $$FNM ] ... Set Field [ TheTable ; $$TableName ] If the calculation was re-evaluated at any point between these 2 steps then the active table would of course be Log. Remember the $$Variables are set based on the current context every time the Custom Function is called.
Danny Dawson Posted April 28, 2006 Author Posted April 28, 2006 Hi Matt good to hear from you. I think you're right that it is a context issue but as you say it works for Get(activefieldname) it should work for get(activefieldtablename). I don't believe the function is being re-triggered, if it was I would expect the get(activefieldname) variable to change as well. Also after the function is called a script is triggered and this is not happening. Having said that I will check.
Recommended Posts
This topic is 6782 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 accountSign in
Already have an account? Sign in here.
Sign In Now