-
-
Save johndowns/414220c68b810781b5de5c7a0d1c3d21 to your computer and use it in GitHub Desktop.
This file contains 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
function getCustomerId(document) { | |
// try to get the customer ID from the new format first | |
if (document.customer != undefined && document.customer.id != undefined) { | |
return document.customer.id; | |
} | |
// if that didn't work, try to get the customer ID from the old format | |
if (document.customerId != undefined) { | |
return document.customerId; | |
} | |
// if neither are present, that is an error | |
throw new Error("Document with id " + document.id + " does not contain customer ID in recognised format."); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment