Skip to content

Instantly share code, notes, and snippets.

@AjayKumar01
Last active October 3, 2016 20:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AjayKumar01/8216afb253c99c2829094d69a8d63c02 to your computer and use it in GitHub Desktop.
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)
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