mirror of
https://github.com/fleetdm/fleet
synced 2026-05-23 17:08:53 +00:00
Merge branch 'main' into feat-vpp-apps-18867
This commit is contained in:
commit
76642bdc76
4 changed files with 42 additions and 18 deletions
|
|
@ -71,12 +71,12 @@ module.exports = {
|
|||
`Name: ${firstName + ' ' + lastName}, Email: ${emailAddress}, Message: ${message ? message : 'No message.'}`
|
||||
});
|
||||
|
||||
sails.helpers.salesforce.updateOrCreateContactAndAccountAndCreateLead.with({
|
||||
sails.helpers.salesforce.updateOrCreateContactAndAccount.with({
|
||||
emailAddress: emailAddress,
|
||||
firstName: firstName,
|
||||
lastName: lastName,
|
||||
leadSource: 'Website - Contact forms',
|
||||
leadDescription: `Sent a contact form message: ${message}`,
|
||||
description: `Sent a contact form message: ${message}`,
|
||||
}).exec((err)=>{// Use .exec() to run the salesforce helpers in the background.
|
||||
if(err) {
|
||||
sails.log.warn(`Background task failed: When a user submitted a contact form message, a lead/contact could not be updated in the CRM for this email address: ${emailAddress}.`, err);
|
||||
|
|
|
|||
|
|
@ -74,21 +74,36 @@ module.exports = {
|
|||
throw 'invalidEmailDomain';
|
||||
}
|
||||
|
||||
|
||||
sails.helpers.salesforce.updateOrCreateContactAndAccountAndCreateLead.with({
|
||||
emailAddress: emailAddress,
|
||||
firstName: firstName,
|
||||
lastName: lastName,
|
||||
organization: organization,
|
||||
numberOfHosts: numberOfHosts,
|
||||
primaryBuyingSituation: primaryBuyingSituation === 'eo-security' ? 'Endpoint operations - Security' : primaryBuyingSituation === 'eo-it' ? 'Endpoint operations - IT' : primaryBuyingSituation === 'mdm' ? 'Device management (MDM)' : primaryBuyingSituation === 'vm' ? 'Vulnerability management' : undefined,
|
||||
leadSource: 'Website - Contact forms',
|
||||
leadDescription: `Submitted the "Talk to us" form and was taken to the Calendly page for the "${numberOfHosts > 700 ? 'Talk to us' : 'Let\'s get you set up!'}" event.`,
|
||||
}).exec((err)=>{
|
||||
if(err) {
|
||||
sails.log.warn(`Background task failed: When a user submitted the "Talk to us" form, a lead/contact could not be updated in the CRM for this email address: ${emailAddress}.`, err);
|
||||
}
|
||||
});
|
||||
if(numberOfHosts >= 700){
|
||||
sails.helpers.salesforce.updateOrCreateContactAndAccountAndCreateLead.with({
|
||||
emailAddress: emailAddress,
|
||||
firstName: firstName,
|
||||
lastName: lastName,
|
||||
organization: organization,
|
||||
numberOfHosts: numberOfHosts,
|
||||
primaryBuyingSituation: primaryBuyingSituation === 'eo-security' ? 'Endpoint operations - Security' : primaryBuyingSituation === 'eo-it' ? 'Endpoint operations - IT' : primaryBuyingSituation === 'mdm' ? 'Device management (MDM)' : primaryBuyingSituation === 'vm' ? 'Vulnerability management' : undefined,
|
||||
leadSource: 'Website - Contact forms',
|
||||
leadDescription: `Submitted the "Talk to us" form and was taken to the Calendly page for the "Talk to us" event.`,
|
||||
}).exec((err)=>{
|
||||
if(err) {
|
||||
sails.log.warn(`Background task failed: When a user submitted the "Talk to us" form, a lead/contact could not be updated in the CRM for this email address: ${emailAddress}.`, err);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
sails.helpers.salesforce.updateOrCreateContactAndAccount.with({
|
||||
emailAddress: emailAddress,
|
||||
firstName: firstName,
|
||||
lastName: lastName,
|
||||
organization: organization,
|
||||
primaryBuyingSituation: primaryBuyingSituation === 'eo-security' ? 'Endpoint operations - Security' : primaryBuyingSituation === 'eo-it' ? 'Endpoint operations - IT' : primaryBuyingSituation === 'mdm' ? 'Device management (MDM)' : primaryBuyingSituation === 'vm' ? 'Vulnerability management' : undefined,
|
||||
leadSource: 'Website - Contact forms',
|
||||
description: `Submitted the "Talk to us" form and was taken to the Calendly page for the "Let\'s get you set up!" event.`,
|
||||
}).exec((err)=>{
|
||||
if(err) {
|
||||
sails.log.warn(`Background task failed: When a user submitted the "Talk to us" form, a lead/contact could not be updated in the CRM for this email address: ${emailAddress}.`, err);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -73,6 +73,7 @@ module.exports = {
|
|||
primaryBuyingSituation,
|
||||
psychologicalStage,
|
||||
leadSource,
|
||||
description: leadDescription,
|
||||
});
|
||||
|
||||
await sails.helpers.salesforce.createLead.with({
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ module.exports = {
|
|||
firstName: { type: 'string', required: true },
|
||||
lastName: { type: 'string', required: true },
|
||||
organization: { type: 'string' },
|
||||
description: { type: 'string' },
|
||||
primaryBuyingSituation: { type: 'string' },
|
||||
psychologicalStage: {
|
||||
type: 'string',
|
||||
|
|
@ -51,7 +52,7 @@ module.exports = {
|
|||
},
|
||||
|
||||
|
||||
fn: async function ({emailAddress, linkedinUrl, firstName, lastName, organization, primaryBuyingSituation, psychologicalStage, leadSource}) {
|
||||
fn: async function ({emailAddress, linkedinUrl, firstName, lastName, organization, primaryBuyingSituation, psychologicalStage, leadSource, description}) {
|
||||
// Return undefined if we're not running in a production environment.
|
||||
if(sails.config.environment !== 'production') {
|
||||
sails.log.verbose('Skipping Salesforce integration...');
|
||||
|
|
@ -95,6 +96,9 @@ module.exports = {
|
|||
if(psychologicalStage) {
|
||||
valuesToSet.Stage__c = psychologicalStage;// eslint-disable-line camelcase
|
||||
}
|
||||
if(description) {
|
||||
valuesToSet.Description = description;
|
||||
}
|
||||
|
||||
let existingContactRecord;
|
||||
// Search for an existing Contact record using the provided email address or linkedIn profile URL.
|
||||
|
|
@ -111,6 +115,10 @@ module.exports = {
|
|||
}
|
||||
|
||||
if(existingContactRecord) {
|
||||
// If a description was provided and the contact has a description, append the new description to it.
|
||||
if(description && existingContactRecord.Description) {
|
||||
valuesToSet.Description = existingContactRecord.Description + '\n' + description;
|
||||
}
|
||||
// console.log(`Exisitng contact found! ${existingContactRecord.Id}`);
|
||||
// If we found an existing contact, we'll update it with the information provided.
|
||||
salesforceContactId = existingContactRecord.Id;
|
||||
|
|
|
|||
Loading…
Reference in a new issue