Tap Forms – Organizer Database App for Mac, iPhone, and iPad › Forums › Using Tap Forms › Auto-assign ID for each record?
- This topic has 4 replies, 2 voices, and was last updated 7 years ago by Brendan.
-
AuthorPosts
-
January 17, 2018 at 5:56 PM #27040
Greg MaleticParticipantI have a form that (currently) has 100 records in it. I’d like to assign an identifier number to each. Something like a 7-digit random number would be ideal. Is there a way that Tap Forms can do that for me?
January 17, 2018 at 6:05 PM #27041
BrendanKeymasterHi Greg,
You could use a Calculation field and use the function RND() to generate a random number which you could use.
Enable the new “Calculate one time only” setting on the Formula Edit screen in Tap Forms 5.2.1 and that’ll cause the random number to be generated only one time for each record.
When you add a new record you’ll get a new random number.
Here’s an example that’ll return a random number between 0 and 10,000:
FORMAT(RND() * 10000, “00000”)
It will also format it so it has leading 0’s if the number is less than 5 digits wide.
Set the Result Type to Text also.
Hope that’s what you’re looking for.
Brendan
January 17, 2018 at 10:17 PM #27042
Greg MaleticParticipantThat works great! Thank you.
(One bug I noticed: if you dupe a calculation field, the “Calculate one time only” value will always be false in the dupe, even if in the original record it was true.)
January 17, 2018 at 10:19 PM #27043
Greg MaleticParticipantOne follow-up question: is there a way to “force” a re-calculation in one particular record if desired?
January 17, 2018 at 10:24 PM #27045
BrendanKeymasterHi Greg,
I fixed that bug for the next update.
As for recalculating just one record, yes, there’s a recalculate button at the bottom of the record on the Default Layout. However, it will still respect the “Calculate one time only” setting.
If you want to recalculate, what you could do is edit the formula, un-check that checkbox, then click the Cancel button so you don’t trigger a recalculation of all records.
Then click the refresh button at the bottom of the Default Layout.
Then go edit the formula again and turn it back on, but also then click Cancel.
The reason this works is because the Calculate one time only checkbox button is bound directly to the field’s
dontRecalculate
property. The Cancel button will prevent the records from being recalculated. -
AuthorPosts
You must be logged in to reply to this topic.