Created
June 11, 2020 17:00
-
-
Save mick-shaw/6154d0724ca19dbea5b872a6932df053 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Birthdateconversion.js | |
| // | |
| // Created by: Mick Shaw | |
| // Contact Information: mshaw@potomacintegration.com | |
| // Subject: Birthdateconversion.js | |
| // | |
| // This birthday converstion script is invoked from Connect | |
| // when a caller enters their birthdate. | |
| // | |
| // This script expects a call attribute called 'DOB' | |
| // The value passed in the DOB attribute is an 8 digit string (XXXXXXXX). | |
| // | |
| // The script will return the value in a date format that can be compared against SalesForce | |
| // Date values in the form of XXXX-XX-XX . | |
| // | |
| var AWS = require("aws-sdk"); | |
| process.env.TZ = "America/New_York"; | |
| exports.handler = function(event,context,callback){ | |
| var DOB = event.Details.ContactData.Attributes.DOB; | |
| DOB = DOB.replace(/(\d{4})(\d{2})(\d{2})/, "$1-$2-$3"); | |
| console.log("Formatted DOB is "+DOB); | |
| callback(null,buildResponse(true,DOB)); | |
| }; | |
| function buildResponse(isSuccess,DOB) { | |
| if (isSuccess){ | |
| return { | |
| DOB: DOB, | |
| lambdaResult:"Success"}; | |
| }else { | |
| console.log("Lambda returned and error"); | |
| return { | |
| lambdaResult:"Error"}; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment