Website: Set leadSource on new contact records (#20285)

Closes: #20284

Changes:
- Updated the `update-or-create-contact-and-account` helper to set a
lead source on new contact records
- Updated `update-or-create-contact-and-account-and-create-lead` to to
pass in a lead source to the `update-or-create-contact-and-account`
helper
- Updated save-questionnaire-progress to set a lead source on newly
created contact records
This commit is contained in:
Eric 2024-07-09 17:04:12 -05:00 committed by GitHub
parent 40bc8e8226
commit 670a8ef2a0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 14 additions and 2 deletions

View file

@ -218,6 +218,7 @@ module.exports = {
primaryBuyingSituation: primaryBuyingSituation === 'eo-security' ? 'Endpoint operations - Security' : primaryBuyingSituation === 'eo-it' ? 'Endpoint operations - IT' : primaryBuyingSituation === 'mdm' ? 'Device management (MDM)' : primaryBuyingSituation === 'vm' ? 'Vulnerability management' : undefined,
organization: this.req.me.organization,
psychologicalStage,
leadSource: 'Website - Sign up',
}).exec((err)=>{
if(err){
sails.log.warn(`Background task failed: When a user (email: ${this.req.me.emailAddress} submitted a step of the get started questionnaire, a Contact and Account record could not be created/updated in the CRM.`, err);

View file

@ -72,6 +72,7 @@ module.exports = {
linkedinUrl,
primaryBuyingSituation,
psychologicalStage,
leadSource,
});
await sails.helpers.salesforce.createLead.with({

View file

@ -29,6 +29,13 @@ module.exports = {
'6 - Has team buy-in'
]
},
leadSource: {
type: 'string',
isIn: [
'Website - Contact forms',
'Website - Sign up',
],
},
},
@ -44,7 +51,7 @@ module.exports = {
},
fn: async function ({emailAddress, linkedinUrl, firstName, lastName, organization, primaryBuyingSituation, psychologicalStage}) {
fn: async function ({emailAddress, linkedinUrl, firstName, lastName, organization, primaryBuyingSituation, psychologicalStage, leadSource}) {
// Return undefined if we're not running in a production environment.
if(sails.config.environment !== 'production') {
sails.log.verbose('Skipping Salesforce integration...');
@ -89,7 +96,6 @@ module.exports = {
valuesToSet.Stage__c = psychologicalStage;// eslint-disable-line camelcase
}
let existingContactRecord;
// Search for an existing Contact record using the provided email address or linkedIn profile URL.
if(emailAddress) {
@ -184,6 +190,10 @@ module.exports = {
// console.log('New account created!', salesforceAccountId);
}//fi
// Only add leadSource to valuesToSet if we're creating a new contact record.
if(leadSource) {
valuesToSet.LeadSource = leadSource;
}
// console.log(`creating new Contact record.`)
// Create a new Contact record for this person.
let newContactRecord = await salesforceConnection.sobject('Contact')