From c8149fa5e2cb3b7952511878b3d7e454bd81dc7e Mon Sep 17 00:00:00 2001 From: Eric Date: Thu, 12 Sep 2024 17:17:52 -0500 Subject: [PATCH] Website: update contacts when users subscribe to Fleet Premium (#22004) Closes: #21921 Changes: - Updated `save-biling-info-and-subscribe` to update CRM records in the background when users purchase a self-service license. --- .../customers/save-billing-info-and-subscribe.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/website/api/controllers/customers/save-billing-info-and-subscribe.js b/website/api/controllers/customers/save-billing-info-and-subscribe.js index 31f6e7df7e..6369ebb06c 100644 --- a/website/api/controllers/customers/save-billing-info-and-subscribe.js +++ b/website/api/controllers/customers/save-billing-info-and-subscribe.js @@ -162,6 +162,22 @@ module.exports = { } }); + let todayOn = new Date(); + let isoTimestampForDescription = todayOn.toISOString(); + sails.helpers.salesforce.updateOrCreateContactAndAccount.with({ + emailAddress: this.req.me.emailAddress, + firstName: this.req.me.firstName, + lastName: this.req.me.lastName, + organization: this.req.me.organization, + description: `Purchased a self-service Fleet Premium license on ${isoTimestampForDescription.split('T')[0]} for ${quoteRecord.numberOfHosts} host${quoteRecord.numberOfHosts > 1 ? 's' : ''}.` + }).exec((err)=>{ + if(err){ + sails.log.warn(`Background task failed: When a user (email: ${this.req.me.emailAddress} purchased a self-service Fleet premium subscription, a Contact and Account record could not be created/updated in the CRM.`, err); + } + return; + }); + + }