wixCrm.createContact issue

Background:
I am trying to circumvent an issue caused by the fact that Wix-Stores does not allow to set a static “delivery address” (we do shop-only pick-up) and because of this asks every client to insert a personal address at confirmation, in order to calculate applicable tax rules - and picks up addresse already defined via wixCRM Contacts. If a client happens to have registered an address from another country, or even is using an IP address abroad, Wix-Stores interprets this to be as a need to calculate applicable VAT rules … which is nonsense, given that the settings for shipping are defined properly, as are applicable tax rules for the pick-up location. Wix Support told me that populating a static address in settings would not help - it needs to be set a customer level.

Workaround envisaged:
The workaround (not happy, but when testing it, it worked …) could be to create an additional static “c/o pick-up store” address within CRM contacts (we ask the client to confirm), for each and every one, at registration … but here is, where I got coding issues.

Coding issue:
I ask customers to first register, before doing business. For this, I first gather customer information via a separate page (works perfectly fine), then fire the below …createContact command “on click” (which does NOT work) and direct the client to a lightbox containing a Wix custom registration form, where I just reuse data in required fields and ask for a password (the registration part also works fine).

Any suggestions, please? I have run through many blogs here, but am apparently not able to reproduce the proposed solutions …

Or is it an issue that the registration overwrites data from the previously created contact??

Remark: below “short names” for field content work properly (data is reproducable via console.log). So no worries about this, either.

https://jochenimhoff.wixsite.com/test-bwi/registrierung

import wixCrm from 'wix-crm';

export function confirm_click(event) {

 let emails = []
 let email = $w('#confirmEMail').value
  emails.push(email)
 let country = $w('#land2') //value in ISO 3166 alpha-2 format (capital letters)
 let anrede = $w('#anrede').value
 let titel = $w('#titel').value
 let vorname = $w('#Vorname').value
 let nachname = $w('#Nachname').value
 let addressType = "SHIPPING" //hard entry to store single pick-up address
 let strasseNr = $w('#strasseNr2').value
 let postleitzahl = $w('#postleitzahl2').value
 let ort = $w('#ort2').value
 let bundesland = $w('#bundesland2').value

let contactInfo = {
 "Anrede": anrede, //custom field - written exactly like this (minor letters does not solve)
 "Titel": titel, //custom field - written exactly like this (minor letters does not solve)
 "firstName": vorname,
 "lastName": nachname,
 "emails": [emails],
 "addresses": [{
 "tag": addressType,
 "street": strasseNr,
 "city": ort,
 "state": bundesland,
 "country": country,
 "zip": postleitzahl}]
}

wixCrm.createContact(contactInfo)
.then( (contactId) => {
} );

setTimeout (function delay () {  
wixWindow.openLightbox("Custom Signup", {
 "vorname": $w('#Vorname').value,
 "nachname": $w('#Nachname').value,
 "email": $w('#confirmEMail').value,
  });3000})
 $w('#success').hide()
}

I get an error message “Wix code SDK error: The url parameter that is passed to the to method cannot be set to the value . It must be of type string.”

At browser console level (am using Chrome, not IE9 …), the following is stated regarding the above error message in the corresponding code line - otherwise, I am not transferring any non-string type of information to the back-end and back to the front-end on that page:

// this fails for some browsers. :frowning:
if (originalConsoleLevel) {
// IE9 doesn’t allow calling apply on console functions directly
// See: javascript - Does IE9 support console.log, and is it a real function? - Stack Overflow
Function.prototype.apply.call(originalConsoleLevel, originalConsole, args);
}

Could this be the reason for the above coding NOT creating the contact at all?

Hello Thomas! ( Ich hoffe der Wein schmeckt auch xD )

I get an error message " Wix code SDK error: The url parameter that is passed to the to method cannot be set to the value . It must be of type string."

This will be caused, because you work with different types of values (STRINGS and NUMBERS).
The DATABASE-REFERENCES should always have the same type as your inputfields.

For example you type a #NUMBER into your inputfield but setted your DATABASE-REFERENCE to STRING. This will cause an error.

In such situations you have to change the type or REFERENCE-FIELD in your DATASE, or in your INPUT.

Find your error-causing code-line and converst the types.

let myNewNumber = Number("12") //<--- converting STRING into NUMBER

let myNewString = (12).toString // <--- converting NUMBER into STRING

Perhaps this will solve your issue.

Спасибо, Дима! Посмотрю …

Dima, I checked it. Only difference in field definitions is that the email field is declared as “email” on the page (to allow for automated validation), while it is a text base in the collection / dataset. No numbers at all involved. Only string.

Any other possible reasons?

Oh, sogar so! OK :grin:

Good question, i will have to think about it.

Da guckst Du, was? :slight_smile:

To me, next to the error stated above, it’s all about that CRM contactInfo issue. All previous discussions about that topic lead to the Corvid API references - and directly applying register(email,password,contactInfo) did not work either. The API reference does not mention all those address fields that are available in those Ascend solutions - and that are downloadable as csv. Including Google field formats, outlook formats, plain ones … Importing tables allows to map fields, as well. But no access granted via code. As if somebody at all cost tried to get rid of data protection risks linked to person-related information. Not even applying the feld logic of the SDK CRM contact object ( https://dev.wix.com/api/rest/crm/contacts/contact-object ) (I know that methods are only applicable at Dashboard levels), in order to feed the tables, helps. Next, the only field that can be reached by connecting a Wix custom form to a contactInfo field would the one “addresses” and within that the address-type (shipping or else). But that data is then stored in the “street” field in Contacts. I also tried to populate that field with the Google address tag (geo positioning), in order to see, if there was some logic behind - NULL again.

Ja da staune ich nicht schlecht xD!

Ok, i will take a look closer to your issue (im verlaufe des Tages). :laughing:
Today is Saturday, have to do some homework. Stay connected.
:wink: In the meanwhile you can take a look onto my helping page, but it’s not a warranty that you will find a solution there especially for your issue.

Ну, есть люди в этом мире, которые интересуются инностраными языками … I do my very best, as they say :slight_smile: Thanks for you help here!

@russian-dima SOLVED: the issue was NOT the code, but a broken connection to the CRM data fields in Members/PrivateMembersData … I took me days fighting with that from all sides, before I realized that. Well, next time, I know where to look first … Thanks for your support!