The Community forums are being phased out in favor of a new Slack group.
Add your email address below to get an invitation to join the community slack group

Slack Signup
Newsletter Optin
Help Desk

Auto Increment

Labels

This Discussion is public

Notifications

Hi,

I have autonumber in my form, giving it a unique ID, however it increments by 1. I am making my system fully automated where they can enter the ID number given to them and pull their quote.

Now, with GDPR regulations, anyone can find out someone elses details by putting in the number before / after theirs, so I need to have the number completely randomised. How can I do that?

 

For instance. One customer have 1056 and the next customer could be 3958, so no two numbers increment by one. Just assign a random 5 digit number or something?

 

That way, I would have the accept quote page where they enter their ID number and it would pull only their details - maybe password protect it or something?

Hi Leigh,

Generating a random number requires custom code. You can do it either in PHP or jQuery depending on when you want the number generated, i.e. before the form displays or after it's loaded on the page.

This explains how to generate a random number in jQuery to fit the after the page is loaded scenario. https://gist.github.com/Mikescops/e26a78da0d7d3563c1be

PHP is a different story and a little more complicated. I don't have the time to look up a code example for you right now, but if you'd rather use PHP, I'll see if I can find some code for you when I visit this forum again.

Hi Leigh,

We generate a random 9 digit number in a similar way. Here is the script we use:

function randomNumber(len) {
var randomNumber;
var n = '';
for(var count = 0; count < len; count++) {
randomNumber = Math.floor(Math.random() * 10);
n += randomNumber.toString();
}
return n;
}
window.onload = function() {
document.getElementById("field_xf50u").value = randomNumber(9);
};

Replace field_xf50u with the ID of the field you wish to store you number in.

Thanks

Chris | FDM Digital

Discussion closed.