Need help with uuid's?

@stcroppe @yisrael-wix @liran-kurtz-wix
Hi I am in the UK and am keen to see if someone can help me with one javascript support, I am new to this. I am looking to create two uuid’s and have them insert in to a database and also show on the page that has generated them. I have a dataset/collection called (Details). I have two text elements on my page to display the uuid’s #priKey and #pubKey all of what I have written so far works:

import wixData from ‘wix-data’;

import uuidv4 from ‘uuid’;
uuidv4();

function generatePriKey(item, priKey){
return uuidv4();
}
function generatePubKey(item, pubKey){
return uuidv4();
}
$w.onReady( function () {
$w(‘#createID’).onClick(() => {
$w(‘#priKey’).value = generatePriKey().toString(‘16’)
$w(‘#pubKey’).value = generatePubKey().toString(‘16’)
});

the above code shows the two uuid’s onClick within the two text elements and I thought it was as simple as connecting the text elements to the dataset? this however doesn’t work or display the uuid’s in the fields on the dataset after the onClick of a button #saveCode. Any help to achieve this would be greatly appreciated I am new to this.

Many thanks,

Simon

You also need to use one of the dataset functions: setFieldValue() or setFieldValues() and then do a dataset save() .

Hi Yisrael, thank you for your speedy response, would you happen to be able to show how this may be done? I am new to javascript, Id like to be able to do this in the backend also but it is currently on the page. would anything need to change? I will be working on this with your suggestions moving forwards. best regards Simon

@simonadams Just follow the example snippets given in the API links I provided. They will show you everything you need to know.

As far as doing this in the backend, you won’t be able to use datasets as they are only available in the frontend. You will need to use the wix-data API .

@yisrael-wix Thank you for your support it has been fantastic, I have finally figured out how to code what I need in utilising the suggested API links you are great. Is