Wix database SPART where i’m importing the data on daily basis there is a field " SPARapb" Where i need to generate a random alphabet =“ABSPARTXYZ” How to do this.
if i generated this random alphabet on the database fields my project will Go live. please help me on this
Not sure if that’s what you’d like, but I myself have a script that automatically generates a random 10 digit number and inserts it in the colection when the user submits an item to the collection.
This helps me have a custom unique reference, here you go :
(code on the ‘submit item’ page)
unixCode();
function unixCode (){
var timeStamp = Math.floor(Date.now()/1000);
$w('#input11').value = timeStamp.toString();
}
basically this will generate a random number in the input #input11, this input is connected to the “reference” field in my collection, so every submitted item has a unique ID.
Hi Tristan,
SPAR Nigeria will run a special campaign for their retail consumers.
Upon a loyal customer visiting a SPAR outlet and purchasing items, he/she will be sent a random alphabet
During the duration of this campaign period,
If he/she gets all the alphabets constituting the word SPAR T, an SMS will be sent.
I have a Table name SPART in wix where i am going to import the invoice data on daily basis at EOD.
once i imported the data in to wix DB as shown in the pic. there is a field called SPARTABP needs to generate the random Alphabets.
I don’t think this is possible to tamper with collections’ settings 
Hi,
Generating a random character is pretty straightforward. See the code below.
Note that you will have to check if any given character was generated previously, either by keeping it in a list or by removing the character from the possible variable.
function generateChar() {
let possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
return possible.charAt(Math.floor(Math.random() * possible.length));
}
Where this code goes is up to you, however you will probably want to add it in a hook to be generated once a new customer is added to the system.
Also consider adding a new field in your customer collection to keep the generated string, plus an additional field to keep the current index to send.