Supplementing user member collection input from WixData and WixCRM collections

I have been going round in circles trying to figure this out today.

I have a the members area set up. It works fine.

Through a custom sign-up form and some custom fields, I get a member registered in the PrivateMembers Collection with the custom fields stored in Contacts. One of those custom fields is OrgName…the name of their organisation. That organisation name is actually is selected from another collection (Called memberOrgs) that has a bunch of info about each organisation, including a logo image.

What I am trying to do is have members write to another, unrelated, collection where they can submit information for use on my site. There are 4 things I want need to capture from then and 3 things I want to complete without them having to input anything – 1. their name, 2. organisation name & 3. logo. The basic write operation works fine but I don’t want them to have to re-enter those 3 things I mentioned - as I want the overhead on the user to be minimal.

I can capture their name during submission from the PrivateMembers Collection through querying that collection with current user…so I have 1 of the three issues taken care of. I cannot subsequently figure out how to grab the organisation name (from Contacts) and then the organisation logo (from the memberOrgs collection).

Can someone give me a push in the right direction?..I have been Googling for an example similar to this but have not been able to find one. I feel like it should be possible but access to Contacts is limited…although I think there may be a way to access it through the backend CRM velo tools. If I need to use a JSW routine in the backend, I feel like this might be doable…but I am not sure how.

As you already assumed, you will need to use the backdoor (backend) to get all contact-information…

  1. To get all information about one of your contacts…
    https://www.wix.com/velo/reference/wix-crm-backend/getcontactbyid

  2. To get information out of a separate DB (collection), you can use a simple wix-data-query…
    https://www.wix.com/velo/reference/wix-data/query

You make it all sound so easy @russian-dima …I’ll take a look at these links tomorrow. Thanks for the pointers…I am getting better at this but it’s a sloooow process.

@VeloNinja Try as I might, I can’t figure this out…possibly because my javascript skills are not up to scratch…but I spent the last 48 hours trying to get educated.

However, ultimately you seem to need a contactID to interrogate the Contacts info in the crm-back-end and I can only get the userID, which is different. How do I make getContact() work with the contactID?

I think I could write js code in the back end if I knew how to bridge this gap…do you know I do that?

Contact-ID = User-ID

You can use the user-ID to interrogate to contacts info.

For example —> How to get Contacts-Info ?

Backend-code:

import { contacts } from 'wix-crm-backend';

export function myGetContactFunction() {
  const contactId = "bc0ae72b-3285-485b-b0ad-c32c769a4daf"; // <----user-ID
  const options = {suppressAuth: false};

  return contacts.getContact(contactId, options)
    .then((contact) => {return contact;});
    .catch((error) => {console.error(error);});
}