top of page

Forum Posts

Guy Tadmor
Mar 15, 2023
In Velo Pro Discussion
Hi, is it possible to send an email with an attachment to a contact using Velo API and Wix business email? I want to customize the event ticket purchase experience but the checkout() or startPayment() API does not send the ticket to the related contact after the order is confirmed, Checkout() returns a link to the ticket PDF but emailContact() is not capable to add an attachment to the email. It is a pity that this is not supported by Wix. I understand that sendGrid can be used but this requires an additional cost for the basic plan and sending emails via other providers probably requires to setup other staff to make sure these emails are not considered as spam by the contact mailbox. Thanks.
0
2
53
Guy Tadmor
Feb 01, 2023
In Velo Pro Discussion
I'm executing the below code on a collection which holds the purchased tickets for each event (event id is a reference field within this collection). I've added a console.time() and it shows that this takes around 0.5 sec. Seems to me a very poor performance as I need to perform additional queries in order to return a valuable result to the end user and the total takes around 1.5 sec. I've come to know about this since the site monitoring show timeouts when invoking the API. Is there a way to improve the performance for this kind of query? Will it help to replace the reference field with a regular field which will hold the event id? const filter = wixData.filter().eq("eventId", eventId); //const having = wixData.filter().gt("maxPopulation", 1000000); // .filter(filter) return wixData.aggregate("MyTickets") .filter(filter) .group("ticketId") .count() .run() .then((results) => { if (results.items.length > 0) { console.log("items " + JSON.stringify(results.items)) console.timeEnd("getTicketsSum"); // let items = results.items; // let numItems = results.length; // let hasNext = results.hasNext(); } resolve(results); }) .catch((error) => { let errorMsg = error.message; let code = error.code; reject(error) });
0
5
51
Guy Tadmor
Jan 12, 2023
In Site & Page Design
Posting this in order to some research time to others. Used table element for displaying Event collection, almost each time I've clicked on a row, element refreshed the data and scrolled up. After some research, I've found out that this is probably to do with the fact the Events are read-only collection. To resolve this, I've manually populated the Table. Hope this will help others.
0
0
7
Guy Tadmor
Jan 06, 2023
In Velo Pro Discussion
I've been using the onOrderConfirmed( ) to track the event ticket in a proper manner by logging into a collection as understanding Ticket info per event is not an easy task using the dashboard (when coupons are used). I've realized that the payload structure of the event has changed recently, mainly the invoice part. "grandTotal" field has moved and the type of the amount fields changed to String. This caused the code to fail and not to log the event into the collection. This is my analysis so far... I've checked the release notes but there's no mentioning of this change. This kind of change appears to me as compatibility break and if it is perform, it should announced correctly to all ! It took me a few hours to detect what is the exact issue, sad for em to spend so much time on this... I hope others can find this post and save some time. I hope wix team will take this into account.
1
2
34
Guy Tadmor
Oct 20, 2022
In Velo Pro Discussion
Is there a way to subscribe an existing contact (which is currently not subscribed) using Velo code? I was able only to update info and add labels to the contact but I didn't find any documentation how to subscribe (an email) of an existing contact. Appreciate your response. thanks, Guy.
1
1
41
Guy Tadmor
Apr 08, 2021
In Coding with Velo
Hi, I'm trying to upload file to Wix media using the signed URL which can be retrieved using getFileUrl(). After getFileUrl() is invoked on the wix backend, I get the signed Url without a token. I've tried using fetch() and XMLHttpRequest() to upload the file with the Url I got from a wix page by I but I get 500 response error. I've tried both to send the file as ArrayBuffer or as DataURI (base64) but it does not work. Did anyone knows how to do this properly ? Below the two functions I've tried: export function uploadFile(fileURL, content) { const body = { upload_token: fileURL.uploadToken, file: { value: content, options: { filename: "test.jpg", contentType: "image/jpeg" } } }; // ... fetch(fileURL.uploadUrl, { "method": "post", "headers": { // both content types does not work "Content-Type": "application/x-www-form-urlencoded" //"content-type": "multipart/form-data" }, "mode" : "no-cors" , "credentials":"same-origin", "body": JSON.stringify(body) }) .then((httpResponse) => { if (httpResponse.ok) { return httpResponse.json(); } else { return Promise.reject("Fetch did not succeed - response "+JSON.stringify(httpResponse)); } }) .then((json) => console.log(json.someKey)) .catch(err => console.log(err)); } export function uploadFileXHR(fileURL, content) { const xhr = new XMLHttpRequest(); xhr.open("POST", fileURL.uploadUrl, true); xhr.onload = () => { const status = xhr.status; if (status === 200) { console.log("File is uploaded"); } else { console.log("Something went wrong!, status "+ status); } }; xhr.onerror = () => { console.log("Something went wrong"); }; xhr.setRequestHeader('Content-Type', "image/jpeg"); xhr.send(content); }
0
0
104
Guy Tadmor
Dec 24, 2020
In Coding with Velo
I'm using emailConact to send email to one of the contacts which are kept in Ascend CRM (somewhere). When editing/viewing a contact in the site dashboard, there is an option to define several emails for a single contact, each one with a label (main, home...). However, either the CreateContact() or the getContactById() does not provide a way to define the label for each email address. In addition, when invoking emailContact() for specific contact which has several emails, the current. logic based on my testing is that the latest inserted contact's email is being used for the sending the email. There's no way to indicate via emailContact() which email to use, I would expect that in this case, the "main" email will be used. All the above means that I need to keep the contact's emails in a separate collection and update the contact with the email before invoking emailContact() so I can control to which email address the email is sent to. Any other suggestion, observations? thanks.
1
0
27
Guy Tadmor
Dec 19, 2020
In Coding with Velo
Can the session be configured so the page (client) cannot set a value to it, so hackers will not be able to hijack and manipulate it? I want to use the session values in the backend for saving user information which impact user permission to collections so letting the page make changes to it may results in modifying the permissions by the client. Alternatively, is there a way to use cache in the backend? expect for installation dedicate NPM package for caching... thanks, Guy
0
3
26
Guy Tadmor
Dec 14, 2020
In Coding with Velo
Hi, I'm trying to debug a page code where getCurrentItem() of dataset is invoked after repeater item is clicked. I'm using the Chrome JS debugger but I'm not able to view the result value of getCurrentItem() although it does get logged using console.log(). I'm trying to understand why does it behaves like this, I set the result of the getCurrentItem() into a JavaScript regular variable so why is it not showing any value? BTW - I'm able to set a breakpoint to the clickedItemData line as well. The code is: // API Reference: https://www.wix.com/corvid/reference // “Hello, World!” Example: https://www.wix.com/corvid/hello-world $w.onReady(function () { // Write your JavaScript here // To select an element by ID use: $w("#elementID") // Click "Preview" to run your code     console.log("on ready"); }); export function container3_click(event) { // This function was added from the Properties & Events panel. To learn more, visit http://wix.to/UcBnC-4 // Add your code for this event here:  debugger; let $item = $w.at(event.context); let clickedItemData = $item("#dataset1").getCurrentItem();     console.log("clicked "+ JSON.stringify(clickedItemData)); } Attached the screenshot of the Chrome debugger.
0
4
43
Guy Tadmor
Dec 12, 2020
In Coding with Velo
I'm trying to get a specific value of current item of a dataset which is filtered based on another dataset (has a reference to it in the collction) e.g email dataset filtered by person dataset. I understand that even when the filter does not match the other dataset, getCurrentItem() still returns an object which is null or undefined. Due to that I've added a check for it, so if it is null or undefined I'm not trying to get the field value. In preview mode it works great but when I check it on live site it throws null value error. Furthermore, when I open the chrome debugger and checking the getCurrentItem object it reports that it is not available. PFA the related code from the chrome debugger. Does anyone have an explanation for this?
0
4
2k
Guy Tadmor
Sep 13, 2020
In Coding with Velo
Hi, I've read all the documentation and several examples about the repeater element: 1. Repeater has data and items member objects. 2. To setup the items value, you need to pass the values to the data object and then on OnItemsReady event to pass the data object values to each item within the repeater. I've created a page where the repeater should create new entries in a collection, I've populated the repeater with initial data (several rows) and was expecting that any change the user does on the item will be reflected on the data object in the repeater as well, i.e item values will be synced to the data. However, this didn't happen and I had to read the repeater's items one by one in order to save the repeater to the collection. Am I doing something wrong? or the repeater items and data object are not being sync and when working with repeater without a dataset, I need to manually manage the items and data? why do I need the data object in this case? thanks,
0
1
110
Guy Tadmor
Jul 05, 2020
In Coding with Velo
Hi, I'm using a repeater connected to a dataset to display several items from the collection. As the user may change one or more items on the repeater, I want to save all of these changes in one button click. Is there an example how this should be done? Currently I'm doing the following: while ($w("#datasetPerson").hasNext()) {      var myPromise = await $w("#datasetPerson").next() } The this saved all the items regardless if there were changed. Is there a better way? is there a way to know for a specific item whether it was changed or not? BTW - save() of dataset saved only the current item.
0
0
58
Guy Tadmor
May 10, 2020
In Coding with Velo
Hi, I'm trying to use the upload() backend API from wix-media-backend, I'm passing DataURI as the fileContent parameter, "data:image/jpeg;base64,/9j/4AAQSkZ...." from the page to the backend but I get an error back ""StatusCodeError: 406 - {"error_code":-7751,"error_description":"Failed to get image info."}" and the image is not upload to the destination folder in wix media. Am I doing something wrong? which format the fileContent should be in? BTW - even if I put the DataURI in the backend code directly, it returns the same error. regards, Guy.
0
11
1k

Guy Tadmor

More actions
bottom of page