Lead is always captured to the default mapping: Get in touch with AllOne Health. Architect requested to map the lead to a specific mapped form depending on the selected Customer Type.
I added a custom code to add specific class depending on the selected Customer Type.
This class will be used to decide which form mapping to use for the lead.
mcfx(function(t) {
t.configure("onFormCapture", function(form) {
console.log('MCFX onFormCapture');
console.log(form);
var customerTypeClasses = {
'Prospective Customer': 'rcfx-custom-class-prospective-customer',
'Existing Customer': 'rcfx-custom-class-existing-customer',
'Reseller': 'rcfx-custom-class-reseller',
'Broker': 'rcfx-custom-class-broker'
};
var allMappedClasses = [
'rcfx-custom-class-prospective-customer',
'rcfx-custom-class-existing-customer',
'rcfx-custom-class-reseller',
'rcfx-custom-class-broker',
'rcfx-custom-class-default'
];
var input = form.querySelector('input[name="0-1/customer_type"]');
var classToAdd = 'rcfx-custom-class-default';
if (input && customerTypeClasses[input.value]) {
classToAdd = customerTypeClasses[input.value];
}
for (var i = 0; i < allMappedClasses.length; i++) { form.className = form.className.replace(new RegExp('(^|\\s)' + allMappedClasses[i] + '(\\s|$)', 'g'), ' ').replace(/\s+/g, ' ').replace(/^\s|\s$/g, ''); } form.className = (form.className ? form.className + ' ' : '') + classToAdd; }); });
Lead is captured and mapped to correct form mapping depending on the selected Customer Type.
Task: Link
Code: Screenshot