Jump to content
Server Maintenance This Week. ×

GENIUS or MORONIC?


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

Recommended Posts

A group of amateur developers at the office came up with the following, and we think it is almost too good to be true, especially bc we've never read anything about this- except for a global calc posting in the forums a number of months ago. Here it is:

We want to track certain fields, to follow when which user changes data in each, so we made a calculation for each such field that gets the value, gets the current timestamp and user, then skips a line, and references itself. You can only do this if you create the calc first so it shows up in the field list- then you can go back and add the self-reference.

We were shocked fm allowed us to do this, but it is working exactly as we had hoped. Anyone have any thoughts- is this likely to corrupt our data or crash the system?

The calc (FieldChange) looks like this if you are tracking a field called Name:

Get (AccountName) & " " & Get (CurrentTimestamp) & " " & Name &

"---------"

FieldChange

Obvious glitches? Things to consider? Thoughts?

While I really hope everyone votes "genius", I'd way rather hear any nagging concerns you serious fm people have.

Thanks!

Sara

Link to comment
Share on other sites

Hi Sara,

A few things:

A ) Get (AccountName) & " " & Get (CurrentTimestamp) & " " & Name &

"¶---------¶"

FieldChange

Should be in an text based calc field with do not replace existing values unchecked -- as opposed to a calc field...

B ) You may want to chuck a couple of pilcrows in.

C ) There are more complex versions of this lying around on the forums -- Its called an audit trail. This recent topic has a few links that will be of use: http://www.fmforums.com/forum/showtopic.php?tid/186957/post/251295/hl/audit+trail/

Link to comment
Share on other sites

Thanks very much.

(I was too lazy to add the pilcrows when I retyped the calc [and too lazy to copy/paste too], but we had them in there.)

It sounds like you are saying we should use an auto-enter calc- that's the only place I can see to uncheck that box- what is the benefit of an auto-enter over our calc?

Here is the copied/pasted calc we have:

If ( DeleteFlg = 1 ; "" ; If (

Middle ( Itself ;

( Position ( Itself ; "*" ; 1 ; 2 ) + 1 ) ;

( ( Position ( Itself ; "," ; 1 ; 2 ) ) - ( Position ( Itself ; "*" ; 1 ; 2 ) + 1 ) ) ) = field ; Itself ;

"*" &

Middle ( Itself ;

( Position ( Itself ; "*" ; 1 ; 2 ) + 1 ) ;

( ( Position ( Itself ; "," ; 1 ; 2 ) ) - ( Position ( Itself ; "*" ; 1 ; 2 ) + 1 ) ) )

& ", *"

& field

& ", "

& Get ( CurrentTimeStamp ) & ", "

& Get ( AccountName ) & ", "

& Get ( RecordID )

& ¶

& Itself ) )

The position stuff is just to get the old value of the field... ignore that..

We plan to fill in the deleteswitch after each export (to a new table) of all the old changes, so as not to have too long a field.

Other thoughts or suggestions?

Thanks again.

sara

Link to comment
Share on other sites

Calcs can be reset accidentally... a lot harder to wipe the data out of text fields.

Other than that, nothing I guess.

In relation to your calc though, you might want to try the Let statement, helps to actually make out what your doing lol.

Let( [

_itself = Itself;

_pos1 = Position (_itself; "*" ; 1 ; 2 ) + 1;

_pos2 = Position (_itself ; "," ; 1 ; 2 ) - Position ( _itself ; "*" ; 1 ; 2 ) + 1 ;

_value = Middle( _itself ; _pos1 ; _pos2 )

];

If ( DeleteFlg = 1 ; "" ;

If (_value = field ;_itself ;

"*"

& _value

& ", *"

& field

& ", "

& Get ( CurrentTimeStamp ) & ", "

& Get ( AccountName ) & ", "

& Get ( RecordID )

& ¶

& _itself

)//End Sub If Statement

)//End Delete Flag Check If Statement

)//End Let Statement

Edited by Guest
Slipped into coding php by accident
Link to comment
Share on other sites

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