Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 820
  • Last Modified:

FM - Setting Timestamp Field Based on Another Field set via a Script

This is really hard to test as I have a lot of scripts run off of my Status field.  Already searched EE and FM Help.  I want a timestamp field to be filled with the current date/time anytime there is a modification in my Status field.  This seems easy - just put a script trigger on OnOjbectSave.  However, what if the field is set in a script.  I think this bypasses the trigger.  I have so many scripts that alter this field (Retain, Retire, or Refer status) that it would be nice if I could just set the timestamp field to alter anytime this status field alters.  I thought of doing this via the field's properties AutoEntry, but my understanding is that these fields only run on record creation and not any time in the future when the field might be modified.  Suggestions?
0
rvfowler2
Asked:
rvfowler2
  • 6
  • 3
2 Solutions
 
Will LovingPresidentCommented:
Use the following auto-enter calculation with the "Do not update..." checkbox unchecked.

Let (
trigger = Status ;
Get (CurrentTimeStamp)
)
0
 
Will LovingPresidentCommented:
Also, you might want to consider an audit trail for Status, which tracks what field was changed and when. Check out this video tutorial from John Mark Osborne on Object Script Triggers. The whole video is a good introduction to an explanation of the differences between the various triggers, but at just before the 10 minute mark he shows how to create an audit trail.
0
 
Will LovingPresidentCommented:
Sorry, I meant the "Do not replace existing value of field (if any)" checkbox.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
challengedayCommented:
Sounds like a cool video, I don't see the url though. Thanks!
0
 
Will LovingPresidentCommented:
0
 
rvfowler2Author Commented:
Thanks, I'll look into the video.  Easier than I thought.  But I created 3 timestamp fields so we can have a record if somone moves from retain to refer and then to retire.  So, can you do the calc like this?

If (Status = "Retain";
Let (
RetainStamp = Status ;
Get (CurrentTimeStamp)
)
)
0
 
Will LovingPresidentCommented:
Yes, doing it conditionally works (at least on my test)
0
 
rvfowler2Author Commented:
Yes, it worked, thanks, but I'm having a hard time understanding it in English.  Let sets a variable and then uses it in a calc after the semicolon.  However, here, it seems that the entirety of the calc is simply Get (CurrentTimeStamp), so the variable, or in this case the field, is equal to the timestamp since it is equal to whatever comes after the semicolon.  Did I say it or explain it correctly?
0
 
Will LovingPresidentCommented:
I got the calc elsewhere myself, so I don't have a technical explanation but I think that in either case, what is happening is that setting the Let variable to equal the Status field causes the calc to evaluate whenever Status changes. It's some aspect of how/when a Let variable evaluates in a calculation which is different from just doing an If statement.
0
 
rvfowler2Author Commented:
Thanks.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 6
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now