Last active
October 3, 2016 20:32
-
-
Save AjayKumar01/8216afb253c99c2829094d69a8d63c02 to your computer and use it in GitHub Desktop.
Email Validation through api(Note : this will work in both record.js and create-actions.js as well)
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
var emailAddress="test@test.com"; | |
var self = this, | |
data = { | |
results: [], | |
}, | |
options = {}, | |
callbacks = {}, | |
url; | |
// add the search term to the URL params | |
options.q = emailAddress; | |
// the first 10 results should be enough | |
//we can use 2 or 5 any number which is very less. | |
options.max_num = 10; | |
// build the URL for fetching recipients that match the search term | |
url = app.api.buildURL('Mail', 'recipients/find', null, options); | |
// create the callbacks | |
callbacks.success = function(result) { | |
var email_count=result.records.length; //Assigning the count of returned email addresses. | |
if(email_count>0){ | |
console.log("This is duplicate email address"); | |
} | |
else{ | |
console.log("This is new email address"); | |
} | |
}; | |
callbacks.error = function() { | |
console.log("api error"); | |
}; | |
app.api.call('read', url, null, callbacks); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment