JasonPonce
2 years agoQrew Trainee
Formula Field is Updating Outside of Record Interaction
Hi everyone,
I have a formula field (see code below) that gets the current date and time. Then formats it to a certain way. The issue I'm having is that this formula field updates the content of the field outside of Edit>Save Record operations.
Ex.
1) If I go a table and view all the records. The formula field updates everytime I refresh the page.
2) If I go to edit a record, then discard any changes. The formula field updates.
PS. If there is a better way to format the date, please let me know!
//Intended Time Format 12/21/2021 17:00:19
//Get time
var number numHour = Hour(ToTimeOfDay(Now()));
var number numMin = Minute(ToTimeOfDay(Now()));
var number numSec = Second(ToTimeOfDay(Now()));
//convert to String
var text getHour = If(ToNumber($numHour) < 10, ToText("0"&$numHour), ToText($numHour));
var text getMin = If(ToNumber($numMin) < 10, ToText("0"&$numMin), ToText($numMin));
var text getSec = If(ToNumber($numSec) < 10, ToText("0"&$numSec), ToText($numSec));
var text getTime = $getHour & ":" & $getMin & ":" & $getSec;
//Get Date format
var text getDateFormat = SearchAndReplace(ToText(Today()),"-","/");
//Put it all together
var text setTime = ToFormattedText(Now(),"HHMMSS");
var text dateTimeFormat = $getDateFormat & " " & $getTime;
var text setDateTime = If([Enabled for Execution]=false, $dateTimeFormat);
$setDateTime
------------------------------
Jason Ponce
------------------------------