Look at using the Get ( ActiveFieldName ) and Get ( ActiveFieldTableName ) functions and possible the Get ( ActiveFieldContents ) function.
1 of 1 people found this helpful
This is a case where the Insert Calculated Result ( as opposed to set field) makes sense. If you don't specify a target field, it modifies the field with the current focus (and OnObjectValidate will ensure that the correct field does have the focus).
Get(activeFieldContents) as suggested by philipHPG, gives you an easy way to refer to the current field's value indirectly.
Instead of making it a script trigger set it up in the field definition as a calculated auto entry, making sure to uncheck the "Do not replace existing value" box. That way you can use the "Self" reference and simply paste the formula into whichever field you need it for.
2 of 2 people found this helpful
That sounds like a good idea but FileMaker's built in validation for time fields will cause an error message to pop up if that data doesn't form a valid time entry and that brings back the colon issue.
OnObjectValidate allows a script to modify the entered characters before any validation takes place.
I did it and it works! Here's the script that I have the OnObjectValidate call:
Insert Calculated Result [Select;
Let ( [
@TimeEntered = Get(ActiveFieldContents);
@TimeCalc= Right("0000" & Filter ( @TimeEntered ; "0123456789" );4)];
Left (@TimeCalc;2 )&":"& Right ( @TimeCalc ; 2 )