Jump to content
  • 0

Pre Fix Problem with Sequential Numbering


plance

Question

Hello,

I currently have a db that uses 9 diff prefixes and then a random unique number. When a staff member enters / submits the form everything works fine except the FIRST time they do this per day. So for example, their first entry would look like 12-3- on the table. It should look like 12-3-42516325....

I have to go back into the table and put in my own "random" number when this happens.

Any advice would be helpful and much appreciated!

~ Paul

Link to comment
Share on other sites

6 answers to this question

Recommended Posts

  • 0

I see why it is not working. You are using a JavaScript to combine the two virtual fields and put them into a real field in the table, however Random Unique ID is generated in the server level but JavaScript is on the client level. In other words, the JavaScript cannot pick up the autovalue number because the number is not generated yet. This type of combination requires the code run at the server level such as a database trigger to combine the two values.

If you want to use JavaScript you cannot use the Autovalue field, instead you can write another JavaScript to also create a random unique id.

Best,

Bahar M.

Link to comment
Share on other sites

  • 0

Here is the script that generates 8 digit random number and put it in RandomNum field. It goes to the footer of the submission page.

function r_num()

{

var randNum = "";

var MAX_LENGTH = 8;

while(randNum.toString().length

var temp = Math.floor(Math.random() * 10);

randNum += temp.toString();

}

document.getElementById("InsertRecordRandomNum").value=randNum;

}

document.getElementById("caspioform").onsubmit=r_num;

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...