A better flow would be to click on a link in Zoho CRM and automatically load up a proposal in NiftyQuoter with the client's details pre-loaded.
I've written some code to allow that. Just upload the below HTML file to your server and set up Zoho CRM links accordingly. Here's a screencast showing it in action.
If you need any help implementing this, drop me a line at info@nuanced.it
Make sure you change the API details at the start of the code.
<html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
</head>
<body>
Adding proposal to NiftyQuoter...You'll be redirected to the new proposal in 15 seconds or less
<script type="text/javascript">
//CHANGE THIS
//needed for API
var nifty_API_key = "CHANGE";
var nifty_account_email = "CHANGE";
/**
* Reads URL parameters into array for easy access
* Courtesy Quentin: http://stackoverflow.com/a/979995
*/
var QueryString = function () {
// This function is anonymous, is executed immediately and
// the return value is assigned to QueryString!
var query_string = {};
var query = window.location.search.substring(1);
var vars = query.split("&");
for (var i=0;i<vars.length;i++) {
var pair = vars[i].split("=");
// If first entry with this name
if (typeof query_string[pair[0]] === "undefined") {
query_string[pair[0]] = decodeURIComponent(pair[1]);
// If second entry with this name
} else if (typeof query_string[pair[0]] === "string") {
var arr = [ query_string[pair[0]], pair[1] ];
query_string[pair[0]] = arr;
// If third or later entry with this name
} else {
query_string[pair[0]].push(decodeURIComponent(pair[1]));
}
}
return query_string;
} ();
//get URL parameters
//example URL: http://www.nuancedi.wwwss10.a2hosted.com/client_jobs/mesh_direct/add_niftyquoter_proposal.html?client_first_name=testing%204&client_last_name=testing%204&client_company_name=Testing%20company&client_email=test%40testing.it
console.log(QueryString);
var client_first_name = QueryString.client_first_name;
var client_last_name = QueryString.client_last_name;
var client_company_name = QueryString.client_company_name;
var client_email = QueryString.client_email;
if (client_first_name == "" || client_first_name === "undefined")
alert("Please supply the client's first name" + client_first_name);
else if (client_last_name == "" || client_last_name === "undefined")
alert("Please supply the client's last name");
else if (client_company_name == "" || client_company_name === "undefined" )
alert("Please make sure you fill out the Company name in Zoho");
else if (client_email == "" || client_email === "undefined")
alert("Please make sure you fill out the client's email address in Zoho");
else{
add_proposal();
}
/**
* Adds a new proposal to Nifty Quoter with the client's name pre-filled in the proposal name. E.g. Proposal for <client name>
**/
function add_proposal(){
var proposal_id = 0;
$.ajax({
url: 'https://api.niftyquoter.com/api/v1/proposals?key=' + nifty_API_key + '&email=' + nifty_account_email,
type: 'POST',
data: {proposal: {name: 'Proposal for ' + client_company_name}},
success: function(result) {
console.log("add proposal");
console.log(result);
proposal_id = result.proposal.id;
add_client(proposal_id);
},
error: function(result) {
alert('error');
}
});
}
/**
* Adds a new client to Nifty Quoter with the details from Zoho (supplied in URL parameters)
**/
function add_client(proposal_id){
var added_client_id = 0;
//add client
$.ajax({
url: 'https://api.niftyquoter.com/api/v1/clients?key=' + nifty_API_key + '&email=' + nifty_account_email,
type: 'POST',
data: {client: {first_name: client_first_name, last_name: client_last_name, email: client_email, company_name: client_company_name}},
success: function(result) {
added_client_id = result.client.id;
add_client_to_proposal(added_client_id, proposal_id);
},
error: function(result) {
alert('error');
}
});
}
/**
* Adds the client to the proposal
* @param added_client_id The ID of the client in Nifty that we added via add_client()
* @param proposal_id The ID of the proposal in Nifty that we added via add_proposal()
**/
function add_client_to_proposal(added_client_id, proposal_id){
var proposal_url = 'https://api.niftyquoter.com/api/v1/proposals/' + proposal_id + '/contacts?key=' + nifty_API_key + '&email=' + nifty_account_email;
var payload = {contact: {client_id: added_client_id}};
$.ajax({
url: proposal_url,
type: 'POST',
data: payload,
success: function(result) {
console.log(result);
window.location.href = "http://mesh-direct.niftyquoter.com/proposals/" + proposal_id + "/edit";
},
error: function(result) {
console.log(result);
console.log(payload);
}
});
}
</script>
</body>
</html>