top of page

Forum Posts

Oberdan
Aug 20, 2021
In Coding with Velo
Hello everyone, Clients fill up a custom Members Sign Up form on my website, which among other things captures a date. They input the date with a Date Picker. Once the client completes the sign up, I receive an automated email with the relevant info. On another page I past their email address on a form and I then use this code to pull the sign up information into the form. export function inputLoginEmail1_change(event) { let client1 = $w('#inputLoginEmail1').value; partnerEmail = client1; wixData.query("Members/PrivateMembersData") .eq('loginEmail', client1) .find() .then((results)=>{ if (results.items.length === 0) { $w('#textUserError').show(); } else { $w('#textUserError').hide(); let items=results.items; let FN = items[0].firstName; let LN = items[0].lastName; let userID = items[0]._id; customFieldsFunction(userID) .then((customFields) => { console.log(customFields) let options = { day: 'numeric', month: 'long', year: 'numeric' }; let DoB = customFields.DoB; let CoB = customFields.Birthplace; let Referral = customFields.Referral; let Gender = customFields.Gender; let Phone = customFields.phones.toString(); let CoR = customFields.Residence; $w('#inputDoB').value = DoB; $w('#inputCoB').value = CoB; $w('#inputCoResidence').value = CoR; $w('#inputGender').value = Gender; $w('#inputReferred').value = Referral; $w('#inputPhone').value = Phone; }) $w('#inputFN').value = FN; $w('#inputLN').value = LN; } }) } Here is the part that I need help with. When I receive their confirmation email, the date they entered in the form appears correct, however, when the above code pulls the date from the collection it always appears one day earlier; so if the client input 27 Oct 1989, this is the date that will appear on the email, but the above code would show this instead 1989-10-27T16:00:00Z Is the above code the reason for this issue? Thank you
0
3
86
Oberdan
Jan 22, 2021
In Coding with Velo
Good day all. I have this form, the yellow part of which is automatically populated by the code below upon entering the client's email address. The rest of the form in inputed manually. Code to pull form data from Collections: import wixData from 'wix-data'; import wixUsers from 'wix-users'; import {customFieldsFunction} from 'backend/customFields'; export function inputLoginEmail1_change(event) { let client1 = $w('#inputLoginEmail1').value; wixData.query("Members/PrivateMembersData") .eq('loginEmail', client1) .find() .then((results)=>{ if (results.items.length === 0) { $w('#textUserError').show(); } else { $w('#textUserError').hide(); let items=results.items; let FN = items[0].firstName; let LN = items[0].lastName; let userID = items[0]._id; customFieldsFunction(userID) .then((customFields) => { let DoB = customFields.Birthdate; let CoB = customFields.Birthplace; let Referral = customFields.Referral; let Gender = customFields.Gender; let Phone = customFields.phones.toString(); let CoR = customFields.Residence; $w('#inputDoB').value = DoB; $w('#inputCoB').value = CoB; $w('#inputCoResidence').value = CoR; $w('#inputGender').value = Gender; $w('#inputReferred').value = Referral; $w('#inputPhone').value = Phone; }) $w('#inputFN').value = FN; $w('#inputLN').value = LN; } }) } The problem I am facing is that on submitting the form, none of the fields in the yellow box above are inputted to the Collection. I found two workarounds so far, but neither seems like the ideal solution. WORKAROUND 1 I notice that if I tab into the automatically populated fields and I then add a space after the last text character, that field does actually get inputted to the collection correctly. WORKAROUND 2 I coded my way around on another form where I had the exact same problem by: creating onClick function using onAfterSave retrieving the ID of the newly submitted entry updating it with the values of the fields in the yellow box in the above screenshot here is the code I used in the other form: export function button7_click(event) { $w("#datasetIntake").onAfterSave( () => { let userId = wixUsers.currentUser.id; getItemID (userId) .then((results) => { let items = results.items[0]; let itemId = items._id; chooseUpdateItems(itemId) .then((item)=>{ let oggetti = item; oggetti.email = $w('#textEmail').text; oggetti.firstName = $w('#textFN').text; oggetti.lastName = $w('#textLN').text; updateItemId(item) }) }); }) } This second work around works well, but I thought that using the standard Submit function on the Editor, coupled with a custom onClick function in the code can cause issues. And in any case it seems like a waste of time to use these workarounds if indeed the automatically populated fields are also supposed to be inputted to the collection upon submitting the form. Any suggestions please?
On submitting fields don't get copied to collection content media
0
2
58
Oberdan
Jan 22, 2021
In Coding with Velo
Good day all. I have this form, which is automatically populated by the code below upon entering the client's email address: import wixData from 'wix-data'; import wixUsers from 'wix-users'; import {customFieldsFunction} from 'backend/customFields'; export function inputLoginEmail1_change(event) { let client1 = $w('#inputLoginEmail1').value; wixData.query("Members/PrivateMembersData") .eq('loginEmail', client1) .find() .then((results)=>{ if (results.items.length === 0) { $w('#textUserError').show(); } else { $w('#textUserError').hide(); let items=results.items; let FN = items[0].firstName; let LN = items[0].lastName; let userID = items[0]._id; customFieldsFunction(userID) .then((customFields) => { let DoB = customFields.Birthdate; let CoB = customFields.Birthplace; let Referral = customFields.Referral; let Gender = customFields.Gender; let Phone = customFields.phones.toString(); let CoR = customFields.Residence; $w('#inputDoB').value = DoB; $w('#inputCoB').value = CoB; $w('#inputCoResidence').value = CoR; $w('#inputGender').value = Gender; $w('#inputReferred').value = Referral; $w('#inputPhone').value = Phone; }) $w('#inputFN').value = FN; $w('#inputLN').value = LN; } }) } Everything works perfectly, except for Birthdate. As you can see from the Contact List screenshot below, Birthdate is a valid field, but for some reason it is the only one that the code does not bring back. Below I also included the code in the backend customFieldsFunction(userID) function. Is there an error in the code somewhere? Thank you import wixCrmBackend from 'wix-crm-backend'; export function customFieldsFunction (contactId) { return wixCrmBackend.getContactById(contactId); }
CustomFields Only Work Partially? content media
1
2
91
Oberdan
Jan 12, 2021
In Coding with Velo
Good day everyone, I have a form on this site https://www.oberdanmarianetti.com/0thsel When I submit the form on this page on the Wix Editor Preview page, everything works perfectly. However, when I submit the same form on the live site the entry created in the collection named "Selection" does not record an _owner ID (see attached screenshots). Everything else works well and all data on the form is correctly submitted to the collection. I tried the live website on desktop (chrome, safari and firefox), none worked. I also tried the live site on mobile (chrome and safari). none worked. The form is submitted by connecting each form field and the Submit button to data. The page however also has some custom coding, but I am sure it's not conflicting with the submit button. Here it is... export function button6_click(event) { $w('#textLoading').show(); } I am also attaching screenshots from the live and sandbox collections, you'll see the Owner field on both. Any suggestion please? Thank you in advance.
_owner missing from live collection content media
0
6
25
Oberdan
Jun 20, 2020
In Coding with Velo
I just had a ridiculous exchange with the Wix Customer Care team and I wonder if I can solve my query with Corvid. A client asked me for their full Wix Bookings record, which they have to submit for business purposes, and that span across a few years. When the client looks at My Bookings, the history only goes back to the beginning of 2020. I checked at my end through the Dashboard, via the Customer Contact List, and I get a limited list and a message saying, "Bookings. This list shows maximum of 50 bookings". I contacted Wix Customer care and their proposed solution is that I access the Dashboard Bookings Calendar and I manually extract the record for this particular client, week by week, across several years. This is ridiculous! As a small business we can't afford to spend hours and hours manually going through the calendar to generate a report that is likely to have errors. These are business records, something that we, as clients, should be able to report on for operational or audit purposes with a few clicks. Is there a way to query a Wix Bookings collection to create these reports?
0
2
36
Oberdan
Oct 21, 2019
In Coding with Velo
I have create an updatable form that users can submit the first time they access it, or amend it in subsequent visits. The form is completely managed via Wix Code as I could not make it updatable with the standard form properties in the Editor. Everything is working perfectly, except that I can't figure out how to stop the Submit button to submit when one field is left empty. This is the code behind the form. import wixUsers from 'wix-users'; import wixData from 'wix-data'; import wixLocation from 'wix-location'; $w.onReady(()=> { if(wixUsers.currentUser.loggedIn){ wixData.query("PreWorkSet1") .eq('_owner', wixUsers.currentUser.id) .find() .then((results)=>{ let items=results.items; $w('#textBoxQ11').value=items[0].q11; $w('#textBoxQ12').value=items[0].q12; $w('#textBoxQ13').value=items[0].q13; $w('#inputQ21').value=items[0].q21; $w('#inputQ22').value=items[0].q22; $w('#inputQ23').value=items[0].q23; $w('#textBoxQ24').value=items[0].q24; $w('#textBoxQ32').value=items[0].q32; $w('#textBoxQ41').value=items[0].q41; $w('#dropdownQ31').placeholder=items[0].q31; const q21 = items[0].q21; const q22 = items[0].q22; const q23 = items[0].q23; $w("#dropdownQ31").options = [ {"label": q21, "value": q21}, {"label": q22, "value": q22}, {"label": q23, "value": q23} ]; }) } }) export function textBoxQ11_change(event) { if ($w('#textBoxQ11').value === undefined) { $w('#button1').disable(); $w('#textErr').show(); } else { } } export function inputQ21_change(event) { $w("#dropdownQ31").options = [ {"label": $w('#inputQ21').value, "value": $w('#inputQ21').value}, {"label": $w('#inputQ22').value, "value": $w('#inputQ22').value}, {"label": $w('#inputQ23').value, "value": $w('#inputQ23').value}, ]; /*if ((($w('#textBoxQ11').value)=== null) || (($w('#textBoxQ12').value) === null)) { $w('#button1').disable(); $w('#textErr').show(); } else { $w('#button1').enable(); $w('#textSuc').show(); }*/ } export function inputQ22_change(event) { $w("#dropdownQ31").options = [ {"label": $w('#inputQ21').value, "value": $w('#inputQ21').value}, {"label": $w('#inputQ22').value, "value": $w('#inputQ22').value}, {"label": $w('#inputQ23').value, "value": $w('#inputQ23').value}, ]; } export function inputQ23_change(event) { $w("#dropdownQ31").options = [ {"label": $w('#inputQ21').value, "value": $w('#inputQ21').value}, {"label": $w('#inputQ22').value, "value": $w('#inputQ22').value}, {"label": $w('#inputQ23').value, "value": $w('#inputQ23').value}, ]; } export function button1_click() { let userId = wixUsers.currentUser.id; wixData.query("PreWorkSet1") .eq("_owner", userId) .find() .then((results) => { let items = results.items[0]; if (results.items.length === 0){ let toInsertQOnes = { "q11": $w('#textBoxQ11').value, "q12": $w('#textBoxQ12').value, "q13": $w('#textBoxQ13').value, "q21": $w('#inputQ21').value, "q22": $w('#inputQ22').value, "q23": $w('#inputQ23').value, "q24": $w('#textBoxQ24').value, "q31": $w('#dropdownQ31').value, "q32": $w('#textBoxQ32').value, "q41": $w('#textBoxQ41').value }; wixData.insert("PreWorkSet1",toInsertQOnes) .then((results2) => { let items2 = results2; wixLocation.to("/pw1-summary"); }) .catch((err) => { let errorMsg=err; }) } else { let currentItemId = items._id; let toUpdateQOnes = { "_id": currentItemId, "q11": $w('#textBoxQ11').value, "q12": $w('#textBoxQ12').value, "q13": $w('#textBoxQ13').value, "q21": $w('#inputQ21').value, "q22": $w('#inputQ22').value, "q23": $w('#inputQ23').value, "q24": $w('#textBoxQ24').value, "q31": $w('#dropdownQ31').value, "q32": $w('#textBoxQ32').value, "q41": $w('#textBoxQ41').value }; wixData.update("PreWorkSet1", toUpdateQOnes) .then((results3) => { let items3 = results3; wixLocation.to("/pw1-summary"); }) .catch(((err)=> { let errorMsg=err; })) } }) } On the Editor I marked all fields as 'Required' under their individual Settings box. But this makes no difference. I used several versions of this code: if ($w('#textBoxQ11').value === undefined) { $w('#button1').disable(); $w('#textErr').show(); } else { } within onChange() functions for the named field. Under the onClick() function for the button. I tried changing the word 'undefined' to 'null' and to ' "" '. I tried changing the word 'disabled' to 'hide' or 'collapse', but nothing seems to work. The Submit button always submits. When I console.log the field q11, which is the only one I left empty using the code console.log("Q11 FIELD VALUE" + $w('#textBoxQ11').value) The log shows, "Q11 FIELD VALUE" and nothing next to it When I console.log the field value length using code console.log("Q11 FIELD VALUE LENGTH" + " " + $w('#textBoxQ11').value.length) The log shows, "Q11 FIELD VALUE LENGTH 0" Any suggestions please?
0
2
70
Oberdan
Oct 19, 2019
In Coding with Velo
I am looking for a way for wixData.update to modify selected fields in the Collection without deleting every other field on the same row. The collection has 10 fields and I am I am using this code to insert, display or update the Collection data for 3 specific fields 'q11', 'q12' and 'q13'. import wixUsers from 'wix-users'; import wixData from 'wix-data'; import wixLocation from 'wix-location'; $w.onReady(()=> { if(wixUsers.currentUser.loggedIn){ wixData.query("PreWorkSet1") .eq('_owner', wixUsers.currentUser.id) .find() .then((results)=>{ let items=results.items; $w('#textBoxQ11').value=items[0].q11; $w('#textBoxQ12').value=items[0].q12; $w('#textBoxQ13').value=items[0].q13; }) } }) export function button1_click(event) { let userId = wixUsers.currentUser.id; wixData.query("PreWorkSet1") .eq("_owner", userId) .find() .then((results) => { let items = results.items[0]; if (results.items.length === 0){ let toInsertQOnes = { "q11": $w('#textBoxQ11').value, "q12": $w('#textBoxQ12').value, "q13": $w('#textBoxQ13').value }; wixData.insert("PreWorkSet1",toInsertQOnes) .then((results2) => { let items2 = results2; wixLocation.to("/preworkset1-p2"); }) .catch((err) => { let errorMsg=err; }) } else { let currentItemId = items._id; let toUpdateQOnes = { "_id": currentItemId, "q11": $w('#textBoxQ11').value, "q12": $w('#textBoxQ12').value, "q13": $w('#textBoxQ13').value }; wixData.update("PreWorkSet1", toUpdateQOnes) .then((results3) => { let items3 = results3; wixLocation.to("/preworkset1-p2"); }) } }) } The diplay part within the onReady works perfectly. I am having problems with the part within 'button1_click'. Any time a user submits the data, the three specific fields are inserted or updated perfectly, however, the other 7 fields in the same row get deleted. How do I get the button1_click to update the 3 fields without deleting the other 7?
0
3
2k
Oberdan
Jun 17, 2019
In Coding with Velo
Hello there, I have created a form for Site Members to submit a survey. The page permission is: Members Only The dataset on the page is: Read / Write The User Input fields are correctly connected to each collection fields. The collection permission is set to: Read: Site Member Author (SMA); Create: Site Member; Update: SMA; Delete: Admin As far as I understand this should give the logged in user the opportunity to submit the survey, and upon subsequent logins, view the submitted survey and updated it if necessary. And yet the fields and the Submit button are greyed out. Any ideas please?
1
4
695
Oberdan
Jun 17, 2019
In Coding with Velo
Hi all, Is anyone here experiencing problems with the Paid Plans app showing the wrong 'Number of Session' count? I have some users who booked and cancelled a few sessions, and the numbers don't tally. I wrote to the helpdesk, but unlike what the name suggests, they were of little help. I told them I had already done a manual count of each booking/cancellation and to check why the problem was occurring and how it could be fixed. Their answer was to send me screenshots on how to count users' completed bookings. Very frustrating!!! Is there a way for me to create a query on the bookings collection to download a specific user set of bookings? Thanks
0
0
19
Oberdan
Apr 02, 2019
In Coding with Velo
Over the last weeks or so I have been experiencing a lot of unexpected issues with my wix site. I am unsure whether the issue is linked to my installing the Paid Plans app or because Wix made changes to its platform, either way, something is going on in the back end, which I have no control over. Here is one issue I am having (see the two troubleshooting videos here: https://www.essence-rooms.com/troubleshootingvideos) IN SUMMARY My Wix Code login script no longer works on Firefox and Safari, but it works perfectly on Google Chrome. Please note NO CHANGES have been made to that code for many weeks and everything was working perfectly. Upon consolling the login procedure on the three browsers, I notice new entries that were never there before, which is what leads me to believe Wix made some generic changes in the back end, which are affecting the site. Here is the output I get on console upon opening the webpage - clicking on the Login button - and submitting the correct username and pwd CHROME creating bolt instance 5698.094999999739 init.js:216 created bolt instance 7760.054999998829 main-base.js:8 finished hydrate 10781.239999996615 wixcode-worker.js:17 Loading the code for the site. To debug this code, open masterPage.js in Developer Tools. wixcode-worker.js:17 Loading the code for the HOME page. To debug this code, open czhbf.js in Developer Tools. wixcode-worker.js:17 Failed to load initial data e.(anonymous function) @ wixcode-worker.js:17 (anonymous) @ wixcode-worker.js:17 r.error @ app.js:1 t.(anonymous function) @ app.js:7 errorReporter @ app.js:1 (anonymous) @ app.js:6 Promise.catch (async) (anonymous) @ app.js:6 (anonymous) @ app.js:6 (anonymous) @ app.js:1 Ok @ app.js:6 (anonymous) @ app.js:1 e.exports @ app.js:6 qe @ app.js:6 (anonymous) @ app.js:6 e.exports @ app.js:6 (anonymous) @ app.js:1 createControllers @ app.js:1 r @ wixcode-worker.js:17 (anonymous) @ wixcode-worker.js:17 Promise.then (async) (anonymous) @ wixcode-worker.js:17 (anonymous) @ wixcode-worker.js:17 (anonymous) @ lodash.min.js:67 (anonymous) @ wixcode-worker.js:17 (anonymous) @ wixcode-worker.js:17 (anonymous) @ wixcode-worker.js:17 o @ wixcode-worker.js:17 handle @ wixcode-worker.js:17 self.onmessage @ wixcode-worker.js:17 2googleMap.html:1 Uncaught SyntaxError: Unexpected token o in JSON at position 1 at JSON.parse (<anonymous>) at updateMap (googleMap.html:133) at saveMsgAndUpdateMap (googleMap.html:188) updateMap @ googleMap.html:133 saveMsgAndUpdateMap @ googleMap.html:188 postMessage (async) (anonymous) @ contentscript.js:1 console.js:35 Loading the code for the site. To debug this code, open masterPage.js in Developer Tools. console.js:35 Loading the code for the SERVICES page. To debug this code, open jobuh.js in Developer Tools. raven.js:135 navigation-initialization: before init raven.js:135 navigation-initialization: after init raven.js:135 navigation-initialization: after register nav raven.js:135 fallback-nav: doFallbackRedirect raven.js:135 navigation-initialization: after redirect raven.js:135 $routeChangeSuccess with: scriptsIndex.js:2 event= scriptsIndex.js:2 next= scriptsIndex.js:2 current= FIREFOX Loading the code for the site. To debug this code, open masterPage.js in Developer Tools. wixcode-worker.js:17:146686 Loading the code for the HOME page. To debug this code, open czhbf.js in Developer Tools. wixcode-worker.js:17:146686 creating bolt instance 21380 init.js:196:20 created bolt instance 22802 init.js:216:20 finished hydrate 27369 main-base.js:8:4 TypeError: a is null[Learn More] index.js:409 Failed to load initial data Error: The current user does not have permissions to read on the Users collection. wixcode-worker.js:17:146686 Firefox can't establish a connection to the server at wss://s-usc1c-nss-208.firebaseio.com/.ws?v=5&ns=wix-engage-visitors-prod-11. index.esm.js:10756:30 No user is currently logged in wixcode-worker.js:17:146686 TypeError: a is null[Learn More] index.js:409 The connection to wss://wix-engage-visitors-prod-27.firebaseio.com/.ws?v=5 was interrupted while the page was loading. index.esm.js:10756:30 The connection to wss://s-usc1c-nss-208.firebaseio.com/.ws?v=5&ns=wix-engage-visitors-prod-11 was interrupted while the page was loading. index.esm.js:10756:30 SAFARI [Log] creating bolt instance – 3433.4 (bolt-main-r.init.js, line 1) [Log] created bolt instance – 3989.4 (bolt-main-r.init.js, line 1) [Log] finished hydrate – 5260.6 (bolt-main-prod.js, line 3) [Info] Loading the code for the site. To debug this code, open masterPage.js in Developer Tools. (wixcode-worker.js, line 17) [Info] Loading the code for the HOME page. To debug this code, open czhbf.js in Developer Tools. (wixcode-worker.js, line 17) [Error] Failed to load initial data – Error: The current user does not have permissions to read on the Users collection. Error: The current user does not have permissions to read on the Users collection. (anonymous function) (wixcode-worker.js:17:146943) (anonymous function) (wixcode-worker.js:17:283033) (anonymous function) error (app.js:1:231160) (anonymous function) (app.js:7:46783) (anonymous function) (app.js:6:142823) a (wixcode-worker.js:17:87095) (anonymous function) (wixcode-worker.js:17:87240) c (wixcode-worker.js:1:36687) promiseReactionJob [Log] No user is currently logged in (wixcode-worker.js, line 17) Notice how Firefox and Safari state "No user is currently logged in" even though the login details are correct and working perfectly on Chrome. Any help from the Wix team please? I have a ticket opened with the support team already about the Paid Plans issue, while they are investigating, their initial response was to say that what I was experiencing was a "one off", even though I later shared data from multiple users experiencing the same problem. Here I am looking for help on the Wix Code side, but I can't help suspect that the issues are related, given they appeared suddenly and unexpectedly, given that the site was working perfectly for a long time.
0
18
1k
Oberdan
Jan 19, 2019
In Coding with Velo
Good day all, I have a form for members to complete their profile. The form is quite long and rather than link it to one collection, I divided it in sections, each linked to a separate collection. I checked with the Wix support team, and they tell me it is not possible to link the Submit button to multiple collections and should either put multiple Submit buttons on the form or code the page. I have successfully coded the form to submit to multiple collections, here is an extract of the code: import wixData from 'wix-data'; export function button4_click(event) { let toInsertCliDetails = { "dateOfBirth": $w('#datePicker1').value, "ethnicity": $w('#dropdown17').value, "relationshipStatus": $w('#dropdown21').value, "financialStatus": $w('#dropdown18').value, "previousCounselling": $w('#dropdown22').value, "preferredLanguage": $w('#iLanguages').value, "cliTAndCs": $w('#checkbox1'), "addressLine1": $w('#input14'), "addressLine2": $w('#input15'), "city": $w('#input16'), "postcode": $w('#input17'), "state": $w('#input18'), "country": $w('#input19'), }; wixData.insert("ClientDetails", toInsertCliDetails) .then( (results) => { let item = results; //see item below console.log("Cli Detail OK"); } ) .catch( (err) => { let errorMsg = err; } ); let toInsertCliVisiting = { "monday": $w('#checkbox3').value, "tuesday": $w('#checkbox2').value, "wednesday": $w('#checkbox8').value }; wixData.insert("CliVisitingHours", toInsertCliVisiting) .then( (results) => { let item = results; //see item below console.log("Cli VIsiting OK"); } ) .catch( (err) => { let errorMsg = err; } ); } I would love some suggestions to solve the following issues: 1. if members click submit multiple times, multiple entries are created in the collection, instead of the existing one being updated 2. if members navigate to a different page and come back to the form, the form does not read the collections to show the existing data, but it is reset Many thanks
0
2
285
Oberdan
Jan 02, 2019
In Coding with Velo
Happy New Year folks, I modified the Page Code provided here (https://support.wix.com/en/article/wix-code-tutorial-sending-an-email-on-form-submission) with an onBeforeSave that checks if the email address being inputted in the form already exists in the Users collection. The console shows that the onBeforeSave is correctly identifying duplicate emails, but somehow the 'return false;' is not cancelling the save and the items are still being copied the "#dataset2" Collection, which in turns calls the onAfterSave that sends the SendGrid email. How do I cancel the save when the email is deemed to be a duplicate? One small additional problem is that '$w('#errorText').show();' is consolled as 'Unreacheable code' and the error message does not show. Here is the onReady code I wrote: $w.onReady(function () { //check existing members to stop referral if email is already signed up in "Users" $w("#dataset2").onBeforeSave( () => { //create variable to compare query results with the value of the input field let emailcheck = $w('#iReferral').value; console.log(emailcheck); //run data query in "Users" collection to find possible duplicate wixData.query("Users") .eq("email", emailcheck) .find() .then((results) => { let items = results.items; console.log(items); if (results.length > 0) { //email is not unique. show error and stop the save function console.log("Cancelling save"); return false; //show message to alert user that email they are referring is already signed up $w('#errorText').show(); } }).catch((err) => { let errorMsg = err; }); } ); //if save is successful send the SendGrid email accordingly $w("#dataset2").onAfterSave(sendFormData); }); "#dataset2" = the collection into which the page form sends data "#iReferral" = the input field into which users type new email addresses "#errorText" = the text string to appear if 'save' is cancelled
0
6
658
Oberdan
Dec 18, 2018
In Coding with Velo
Hello community, I am looking to redirect logged in users who have yet to complete their members profile when they visit the bookings page (https://www.essence-rooms.com/services). Here is the code: $w.onReady( () => { if(wixUsers.currentUser.loggedIn) { let url = wixLocation.url; console.log(url); if(url === "https://www.essence-rooms.com/services") { let tandcs = $w("#dataset1").getCurrentItem().tandcs; console.log(tandcs); if(tandcs === true) { $w('#text86').text = "True"; } else { $w('#text86').text = "False"; wixLocation.to(`/Users/${wixUsers.currentUser.id}`); } } } }) Once logged in and clicking on https://www.essence-rooms.com/services console.log(tandcs) shows this message "TypeError: null is not an object (evaluating '$w("#dataset1").getCurrentItem().tandcs')" and the page does not redirect. However, if I then refresh the page (F5) console.log(tandcs) shows 'undefined' and the page is correctly redirected. '#text86' never changes, regardless of scenario. Any suggestions please?
0
7
341
Oberdan
Nov 19, 2018
In Coding with Velo
Hello, I would like to create an onClick event on one of the buttons in my nav bar, but the properties panel only shows the ID for the whole bar - 'horizonalMenu1'. How can I create an onClick event for one button only? Here is the broader context. - user clicks on button in nav bar - code checks a condition in the database against that userID - if condition is not met, user is sent to an alternative url, rather than the one linked in the nav bar Thank you.
0
5
842
Oberdan
Oct 10, 2018
In Coding with Velo
Hello there. I would like to have the members profile form refreshes on submit. Here a 1 min video to explain what currently happens. https://screencast-o-matic.com/watch/cF66V9YYJe Thank you
0
2
28
Oberdan
Sep 30, 2018
In Coding with Velo
Hi everyone. I created a Login button using the suggested Wix code (see below). The button works perfectly on these two required features: - redirect to the 'home page' after logout - redirect to the 'services' page after login What I would like the button to do is to redirect to a third page (called 'profile') if the user is new and chooses to sign up instead of log in. Any ideas please? LOGIN BUTTON CODE export function loginButton_click() { // if a user is already logged in if(wixUsers.currentUser.loggedIn) { // go to home page wixLocation.to("/"); // log the user out wixUsers.logout() .then( () => { // and update buttons accordingly setButtons(true); } ); } // if a user is already logged out else { let userId; let userEmail; // then prompt the user to log in wixUsers.promptLogin( {"mode": "login"} ) .then( (user) => { userId = user.id; return user.getEmail(); } ) .then( (email) => { // check if there is an item for the user in the collection userEmail = email; return wixData.query("Users") .eq("_id", userId) .find(); } ) .then( (results) => { // if an item for the user is not found if (results.items.length === 0) { // create an item const toInsert = { "_id": userId, "email": userEmail }; // add the item to the collection wixData.insert("Users", toInsert) .catch( (err) => { console.log(err); } ); } else // update buttons accordingly setButtons(true); wixLocation.to("/services"); } ) .catch( (err) => { console.log(err); } ); } }
0
11
2k
Oberdan
May 04, 2018
In Coding with Velo
Help please, I suspect this is a simple one, but I am unable to find a solution. The button in the middle of the page (Sign Up) does not change label after login, unless I do a refresh (F5). This is the page prior to login... This is the page immediately after login... This is the page after I press F5 and the page reloads... All buttons, including My Profile, are governed by the same function (setButtons). But for some reason #profileButton and #textWelcome work without a need for F5, while the two #bookButton only change label after F5. Here is the code that manages the buttons behaviours. import wixUsers from 'wix-users'; import wixData from 'wix-data'; import wixLocation from 'wix-location'; export function setButtons(showButtons) { if (showButtons) { $w("#loginButton").label = "Logout"; $w("#profileButton").show(); $w("#textName").show(); $w("#textWelcome").show(); } else { $w("#loginButton").label = "Login/Signup"; $w("#profileButton").hide(); $w("#textName").hide(); $w("#textWelcome").hide(); $w("#bookButton1").label = "Sign up"; $w("#bookButton2").label = "Sign up"; } } $w.onReady( () => { if(wixUsers.currentUser.loggedIn) { setButtons(true); } else { setButtons(false); } } ); export function loginButton_click() { // user is logged in if(wixUsers.currentUser.loggedIn) { // log the user out wixLocation.to("/"); wixUsers.logout() .then( () => { // update buttons accordingly setButtons(true); } ); } // user is logged out else { let userId; let userEmail; // prompt the user to log in wixUsers.promptLogin( {"mode": "login"} ) .then( (user) => { userId = user.id; return user.getEmail(); } ) .then( (email) => { // check if there is an item for the user in the collection userEmail = email; return wixData.query("Users") .eq("_id", userId) .find(); } ) .then( (results) => { // if an item for the user is not found if (results.items.length === 0) { // create an item const toInsert = { "_id": userId, "email": userEmail }; // add the item to the collection wixData.insert("Users", toInsert) .catch( (err) => { console.log(err); } ); } // update buttons accordingly setButtons(true); } ) .catch( (err) => { console.log(err); } ); } }
Button Label Does Not Refresh content media
0
2
325
Oberdan
Mar 23, 2018
In Coding with Velo
Hello there, I have an array in my collection and I was wondering how to display its content in a bullet point list. Thanks
1
0
143
Oberdan
Mar 05, 2018
In Coding with Velo
UPDATE: I SOLVED THIS USING CHECKBOXES ORIGINAL POST: Hi folks. Is there a way for me to create a dropdown list that allows multiple selections to be fed into one DB field, which then shows up on a dynamic item page as a bulleted list? Imagine you just signed up on a page and your profile update includes 'languages spoken'. I would like the user to be able to select however many languages they speak and for them to be fed into the one 'Languages' field I have in the DB collection. If a dropdown is not possible, is there a way this can be achieved with checkboxes or any other tool? Many thanks
2
7
2k

Oberdan

More actions
bottom of page