Forum Discussion
- EOMDeveleporsQrew CaptainThis is a copy of a pastie by Dan. Can't find the original post:
function makePasswd() {
var passwd = '';
var chars = '0123456789';
for (i = 1; i < 8; i++) {
var c = Math.floor(Math.random() * chars.length + 1);
passwd += chars.charAt(c)
}
return passwd;
}
//replace fid_21 with the field ID you want to enter the autonumber.
$("#_fid_21").val(makePasswd()); - ChayceDuncan2Qrew CadetIs there a specific reason you're trying to use IOL instead of a form rule or an automation? The above might work - but if you have the 'next' number in a field somewhere you can reference - you can have a form rule populate the sequence number when someone is editing a record and this 'number' field is blank. Or - same thing - but have an automation populate it when you save and there is not 'number' entered yet.
Chayce Duncan | Director of Strategic Solutions
(720) 739-1406 | chayceduncan@quandarycg.com
Quandary Knowledge Base - KristyWillifordQrew Assistant CaptainHello,
Thank you all for your responses.But I tried doing it with record Id and did not work as whenever I delete a sample I want it to start from the beginning. - ChayceDuncan2Qrew CadetYou don't necessarily need 'Record ID#' in this case. You can get around it if you can summarize the # of records in your table to help with sequencing. So an example might be something like this:
You've got a table for 'Projects'. Each Project should auto-number based on its sequence per your comment - so it should be #1000 - not #1056 (the record Id#) because you deleted 56 of them along the way.
A trick in Quick Base is to do something like a table called 'Global'. Its an admin table only - and it has only 1 record - Record ID# 1. You relate your 'Global' table to 'Projects' - and you make it so that your 'Related Global' field in your Projects table - the field Quick Base tries to create for all new relationships - defaults to a value of 1. What this means then - is that every single Project in your system associates as a child of the one record in 'Global'
What that allows then - you can make a summary field of the # of Projects you have in your system into your 'Global' record - calculate what the next # should be based on the # of projects by adding 1 - then add a lookup of your 'next #' into Projects. Using a form rule - you can store that 'next #' into your project so its stored in place. Once you save the project - the # of Projects increases by one in your 'Global' table - and your next # increases by one also for the next project.
Chayce Duncan | Director of Strategic Solutions
(720) 739-1406 | chayceduncan@quandarycg.com
Quandary Knowledge Base- EOMDeveleporsQrew CaptainBut what happens if you delete projects along the way and the # of projects will be the same as it was yesterday which will cause it not to be unique.
- ChayceDuncan2Qrew CadetThats a good point. Instead of # of projects - you can summarize the Max Project # and use that as the reference point.
Chayce Duncan | Director of Strategic Solutions
(720) 739-1406 | chayceduncan@quandarycg.com
Quandary Knowledge Base