Expand my Community achievements bar.

Lock / Freeze Current Date after saving

Avatar

Level 1

Hello,

Is there a way to lock the 'current date' field after it was saved the first time??

At the moment the field updates every time the form is opened.

I am using this (from the custom object library):

 

form1.#subform[0].CurrentDate::ready:layout - (FormCalc, client)

 

// Current Date in short-style date format.

 

$.rawValue

Thank you

Simon

4 Replies

Avatar

Level 1

What is should read is this

 

$.rawValue EQUALS num2date(date(), DateFmt(1))

Avatar

Level 10

Hi,

wrap you code into an if expression at the initialize event.

The date then will only be populated, if the field is empty.

if ($.isNull) then

          $ = Num2Date(date(), DateFmt(1))

endif

Avatar

Level 1

Worked like a charm.  thanks so much!

Avatar

Level 3

I need to use this same code, and it is working like I need. The problem I am having is that now when I use the Submit button, I am getting a "Date validation failed" error message. I don't have any validation on this field, so any thoughts as to where it is coming from? I do have this code to validate other fields, which all work with no errors:

if (form1.Tailboard.Supervisor.rawValue == null)

            xfa.host.messageBox("Choose a supervisor from the list.", "", 0);

           

if (form1.Tailboard.Supervisor.rawValue == null)

            xfa.host.setFocus("form1.Tailboard.Supervisor");

           

if (form1.Tailboard.Header.Table1.Row1.PersonInCharge.rawValue == null)

            xfa.host.messageBox("Enter the name of the Person in Charge.", "", 0);

           

if (form1.Tailboard.Header.Table1.Row1.PersonInCharge.rawValue == null)         

            xfa.host.setFocus("form1.Tailboard.Header.Table1.Row1.PersonInCharge");

           

if (form1.Tailboard.Header.Table1.Row1.WorkLocation.rawValue == null)

            xfa.host.messageBox("Enter a Work Location/Structure Number.", "", 0);

           

if (form1.Tailboard.Header.Table1.Row1.WorkLocation.rawValue == null) 

            xfa.host.setFocus("form1.Tailboard.Header.Table1.Row1.WorkLocation");

           

if (form1.Tailboard.Review.Review1.Review1.rawValue == null)

            xfa.host.messageBox("Check 'YES' that you have completed task 1.", "", 0);

           

if (form1.Tailboard.Review.Review1.Review1.rawValue == null)   

            xfa.host.setFocus("form1.Tailboard.Review.Review1.Review1");

           

if (form1.Tailboard.Review.Review2.Review2.rawValue == null)

            xfa.host.messageBox("Check 'YES' that you have completed task 2.", "", 0);

           

if (form1.Tailboard.Review.Review2.Review2.rawValue == null)   

            xfa.host.setFocus("form1.Tailboard.Review.Review2.Review2");

           

if (form1.Tailboard.Review.Review3.Review3.rawValue == null)

            xfa.host.messageBox("Check 'YES' that you have completed task 3.", "", 0);

           

if (form1.Tailboard.Review.Review3.Review3.rawValue == null)   

            xfa.host.setFocus("form1.Tailboard.Review.Review3.Review3");

           

if (form1.Tailboard.Review.Review4.Review4.rawValue == null)

            xfa.host.messageBox("Check 'YES' that you have completed task 4.", "", 0);

           

if (form1.Tailboard.Review.Review4.Review4.rawValue == null)   

            xfa.host.setFocus("form1.Tailboard.Review.Review4.Review4");

if (form1.Tailboard.Review.Review5.Review5.rawValue == null)

            xfa.host.messageBox("Check 'YES' that you have completed task 5.", "", 0);

           

if (form1.Tailboard.Review.Review5.Review5.rawValue == null)   

            xfa.host.setFocus("form1.Tailboard.Review.Review5.Review5");

                                   

else if (form1.Tailboard.Supervisor.rawValue != null &&

            form1.Tailboard.Header.Table1.Row1.PersonInCharge.rawValue &&

            form1.Tailboard.Header.Table1.Row1.WorkLocation.rawValue &&

            form1.Tailboard.Review.Review1.Review1.rawValue &&

            form1.Tailboard.Review.Review2.Review2.rawValue &&

            form1.Tailboard.Review.Review3.Review3.rawValue &&

            form1.Tailboard.Review.Review4.Review4.rawValue &&

            form1.Tailboard.Review.Review5.Review5.rawValue != null){

            RealEmail.event__click.submit.target = "mailto:" + form1.Tailboard.Supervisor.rawValue + "?subject=" + "SJO" + " — "

            + form1.Tailboard.Supervisor.formattedValue + " — "

            + form1.Tailboard.Header.Table1.Row1.Date.rawValue;

            RealEmail.execEvent("click");

            }