Cegid Retail Y2 fields mapping
Customer and loyalty data synchronization
Creation and update of customer account and loyalty cards in Y2 via the registration forms.
Field mapping: Here is the list of fields that are available by default in the connector:
Wallet Crew fields Y2(WebService) fields
--------------------------------------------------------------------------
email EmailData.Email
consents_email EmailData.EmailingAccepted
phoneNumber PhoneData.CellularPhoneNumber
isProspect IsProspect
firstName FirstName
lastName LastName
sex Sex
title TitleId
advisor SalesPersonId
storeId UsualStoreId
birthDate BirthDateData
address AddressData.AddressLine1
streetNumber AddressData.AddressLine2
postcode / zipCode AddressData.ZipCode
city AddressData.City
country AddressData.CountryId
nationality NationalityId
consents_email OptinEmail(true = BrandOnly, false = DoNotUse)
consents_post OptinPostal(true = BrandOnly, false = DoNotUse)
consents_sms OptinMobile(true = BrandOnly, false = DoNotUse)
consents_emailReceipt EmailData.SendReceiptByMail
If you want additional fields, contacting your Wallet Crew administrator. The labels and values of the multiple-choice fields have to be filled in and located in The Wallet Crew BackOffice. The same applies to consents and other legal texts.
Mapping personalization
It is possible to customize mapping with a custom javascript script. The script requires 2 methods : MapFromY2 and MapToY2. You will find below the minimal script to use the custom mapping
// file server/scripts/y2.mapping.js
/**
* Method used to convert information from the wallet crew data model to Y2 data modal.
* This method will be invoked each time a customer is created or updated to Y2
*
* This method should be implemented if you want to send specific data to Y2
*
* @param account dictionary of data coming from the wallet crew
* @param data Y2 customer data modal as defined in the CustomerWcfService
*/
const mapToY2 = function(account, data) {
}
/**
* Method used to convert information from Y2 to neostore.
* This method will be invoked each time a customer is retrieved and displayed within the wallet crew :
* when editing an existing customer through an enrolment form or when displaying information on a pass
*
* @param data Y2 customer data modal as defined in the CustomerWcfService
* @param account dictionary of data to set within the wallet crew
*/
const mapFromY2 = function(data, account) {
}
export default function(context) {
context.register('extensions.cegid.y2.mapper', {
MapToY2: mapToY2,
MapFromY2: mapFromY2
});
};
Y2 data model is defined like this :
Recipes
Y2 Free texts - YTC_TEXTELIBRE
Within Cegid it is possible to define up to 3 free text, they are stored in columns YTC_TEXTELIBRE1
, YTC_TEXTELIBRE2
, YTC_TEXTELIBRE3
. Values are accessible using UserDefinedTexts
property.
Mapping could be done like this :
// correct Id value should be replace - 2 times in mapToY2 and 1 time in mapFromY2
// Id : 0 => YTC_TEXTELIBRE1
// Id : 1 => YTC_TEXTELIBRE2
// Id : 2 => YTC_TEXTELIBRE3
const mapToY2 = function(account, data) {
// other field mapping
const comment = account["comment"];
if(comment)
{
data.UserDefinedTexts = [...(data.UserDefinedTexts || []).filter(udt => udt?.Id != 0), { Id: 0, Value: comment}];
}
}
const mapFromY2 = function(data, account) {
// other field mapping
account["comment"] = (data.UserDefinedTexts || []).find(udt => udt?.Id == 0)?.Value;
}
Y2 Free table - YTC_TABLELIBRETIERS
Within Cegid it is possible to define up to 10 values in free table (Table libre in french), they are stored in columns YTC_TABLELIBRETIERS1
, YTC_TABLELIBRETIERS2
, YTC_TABLELIBRETIERS3
, YTC_TABLELIBRETIERS4
, YTC_TABLELIBRETIERS5
, YTC_TABLELIBRETIERS6
, YTC_TABLELIBRETIERS7
, YTC_TABLELIBRETIERS8
, YTC_TABLELIBRETIERS9
, YTC_TABLELIBRETIERSA
. Values are accessible using UserDefinedData
property.
Be careful Cegid WebServices as a gap of 1 between name on the database and name on the web service.
Mapping could be done like this :
// Y2 as a gap of 1. UserDefinedTable0Value is YTC_TABLELIBRETIERS1, etc.
/*
* UserDefinedTable0Value => YTC_TABLELIBRETIERS1
* UserDefinedTable1Value => YTC_TABLELIBRETIERS2
* UserDefinedTable2Value => YTC_TABLELIBRETIERS3
* UserDefinedTable3Value => YTC_TABLELIBRETIERS4
* UserDefinedTable4Value => YTC_TABLELIBRETIERS5
* UserDefinedTable5Value => YTC_TABLELIBRETIERS6
* UserDefinedTable6Value => YTC_TABLELIBRETIERS7
* UserDefinedTable7Value => YTC_TABLELIBRETIERS8
* UserDefinedTable8Value => YTC_TABLELIBRETIERS9
* UserDefinedTable9Value => YTC_TABLELIBRETIERSA
*/
const mapToY2 = function(account, data) {
// other field mapping
const preference = account["preference"];
if(preference)
{
data.UserDefinedData = {
...(data.UserDefinedData || {}),
UserDefinedTable1Value : preference
}
}
}
const mapFromY2 = function(data, account) {
// other field mapping
account["preference"] = data.UserDefinedData?.UserDefinedTable1Value;
}