Expand my Community achievements bar.

Need field to be read only once saved...

Avatar

Level 4

I have altered the current date field to create a unique ID for a form. What I need it to do is to become READ ONLY once the user clicks the Submit button. Below is my current FormCalc code

$.rawValue = Concat(Num2Date(Date(), "MMDDYY"), "-", Num2Time(Time(), "hMMSS"))

Any ideas? THanks!

1 Reply

Avatar

Level 6

If you want the Unique ID to be set as soon as the form is initially opened, then use the scripts below. It is designed NOT to update the ID each time the form is opened thereafter (i.e. if the user saves the form and reopens at a later time, it will NOT update the ID since it was already set. Instead, it will maintain the initial ID value).

- Place the following script on the initlize event of the field ID field:

//Only apply script if ID field is blank

//Will not update ID if value has already been set

if ($ == "" | $ == null)

then

$.rawValue = Concat(Num2Date(Date(), "MMDDYY"), "-", Num2Time(Time(), "hMMSS"))

endif

- Place the following script on the preSubmit event on the submit button (NOTE: you will need to update the field name path of the ID field):

//If ID field is not blank or null at time of submit, then set field access to protected.

if ($ <> "" | $ <> null)

then

TextField1.access = "protected"//TextField1 is the ID field in this example - update field name and path accordingly

endif

***NOTE: If oyu are trying to set the unique ID at the time the form is being submitted (i.e. serving as a date/time stamp), then the script would need to be modified for that usage/setup.

Hope this helps!