I have a dinamic page with a list of designers you can choose from, and when you open one designer in particular (another "read" dynamic page) there is a button to "select designer". When pressed, I need for it to save the "Name" of the designer (belonging to the Designers database) to a field in a database called Proyects. I´ve being trying to get the code right from this post:
but it´s not working. All the database ID are correct. This is the code I tried:
export function button1_click(event, $w) { $w.onReady( () => { $w("#designers).onReady( () => { let itemObj = $w("#designers").getCurrentItem() $w('#designers').setFieldValue('#Name, $w('#Name').value) $w("#Proyects).save() } ); } ); }
I´m totally new at code so probably a few things are wrong!
Amazing!! Thank you so much!
thank you so much for the magiiiiiiiiiiiic! it worked! ❤️❤️❤️
Ok, here a try without knowing all your data-structure.
Replace/fill the related datasets with your own.
Dataset-A = designer-database (READ-ONLY)
Dataset-B = proyects (WRITE-ONLY)
Set the right reference-IDs ! ! ! ---> (look into your databases)
$w.onReady(function () { let itemObj $w('#button1').onClick(()=>{ $w('#dataset1').onReady( () => { itemObj = $w('#dataset1').getCurrentItem(); console.log(itemObj) console.log(itemObj.title) }) $w("#dataset2").onReady(() => { $w('#dataset2').setFieldValue('title', itemObj.title) $w('#dataset2').save() }) }) });
Press-F12 and go to CONSOLE, to see whats going on.
Can still have some failures, but should work.
This code do a copy of the curent item ("title") of database-A to database-B (title). Change by your needs and optimize the code.
Hello yuyog,
please show a peace of your 2 databases in a pic (each the first 2 rows and the header). And show the IDs of the relevant references (columns).