HI! I need send the user input data to import into my CRM system. It is nice to have the wix database as a backup but in order for our sales team to work efficiently, I need the data the user enters into the form fields to be sent to our other CRM system. What code would I need to use?
I matched the CRM id names to the Wix Database/field id names, for example:
id=“fname, lname, email, phone, city, state, zip, analyte, analyte2, analyte_text, weight, dob, test_result”
then something like … action=“customer.i” method=“GET” onSubmit=“return checkform()”
Please help me fill in the blanks so that I get this to work. Thank you!
Ok I really need some additional input on this. I have been going through videos and other resource, but none of them tell me how to get the textinput to go into another database outside of wix. What is that command??
Here are some starting points: 1. Define each text input line item to do something
export function qualifyform_ready() {
//Add your code for this event here:
$w(“#fname”).result(where do I send the data? it needs to go directly into the database - located here: h idden );
$w(“#lname”).onChange(would this one read better? where do I send the data? );
$w(“#email”).enable(where/how?..);
$w(“#phone”)
$w(“#city”).toString(where/how?..);
$w(“#state”)
$w(“#zip”)
$w(“#analyte”)
$w(“#analyte2”)
$w(“#anlaytetext”)
$w(“#weight”)
$w(“#dob”)
$w(“#testresult”)
}
**2. ** Define the text input fields all together – not all are required.
export function qualifyform_afterSave() {
//Add your code for this event here:
$w(“#fname”,“lname”,“email”,“phone”,“city”,“state”,“zip”,“analyte”,“weight”,“analyte2”,“dob”,“analytetext”,“testresult”).enable(export? to… * export not recognized );
}
**3. ** Or maybe this is a better one
export function submit_click(event, $w) {
//Add your code for this event here:
$w(“#submit”).toString(" https://biolynk.com. …" this one is showing errors…);
}
Thank you Moshe! That got me closer, but still there are holes. After I sent the CRM guys your note, below is what they sent me: http://www.biolynk.com/customer.i ?
cmd=add&
type=rest&
fname=[fname]&
lname=[lname]&
dob=[dob]&
weight=[weight]&
city=[city]&
state=[state]&
zipcode=[zipcode]&
phone=[phone]&
email=[email]&
analyte=[analyte]&
analyte2=[analyte2]&
analyte_text=[analyte_text]&
testresults=[testresults]&
other=[other]&
They did not put it into code language, so I am guessing the code should something like this, but I do not know where to put these two elements…and so this is obviously not working.
cmd=add&
type=rest&
cmd=add&
type=rest&
are just static parameters that specify the command and that it’s a REST protocol.
I must say that the entire code you wrote here will not work, it has a lot of bugs,
I would like to kindly recommend you to seek the help of a pro at the Wix Arena .
To start with you need to use the wix-fetch API. wix-fetch - Velo API Reference - Wix.com
When you look at the API you will see that there are two arguments to the fetch function:
function fetch(url: string, [options: WixFetchRequest]):Promise<WixFetchResponse>
The URL is the one your CRM guys gave you - http://www.biolynk.com/customer.i
Now to complete the request per the CRM guy’s recommendation you need to go through each of the CRM properties you want to send and add the key value pairs to the end of the url.
To get you started try building this out:
import {fetch} from 'wix-fetch';
let crmApiURL = 'http://www.biolynk.com/customer.i?cmd=add&type=rest';
let apiQuery = '';
if ($w("#fname").value !== null && $w("#fname").value.length > 0) {
crmApiURL += addQuery(crmApiURL) + '&fname=['+$w("#fname").value+']';
}
if ($w("#lname").value !== null && $w("#lname").value.length > 0) {
crmApiURL += addQuery(crmApiURL) + '&lname=['+$w("#lname").value+']';
}
if ($w("#phone").value !== null && $w("#phone").value.length > 0) {
crmApiURL += addQuery(crmApiURL) + '&phone=['+$w("#phone").value+']';
}
// etc. for each property
fetch(crmApiURL, {method: 'get'})
// Check the result and manage errors - check the documentation for wix-fetch out
.then((fetchResult) => {
//Check to make sure the request was successful
})
.catch((error) => {
console.log(error);
});
Hi Steve!
Thank you! I was able to start with your code and make a few adjustments and now the URL will properly build!! >> Now I just need this newly constructed URL to send out somehow so that my CRM will pick it up. Right now I can see the URL in my console log (using the code below)
Hi Kim:
Is there an online page with the API spec that you need to use?
Typically if you are sending information to a web application to be stored or updated you need to use the method ‘post’ or ‘put’. Check out this web page .
You might want to try changing the method on line 27 to ‘post’. If that doesn’t work try ‘put’. These verbs are important so if you can get the full specification for the API that will be helpful.
What is the crmApiURL? At the moment it is set to “”.
You need to have an http endpoint to send the queries to
If you don’t understand this point you probably need to spend a little more time learning advanced JavaScript, the fetch API and the documentation for your external CRM