Writing to Contacts to change subscriptionStatus

Happy New Year everyone!

I have a large number of users in a database on non-Wix site and have authorization to email them. I am importing the dB to Wix and want to be able to set subscriptionStatus in the Contacts collection, so my client can use the Wix tools for email marketing.

I am using Wix Studio to test how this works at the moment and am adding a Contact with this object:

This is my back end code - a self contained block that I trigger from the front end by calling the function. I pulled all this out of the API, except for the bit I’m struggling with.


  console.log("running")
  const item = {
    name: {
      first: "Gene",
      last: "Lopez"
    },
    emails: [
      {
        tag: "WORK",
        email: "gene.lopez@example.com"
      },
      {
        tag: "HOME",
        email: "gene.lopez.at.home@example.com",
        primary: true
      }
    ],
    phones: [
      {
        tag: "HOME",
        countryCode: "US",
        phone: "(704)-454-1233"
      },
      {
        tag: "MOBILE",
        countryCode: "US",
        phone: "(722)-138-3099",
        primary: true
      }
    ],
    extendedFields: {
      ['emailSubscriptions.subscriptionStatus']: "subscribed"
    },
    labelKeys: [
      "custom.member"
    ]
  };

When I call this object to submit it using contacts.createContact(item, options), everything else goes into Contacts fine but I cannot figure out how to set the subscription setting…nothing I write to this field seems to stick - it shows NEVER SUBSCRIBED still. It doesn’t throw an error or anything, it just doesn’t get written to the contact.

Can anyone help point me in the right direction? I can’t see this in the API but it also doesn’t say it can’t be done. Surely I don’t have to go through every Contact in the collection setting these manually?..it’ll take forever! The alternative is to not set them and have the client use Mailchimp I guess…but that seems a little bit odd.

Simon.

I just have something in my memories → that extended fields can only be used, when they were already generated inside contacts.

Would that solve your question? But i am not sure.

Let’s go through the issue…
-To be able to work with CONTACTS → you will need wix-crm-backend.
-The following information is important…

Maybe this post can help you somehow…

Hi there Ninja.

I got to bottom of this last night. The subscription info is SYSTEM only and is not editable via Velo. All the custom fields, which are stored in extendedFields, are readable & writable, as long as they’ve been set-up first in the dashboard, which they were. I looked in wix-crm.v2 also and it hasn’t been changed there either.

This is, of course, patently ridiculous but we are where we are. I’m gong to push my client away from using Wix’s email marketing, which is a shame, as they were going to move away from MailChimp.

It would really be useful if the SYSTEM fields were at least highlighted in the Velo API under wix-crm somewhere…to avoid a repeat of my search for others. The only way I was able to determine the status was to use contacts.getExtendedField to look at the field. Not sure how easy it is to get this kind of things added though.

I’ve filed a feature request for edit rights for this field in both Velo and Email Marketing but I’m obviously not going to hold my breath on that…

Simon.

1 Like

exactly!

This was what was in my memories…

I just have something in my memories → that extended fields can only be used, when they were already generated inside contacts.

If i am honest, i did not take a closer look on your issue, maybe there is a way though, but this for i would have to investigate the whole setup. Workarounds are in most cases possible.

But this looks anyways promissing…