From 77a321a8215660d9466398522ae66100e5692fde Mon Sep 17 00:00:00 2001 From: georgeotj Date: Fri, 8 Mar 2019 13:57:34 -0600 Subject: [PATCH 01/59] Add files via upload These scripts will allow user's to take Mockaroo schemas to automatically generate mock data into the CRM through an API --- .../Zoho_CRM_API/2.0/insertTasksMockaroo.py | 47 +++++++++++++++++ .../2.0/upsertAccountsMockaroo.py | 46 +++++++++++++++++ .../2.0/upsertContactsMockaroo.py | 50 +++++++++++++++++++ .../Zoho_CRM_API/2.0/upsertDealsMockaroo.py | 46 +++++++++++++++++ .../Zoho_CRM_API/2.0/upsertLeadsMockaroo.py | 44 ++++++++++++++++ 5 files changed, 233 insertions(+) create mode 100644 Python/Zoho_CRM_API/2.0/insertTasksMockaroo.py create mode 100644 Python/Zoho_CRM_API/2.0/upsertAccountsMockaroo.py create mode 100644 Python/Zoho_CRM_API/2.0/upsertContactsMockaroo.py create mode 100644 Python/Zoho_CRM_API/2.0/upsertDealsMockaroo.py create mode 100644 Python/Zoho_CRM_API/2.0/upsertLeadsMockaroo.py diff --git a/Python/Zoho_CRM_API/2.0/insertTasksMockaroo.py b/Python/Zoho_CRM_API/2.0/insertTasksMockaroo.py new file mode 100644 index 0000000..787c7c6 --- /dev/null +++ b/Python/Zoho_CRM_API/2.0/insertTasksMockaroo.py @@ -0,0 +1,47 @@ +__author__ = 'JorgeH' + +import requests +import json +import urllib.request +from Authentication import tokens + +# Define URL +# The key that appears on the Mockaroo URL at the end must match the API key of the user # noqa +url = 'https://www.zohoapis.com/crm/v2/tasks' +urlMockaroo = 'https://my.api.mockaroo.com/zcrmLCADT.json?key=58fd1ee0' + +# Reads the Mockaroo data and loads it into the file +data = urllib.request.urlopen(urlMockaroo).read() +mockData = json.loads(data) + +# Get Token and Headers +token = tokens.getAccess() +headers = {'Authorization': token} + +# Build Body +# NOTE: The mockData[x] must be iterated through. Currently working on this. +body = { + "data": [ + mockData[0], mockData[1], mockData[2], mockData[3], mockData[4] + ] +} + +# Print Input Data +print('') +print('---- Request ----') +print('URL:', url) +print('Head:', headers) + +# Call API +response = requests.post(url, headers=headers, json=body) + +# Print Output Data +if (response.status_code) == 200: + jsonData = json.loads(response.text) + data = jsonData['data'] + print('') + print('-- Response --') + print(json.dumps(data, sort_keys=True, indent=4)) +else: + print(response.status_code) + print(response.text) diff --git a/Python/Zoho_CRM_API/2.0/upsertAccountsMockaroo.py b/Python/Zoho_CRM_API/2.0/upsertAccountsMockaroo.py new file mode 100644 index 0000000..02eceb3 --- /dev/null +++ b/Python/Zoho_CRM_API/2.0/upsertAccountsMockaroo.py @@ -0,0 +1,46 @@ +__author__ = 'JorgeH' + +import requests +import json +import urllib.request +from Authentication import tokens + +# Define URL +url = 'https://www.zohoapis.com/crm/v2/Accounts/upsert' +urlMockaroo = 'https://my.api.mockaroo.com/zcrmLCADT.json?key=58fd1ee0' + +# Reads the Mockaroo data and loads it into the file +data = urllib.request.urlopen(urlMockaroo).read() +mockData = json.loads(data) + +# Get Token and Headers +token = tokens.getAccess() +headers = {'Authorization': token} + +# Build Body +# NOTE: The mockData[x] must be iterated through. Currently working on this. +body = { + "data": [ + mockData[0] + ] +} + +# Print Input Data +print('') +print('---- Request ----') +print('URL:', url) +print('Head:', headers) + +# Call API +response = requests.post(url, headers=headers, json=body) + +# Print Output Data +if (response.status_code) == 200: + jsonData = json.loads(response.text) + data = jsonData['data'] + print('') + print('-- Response --') + print(json.dumps(data, sort_keys=True, indent=4)) +else: + print(response.status_code) + print(response.text) diff --git a/Python/Zoho_CRM_API/2.0/upsertContactsMockaroo.py b/Python/Zoho_CRM_API/2.0/upsertContactsMockaroo.py new file mode 100644 index 0000000..cfd4c81 --- /dev/null +++ b/Python/Zoho_CRM_API/2.0/upsertContactsMockaroo.py @@ -0,0 +1,50 @@ +__author__ = 'JorgeH' + +import requests +import json +import urllib.request +from Authentication import tokens + +# Define URL +url = 'https://www.zohoapis.com/crm/v2/Contacts/upsert' +urlMockaroo = 'https://my.api.mockaroo.com/zcrmLCADT.json?key=58fd1ee0' + +# Reads the Mockaroo data and loads it into the file +data = urllib.request.urlopen(urlMockaroo).read() +mockData = json.loads(data) + +# Get Token and Headers +token = tokens.getAccess() +headers = {'Authorization': token} + +# Build Body +# NOTE: The mockData[x] must be iterated through. Currently working on this. +body = { + # "data": [ + # mockData[0] + # ] + + data = [] + for dict in mockData + data.append(dict) +} + +# Print Input Data +print('') +print('---- Request ----') +print('URL:', url) +print('Head:', headers) + +# Call API +response = requests.post(url, headers=headers, json=body) + +# Print Output Data +if (response.status_code) == 200: + jsonData = json.loads(response.text) + data = jsonData['data'] + print('') + print('-- Response --') + print(json.dumps(data, sort_keys=True, indent=4)) +else: + print(response.status_code) + print(response.text) diff --git a/Python/Zoho_CRM_API/2.0/upsertDealsMockaroo.py b/Python/Zoho_CRM_API/2.0/upsertDealsMockaroo.py new file mode 100644 index 0000000..001a70f --- /dev/null +++ b/Python/Zoho_CRM_API/2.0/upsertDealsMockaroo.py @@ -0,0 +1,46 @@ +__author__ = 'JorgeH' + +import requests +import json +import urllib.request +from Authentication import tokens + +# Define URL +url = 'https://www.zohoapis.com/crm/v2/Deals/upsert' +urlMockaroo = 'https://my.api.mockaroo.com/zcrmLCADT.json?key=58fd1ee0' + +# Reads the Mockaroo data and loads it into the file +data = urllib.request.urlopen(urlMockaroo).read() +mockData = json.loads(data) + +# Get Token and Headers +token = tokens.getAccess() +headers = {'Authorization': token} + +# Build Body +# NOTE: The mockData[x] must be iterated through. Currently working on this. +body = { + "data": [ + mockData[0], mockData[1], mockData[2], mockData[3], mockData[4] + ] +} + +# Print Input Data +print('') +print('---- Request ----') +print('URL:', url) +print('Head:', headers) + +# Call API +response = requests.post(url, headers=headers, json=body) + +# Print Output Data +if (response.status_code) == 200: + jsonData = json.loads(response.text) + data = jsonData['data'] + print('') + print('-- Response --') + print(json.dumps(data, sort_keys=True, indent=4)) +else: + print(response.status_code) + print(response.text) diff --git a/Python/Zoho_CRM_API/2.0/upsertLeadsMockaroo.py b/Python/Zoho_CRM_API/2.0/upsertLeadsMockaroo.py new file mode 100644 index 0000000..5eeeb4c --- /dev/null +++ b/Python/Zoho_CRM_API/2.0/upsertLeadsMockaroo.py @@ -0,0 +1,44 @@ +__author__ = 'JorgeH' + +import requests +import json +import urllib.request +from Authentication import tokens + +# Define URL +url = 'https://www.zohoapis.com/crm/v2/Leads/upsert' +urlMockaroo = 'https://my.api.mockaroo.com/zcrmLCADT.json?key=58fd1ee0' + +# Reads the Mockaroo data and loads it into the file +data = urllib.request.urlopen(urlMockaroo).read() +mockData = json.loads(data) + +# Get Token and Headers +token = tokens.getAccess() +headers = {'Authorization': token} + +# Build Body +# NOTE: The mockData[x] must be iterated through. Currently working on this. +body = { + "data": [ + mockData[0], mockData[1], mockData[2] + ] +} + +# Print Input Data +print(' \n ---- Request ----') +print('URL:', url) +print('Head:', headers) + +# Call API +response = requests.post(url, headers=headers, json=body) + +# Print Output Data +if (response.status_code) == 200: + jsonData = json.loads(response.text) + data = jsonData['data'] + print(' \n ---- Response ----') + print(json.dumps(data, sort_keys=True, indent=4)) +else: + print(response.status_code) + print(response.text) From 5dcf9f0eb59c8c85b1305137e8486e64f5273244 Mon Sep 17 00:00:00 2001 From: georgeotj Date: Fri, 8 Mar 2019 14:01:48 -0600 Subject: [PATCH 02/59] Update insertTasksMockaroo.py --- Python/Zoho_CRM_API/2.0/insertTasksMockaroo.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Python/Zoho_CRM_API/2.0/insertTasksMockaroo.py b/Python/Zoho_CRM_API/2.0/insertTasksMockaroo.py index 787c7c6..8007719 100644 --- a/Python/Zoho_CRM_API/2.0/insertTasksMockaroo.py +++ b/Python/Zoho_CRM_API/2.0/insertTasksMockaroo.py @@ -8,7 +8,9 @@ # Define URL # The key that appears on the Mockaroo URL at the end must match the API key of the user # noqa url = 'https://www.zohoapis.com/crm/v2/tasks' -urlMockaroo = 'https://my.api.mockaroo.com/zcrmLCADT.json?key=58fd1ee0' + +# NOTE: User must add the URL of the API they created in Mockaroo +urlMockaroo = '' # Reads the Mockaroo data and loads it into the file data = urllib.request.urlopen(urlMockaroo).read() From 079f37e19a307e1e5d33969396f955de474fb235 Mon Sep 17 00:00:00 2001 From: georgeotj Date: Fri, 8 Mar 2019 14:02:42 -0600 Subject: [PATCH 03/59] Update upsertAccountsMockaroo.py --- Python/Zoho_CRM_API/2.0/upsertAccountsMockaroo.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Python/Zoho_CRM_API/2.0/upsertAccountsMockaroo.py b/Python/Zoho_CRM_API/2.0/upsertAccountsMockaroo.py index 02eceb3..3239017 100644 --- a/Python/Zoho_CRM_API/2.0/upsertAccountsMockaroo.py +++ b/Python/Zoho_CRM_API/2.0/upsertAccountsMockaroo.py @@ -7,7 +7,9 @@ # Define URL url = 'https://www.zohoapis.com/crm/v2/Accounts/upsert' -urlMockaroo = 'https://my.api.mockaroo.com/zcrmLCADT.json?key=58fd1ee0' + +# NOTE: User must add the URL of the API they created in Mockaroo +urlMockaroo = '' # Reads the Mockaroo data and loads it into the file data = urllib.request.urlopen(urlMockaroo).read() From ef2f1a9dfd7a51b3b08dcbdbe6a8cf65ff048f20 Mon Sep 17 00:00:00 2001 From: georgeotj Date: Fri, 8 Mar 2019 14:03:11 -0600 Subject: [PATCH 04/59] Update upsertContactsMockaroo.py --- Python/Zoho_CRM_API/2.0/upsertContactsMockaroo.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Python/Zoho_CRM_API/2.0/upsertContactsMockaroo.py b/Python/Zoho_CRM_API/2.0/upsertContactsMockaroo.py index cfd4c81..9a3e3eb 100644 --- a/Python/Zoho_CRM_API/2.0/upsertContactsMockaroo.py +++ b/Python/Zoho_CRM_API/2.0/upsertContactsMockaroo.py @@ -7,7 +7,9 @@ # Define URL url = 'https://www.zohoapis.com/crm/v2/Contacts/upsert' -urlMockaroo = 'https://my.api.mockaroo.com/zcrmLCADT.json?key=58fd1ee0' + +# NOTE: User must add the URL of the API they created in Mockaroo +urlMockaroo = '' # Reads the Mockaroo data and loads it into the file data = urllib.request.urlopen(urlMockaroo).read() From e45b3fe5fbe0c5ef91218c66837ad8168667d33c Mon Sep 17 00:00:00 2001 From: georgeotj Date: Fri, 8 Mar 2019 14:03:55 -0600 Subject: [PATCH 05/59] Update upsertDealsMockaroo.py --- Python/Zoho_CRM_API/2.0/upsertDealsMockaroo.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Python/Zoho_CRM_API/2.0/upsertDealsMockaroo.py b/Python/Zoho_CRM_API/2.0/upsertDealsMockaroo.py index 001a70f..1767232 100644 --- a/Python/Zoho_CRM_API/2.0/upsertDealsMockaroo.py +++ b/Python/Zoho_CRM_API/2.0/upsertDealsMockaroo.py @@ -7,7 +7,9 @@ # Define URL url = 'https://www.zohoapis.com/crm/v2/Deals/upsert' -urlMockaroo = 'https://my.api.mockaroo.com/zcrmLCADT.json?key=58fd1ee0' + +# NOTE: User must add the URL of the API they created in Mockaroo +urlMockaroo = '' # Reads the Mockaroo data and loads it into the file data = urllib.request.urlopen(urlMockaroo).read() From fb9a993d3a8f5a38ec5fb66e5d963add52f39487 Mon Sep 17 00:00:00 2001 From: georgeotj Date: Fri, 8 Mar 2019 14:04:22 -0600 Subject: [PATCH 06/59] Update upsertLeadsMockaroo.py --- Python/Zoho_CRM_API/2.0/upsertLeadsMockaroo.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Python/Zoho_CRM_API/2.0/upsertLeadsMockaroo.py b/Python/Zoho_CRM_API/2.0/upsertLeadsMockaroo.py index 5eeeb4c..427138d 100644 --- a/Python/Zoho_CRM_API/2.0/upsertLeadsMockaroo.py +++ b/Python/Zoho_CRM_API/2.0/upsertLeadsMockaroo.py @@ -7,7 +7,9 @@ # Define URL url = 'https://www.zohoapis.com/crm/v2/Leads/upsert' -urlMockaroo = 'https://my.api.mockaroo.com/zcrmLCADT.json?key=58fd1ee0' + +# NOTE: User must add the URL of the API they created in Mockaroo +urlMockaroo = '' # Reads the Mockaroo data and loads it into the file data = urllib.request.urlopen(urlMockaroo).read() From 69ca5130ea857982d57e2f8a0f77f5df8503f55e Mon Sep 17 00:00:00 2001 From: georgeotj Date: Fri, 8 Mar 2019 14:27:51 -0600 Subject: [PATCH 07/59] Update upsertContactsMockaroo.py --- Python/Zoho_CRM_API/2.0/upsertContactsMockaroo.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/Python/Zoho_CRM_API/2.0/upsertContactsMockaroo.py b/Python/Zoho_CRM_API/2.0/upsertContactsMockaroo.py index 9a3e3eb..ee0fda9 100644 --- a/Python/Zoho_CRM_API/2.0/upsertContactsMockaroo.py +++ b/Python/Zoho_CRM_API/2.0/upsertContactsMockaroo.py @@ -22,13 +22,9 @@ # Build Body # NOTE: The mockData[x] must be iterated through. Currently working on this. body = { - # "data": [ - # mockData[0] - # ] - - data = [] - for dict in mockData - data.append(dict) + "data": [ + mockData[0] + ] } # Print Input Data From 62334f819b104517c8b67fbd815ad55b67aa3b0c Mon Sep 17 00:00:00 2001 From: georgeotj Date: Tue, 12 Mar 2019 10:56:47 -0500 Subject: [PATCH 08/59] Update credentials.py-example --- Python/Zoho_CRM_API/2.0/Authentication/credentials.py-example | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Python/Zoho_CRM_API/2.0/Authentication/credentials.py-example b/Python/Zoho_CRM_API/2.0/Authentication/credentials.py-example index 6b56143..8f09028 100644 --- a/Python/Zoho_CRM_API/2.0/Authentication/credentials.py-example +++ b/Python/Zoho_CRM_API/2.0/Authentication/credentials.py-example @@ -1,7 +1,5 @@ -__author__ = 'MinterS' - # User Credentials from Zoho CRM redirect_uri = 'http://www.mysite.com/success.php' client_id = '####.####################' client_secret = '#############################' -access_type = 'offline' \ No newline at end of file +access_type = 'offline' From f7d132199b3d2f468fa92f7593dba9526d020b83 Mon Sep 17 00:00:00 2001 From: georgeotj Date: Wed, 20 Mar 2019 11:23:56 -0500 Subject: [PATCH 09/59] Create Total_Cost_of_Tradeshow.ds --- .../Custom Buttons/Total_Cost_of_Tradeshow.ds | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 Deluge Functions/Custom Buttons/Total_Cost_of_Tradeshow.ds diff --git a/Deluge Functions/Custom Buttons/Total_Cost_of_Tradeshow.ds b/Deluge Functions/Custom Buttons/Total_Cost_of_Tradeshow.ds new file mode 100644 index 0000000..0adf49b --- /dev/null +++ b/Deluge Functions/Custom Buttons/Total_Cost_of_Tradeshow.ds @@ -0,0 +1,18 @@ +// This deluge script will pull entries from the Expenses modules and when attributed to a campaign, will add up the expenses to the "Actual Cost" field in the Campaign entry. +// Arguments +//expid = Trade Show Expense id +//campid = Campaign id + +//Get Campaigns Related to Trade Show Expense +relexp = zoho.crm.getRecordById("Trade_Show_Expenses",expid); +newrel = zoho.crm.getRelatedRecords("Expenses","Campaigns",campid); +total = 0.0; + +//Total up all expenses related to the Campaign +for each rec in newrel +{ + //iterate and refresh total in case other expense amounts change at later date + total = total + if(rec.get("Amount") == "",0.0,rec.get("Amount").toDecimal()); +} +//Update Campaign with new values +update = zoho.crm.updateRecord("Campaigns",campid,{"Actual_Cost":total}); From 4ee62607566a9bd436d2b13b1e42360dfb769b6e Mon Sep 17 00:00:00 2001 From: georgeotj Date: Wed, 20 Mar 2019 11:39:45 -0500 Subject: [PATCH 10/59] Updated format to increase clarity --- .../Custom Buttons/Total_Cost_of_Tradeshow.ds | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Deluge Functions/Custom Buttons/Total_Cost_of_Tradeshow.ds b/Deluge Functions/Custom Buttons/Total_Cost_of_Tradeshow.ds index 0adf49b..c7a9099 100644 --- a/Deluge Functions/Custom Buttons/Total_Cost_of_Tradeshow.ds +++ b/Deluge Functions/Custom Buttons/Total_Cost_of_Tradeshow.ds @@ -1,9 +1,9 @@ -// This deluge script will pull entries from the Expenses modules and when attributed to a campaign, will add up the expenses to the "Actual Cost" field in the Campaign entry. -// Arguments -//expid = Trade Show Expense id -//campid = Campaign id +// Author: georgeotj +// Description: This deluge script will pull entries from the Expenses modules and when attributed to a campaign, will add up the expenses to the "Actual Cost" field in the Campaign entry. +// Requirements: "Lead Name" Lookup on Quotes Layout +// Arguments: expid = Trade Show Expense id, campid = Campaign id -//Get Campaigns Related to Trade Show Expense +// Declare variables relexp = zoho.crm.getRecordById("Trade_Show_Expenses",expid); newrel = zoho.crm.getRelatedRecords("Expenses","Campaigns",campid); total = 0.0; @@ -14,5 +14,6 @@ for each rec in newrel //iterate and refresh total in case other expense amounts change at later date total = total + if(rec.get("Amount") == "",0.0,rec.get("Amount").toDecimal()); } + //Update Campaign with new values update = zoho.crm.updateRecord("Campaigns",campid,{"Actual_Cost":total}); From 54e6ba36a9075b6d8ece5fcf2645c7552a6f5e9f Mon Sep 17 00:00:00 2001 From: georgeotj Date: Wed, 20 Mar 2019 11:50:39 -0500 Subject: [PATCH 11/59] Update Total_Cost_of_Tradeshow.ds --- Deluge Functions/Custom Buttons/Total_Cost_of_Tradeshow.ds | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Deluge Functions/Custom Buttons/Total_Cost_of_Tradeshow.ds b/Deluge Functions/Custom Buttons/Total_Cost_of_Tradeshow.ds index c7a9099..f38fa66 100644 --- a/Deluge Functions/Custom Buttons/Total_Cost_of_Tradeshow.ds +++ b/Deluge Functions/Custom Buttons/Total_Cost_of_Tradeshow.ds @@ -1,6 +1,6 @@ // Author: georgeotj // Description: This deluge script will pull entries from the Expenses modules and when attributed to a campaign, will add up the expenses to the "Actual Cost" field in the Campaign entry. -// Requirements: "Lead Name" Lookup on Quotes Layout +// Requirements: "Trade Show Expenses" module // Arguments: expid = Trade Show Expense id, campid = Campaign id // Declare variables From 9bdcc50266033d46415887fb581586f603c20a4c Mon Sep 17 00:00:00 2001 From: georgeotj Date: Wed, 20 Mar 2019 12:00:58 -0500 Subject: [PATCH 12/59] Create Trade_Show_ROI.ds --- .../Custom Buttons/Trade_Show_ROI.ds | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 Deluge Functions/Custom Buttons/Trade_Show_ROI.ds diff --git a/Deluge Functions/Custom Buttons/Trade_Show_ROI.ds b/Deluge Functions/Custom Buttons/Trade_Show_ROI.ds new file mode 100644 index 0000000..ff0ac3e --- /dev/null +++ b/Deluge Functions/Custom Buttons/Trade_Show_ROI.ds @@ -0,0 +1,24 @@ +// Author: georgeotj +// Description: This deluge script will auomatically calculate the ROI of a Campaign when comparing Actual Revenue and Actual Cost +// Requirements: "Lead Name" Lookup on Quotes Layout +// Arguments: campid = Campaign id, dealid = Deal Id + +// Declare variables +deal = dealid; +thisCampaign = zoho.crm.getRecordById("Campaigns",campid); +relatedDeals = zoho.crm.getRelatedRecords("Deals","Campaigns",campid); +total = 0.0; + + +// Look through the Deals related list in the Campaigns module and if there's a "Closed Won" deal, add it up to the Actual Revenue +for each deal in relatedDeals +{ + info deal.get("Amount"); + stage = deal.get("Stage"); + info stage; + if(stage == "Closed Won") + { + total = total + ifnull(deal.get("Amount"),"0.0").toDecimal(); + } + update = zoho.crm.updateRecord("Campaigns",campid,{"Actual_Revenue":total}); +} From dbfbd6d6f8e08bbd43ffcfc931088ba0165eb7e0 Mon Sep 17 00:00:00 2001 From: georgeotj Date: Wed, 20 Mar 2019 12:41:30 -0500 Subject: [PATCH 13/59] Rename Deluge Functions/Custom Buttons/Total_Cost_of_Tradeshow.ds to Deluge Functions/Total_Cost_of_Tradeshow.ds --- Deluge Functions/{Custom Buttons => }/Total_Cost_of_Tradeshow.ds | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Deluge Functions/{Custom Buttons => }/Total_Cost_of_Tradeshow.ds (100%) diff --git a/Deluge Functions/Custom Buttons/Total_Cost_of_Tradeshow.ds b/Deluge Functions/Total_Cost_of_Tradeshow.ds similarity index 100% rename from Deluge Functions/Custom Buttons/Total_Cost_of_Tradeshow.ds rename to Deluge Functions/Total_Cost_of_Tradeshow.ds From d4d1b30a2c945ec008afd237e13be272e7202704 Mon Sep 17 00:00:00 2001 From: georgeotj Date: Wed, 20 Mar 2019 12:41:49 -0500 Subject: [PATCH 14/59] Rename Deluge Functions/Custom Buttons/Trade_Show_ROI.ds to Deluge Functions/Trade_Show_ROI.ds --- Deluge Functions/{Custom Buttons => }/Trade_Show_ROI.ds | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Deluge Functions/{Custom Buttons => }/Trade_Show_ROI.ds (100%) diff --git a/Deluge Functions/Custom Buttons/Trade_Show_ROI.ds b/Deluge Functions/Trade_Show_ROI.ds similarity index 100% rename from Deluge Functions/Custom Buttons/Trade_Show_ROI.ds rename to Deluge Functions/Trade_Show_ROI.ds From 9c0098e70dbe7060f17ce5caa987de7ba8dd21e8 Mon Sep 17 00:00:00 2001 From: georgeotj Date: Wed, 20 Mar 2019 12:42:17 -0500 Subject: [PATCH 15/59] Rename Deluge Functions/Custom Buttons/convert_lead_from_quote_view.ds to Deluge Functions/convert_lead_from_quote_view.ds --- .../{Custom Buttons => }/convert_lead_from_quote_view.ds | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename Deluge Functions/{Custom Buttons => }/convert_lead_from_quote_view.ds (96%) diff --git a/Deluge Functions/Custom Buttons/convert_lead_from_quote_view.ds b/Deluge Functions/convert_lead_from_quote_view.ds similarity index 96% rename from Deluge Functions/Custom Buttons/convert_lead_from_quote_view.ds rename to Deluge Functions/convert_lead_from_quote_view.ds index a6aa0fe..23860e7 100644 --- a/Deluge Functions/Custom Buttons/convert_lead_from_quote_view.ds +++ b/Deluge Functions/convert_lead_from_quote_view.ds @@ -26,4 +26,4 @@ quote_map.put("Contact_Name",contact_ID); // Update Quote with Account / Contact ID resp = zoho.crm.updateRecord("Quotes",quote_ID,quote_map); -return "Success: Lead Converted"; \ No newline at end of file +return "Success: Lead Converted"; From 8bb7efb347a8d9c90283ef51bd96b0d4b7e45517 Mon Sep 17 00:00:00 2001 From: georgeotj Date: Wed, 20 Mar 2019 12:46:13 -0500 Subject: [PATCH 16/59] Create Custom Function --- Deluge Functions/Custom Function | 1 + 1 file changed, 1 insertion(+) create mode 100644 Deluge Functions/Custom Function diff --git a/Deluge Functions/Custom Function b/Deluge Functions/Custom Function new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/Deluge Functions/Custom Function @@ -0,0 +1 @@ + From dcfdb6bea884f42861cb9b50fe0ea016f59b0163 Mon Sep 17 00:00:00 2001 From: georgeotj Date: Wed, 20 Mar 2019 12:46:46 -0500 Subject: [PATCH 17/59] Delete Custom Function --- Deluge Functions/Custom Function | 1 - 1 file changed, 1 deletion(-) delete mode 100644 Deluge Functions/Custom Function diff --git a/Deluge Functions/Custom Function b/Deluge Functions/Custom Function deleted file mode 100644 index 8b13789..0000000 --- a/Deluge Functions/Custom Function +++ /dev/null @@ -1 +0,0 @@ - From 5cb1999857be4e4f63e666a38b46158cb09754d8 Mon Sep 17 00:00:00 2001 From: georgeotj Date: Wed, 20 Mar 2019 12:54:12 -0500 Subject: [PATCH 18/59] Create README.txt --- Deluge Functions/Custom Functions/README.txt | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 Deluge Functions/Custom Functions/README.txt diff --git a/Deluge Functions/Custom Functions/README.txt b/Deluge Functions/Custom Functions/README.txt new file mode 100644 index 0000000..014d81a --- /dev/null +++ b/Deluge Functions/Custom Functions/README.txt @@ -0,0 +1,10 @@ +This folder will contain custom functions for Zoho CRM. These functions will have the following format + +// Author: +// Description: +// Requirements: +// Arguments: + +// Declare variables + +// Code From ded339a0dbb049348fe2cf0005a0a7f37c5dec0b Mon Sep 17 00:00:00 2001 From: georgeotj Date: Wed, 20 Mar 2019 12:54:46 -0500 Subject: [PATCH 19/59] Rename Deluge Functions/Total_Cost_of_Tradeshow.ds to Deluge Functions/Custom Functions/Total_Cost_of_Tradeshow.ds --- .../{ => Custom Functions}/Total_Cost_of_Tradeshow.ds | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Deluge Functions/{ => Custom Functions}/Total_Cost_of_Tradeshow.ds (100%) diff --git a/Deluge Functions/Total_Cost_of_Tradeshow.ds b/Deluge Functions/Custom Functions/Total_Cost_of_Tradeshow.ds similarity index 100% rename from Deluge Functions/Total_Cost_of_Tradeshow.ds rename to Deluge Functions/Custom Functions/Total_Cost_of_Tradeshow.ds From 9c051d2e7d91246d2ef11afbbfd6c8a68e58f87d Mon Sep 17 00:00:00 2001 From: georgeotj Date: Wed, 20 Mar 2019 12:55:15 -0500 Subject: [PATCH 20/59] Rename Deluge Functions/Trade_Show_ROI.ds to Deluge Functions/Custom Functions/Trade_Show_ROI.ds --- Deluge Functions/{ => Custom Functions}/Trade_Show_ROI.ds | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Deluge Functions/{ => Custom Functions}/Trade_Show_ROI.ds (100%) diff --git a/Deluge Functions/Trade_Show_ROI.ds b/Deluge Functions/Custom Functions/Trade_Show_ROI.ds similarity index 100% rename from Deluge Functions/Trade_Show_ROI.ds rename to Deluge Functions/Custom Functions/Trade_Show_ROI.ds From fca48e52a1295fe4d0b3a7560025da12775391eb Mon Sep 17 00:00:00 2001 From: georgeotj Date: Wed, 20 Mar 2019 12:55:33 -0500 Subject: [PATCH 21/59] Rename Deluge Functions/convert_lead_from_quote_view.ds to Deluge Functions/Custom Functions/convert_lead_from_quote_view.ds --- .../{ => Custom Functions}/convert_lead_from_quote_view.ds | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Deluge Functions/{ => Custom Functions}/convert_lead_from_quote_view.ds (100%) diff --git a/Deluge Functions/convert_lead_from_quote_view.ds b/Deluge Functions/Custom Functions/convert_lead_from_quote_view.ds similarity index 100% rename from Deluge Functions/convert_lead_from_quote_view.ds rename to Deluge Functions/Custom Functions/convert_lead_from_quote_view.ds From e2d4eb71541149b96c594280c48385d11e47f3cc Mon Sep 17 00:00:00 2001 From: georgeotj Date: Tue, 26 Mar 2019 10:58:49 -0500 Subject: [PATCH 22/59] Create leadScoring.ds This is an update to the original deluge script which is present on the Gallery of Custom Functions. --- .../Custom Functions/leadScoring.ds | 70 +++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 Deluge Functions/Custom Functions/leadScoring.ds diff --git a/Deluge Functions/Custom Functions/leadScoring.ds b/Deluge Functions/Custom Functions/leadScoring.ds new file mode 100644 index 0000000..23f8743 --- /dev/null +++ b/Deluge Functions/Custom Functions/leadScoring.ds @@ -0,0 +1,70 @@ +This folder will contain custom functions for Zoho CRM. These functions will have the following format + +// Author: georgeotj +// Description: To rate leads, we want to follow certain criteria like having a phone numberm, email, and more information. +// Requirements: Leads module with a custom text field called, "Lead Rating" +// Arguments: leadId:Lead Id, phone:Phone, email:Email, title:Title, website:Website, industry:Industry, scoreField, Lead Rating + +// Declare variables + +// Code +//Verify that if the fields are null (different from isEmpty()) +if(phone.isNull()) { + phone = ""; +} +if(email.isNull()) { + email = ""; +} +if(title.isNull()) { + title = ""; +} +if(website.isNull()) { + website = ""; +} +if(industry.isNull()){ + industry = ""; +} + +//Start point counting +point = 0; + +if(phone.length() >= 9) { + point += 2; +} +if(!(email.contains("gmail") || email.contains("yahoo") || email.contains("outlook") || email == "")) { + point += 2; +} +if(title.contains("CEO") || title.contains("manager") || title.contains("dir") || title.contains("VP")) { + point += 2; +} +if(!website.isBlank()) { + point += 2; +} +if(industry.contains("ERP")) { + point += 2; +} + +//Calculating the points. +if(point >= 9) { + score = "*****"; +} +else if(point >= 7) { + score = "****"; +} +else if(point >= 5) { + score = "***"; +} +else if(point >= 3) { + score = "**"; +} +else if(point >= 1) { + score = "*"; +} +else { + score = ""; +} + +info point; +info score; +updateMap = {scoreField:score}; +updatedResponse = zoho.crm.updateRecord("Leads",leadId,updateMap); From 678f9f45917940def1aee75f5a3393ed52c4fca3 Mon Sep 17 00:00:00 2001 From: georgeotj Date: Tue, 26 Mar 2019 11:49:29 -0500 Subject: [PATCH 23/59] Update leadScoring.ds added scoreField check --- Deluge Functions/Custom Functions/leadScoring.ds | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Deluge Functions/Custom Functions/leadScoring.ds b/Deluge Functions/Custom Functions/leadScoring.ds index 23f8743..c4d03f8 100644 --- a/Deluge Functions/Custom Functions/leadScoring.ds +++ b/Deluge Functions/Custom Functions/leadScoring.ds @@ -24,6 +24,9 @@ if(website.isNull()) { if(industry.isNull()){ industry = ""; } +if(scoreField.isNull() || scoreField.isEmpty()) { + scoreField = ""; +} //Start point counting point = 0; From b562577280988bea43f4d6bfc02854c6242ea63f Mon Sep 17 00:00:00 2001 From: georgeotj Date: Wed, 27 Mar 2019 09:17:47 -0500 Subject: [PATCH 24/59] Update Trade_Show_ROI.ds fixed formatting --- Deluge Functions/Custom Functions/Trade_Show_ROI.ds | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Deluge Functions/Custom Functions/Trade_Show_ROI.ds b/Deluge Functions/Custom Functions/Trade_Show_ROI.ds index ff0ac3e..5aa8495 100644 --- a/Deluge Functions/Custom Functions/Trade_Show_ROI.ds +++ b/Deluge Functions/Custom Functions/Trade_Show_ROI.ds @@ -1,6 +1,6 @@ // Author: georgeotj // Description: This deluge script will auomatically calculate the ROI of a Campaign when comparing Actual Revenue and Actual Cost -// Requirements: "Lead Name" Lookup on Quotes Layout +// Requirements: Revenue Information for // Arguments: campid = Campaign id, dealid = Deal Id // Declare variables @@ -9,7 +9,6 @@ thisCampaign = zoho.crm.getRecordById("Campaigns",campid); relatedDeals = zoho.crm.getRelatedRecords("Deals","Campaigns",campid); total = 0.0; - // Look through the Deals related list in the Campaigns module and if there's a "Closed Won" deal, add it up to the Actual Revenue for each deal in relatedDeals { From 88d9a9c83a60bda6bb95a9d9278542214b24f058 Mon Sep 17 00:00:00 2001 From: georgeotj Date: Wed, 27 Mar 2019 09:33:28 -0500 Subject: [PATCH 25/59] Update leadScoring.ds Corrected error that wouldn't update the "LeadScore" field with the stars. --- Deluge Functions/Custom Functions/leadScoring.ds | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/Deluge Functions/Custom Functions/leadScoring.ds b/Deluge Functions/Custom Functions/leadScoring.ds index c4d03f8..4e417d8 100644 --- a/Deluge Functions/Custom Functions/leadScoring.ds +++ b/Deluge Functions/Custom Functions/leadScoring.ds @@ -2,11 +2,12 @@ This folder will contain custom functions for Zoho CRM. These functions will hav // Author: georgeotj // Description: To rate leads, we want to follow certain criteria like having a phone numberm, email, and more information. -// Requirements: Leads module with a custom text field called, "Lead Rating" -// Arguments: leadId:Lead Id, phone:Phone, email:Email, title:Title, website:Website, industry:Industry, scoreField, Lead Rating +// Requirements: Leads module with a custom text field called, "LeadScore" +// Arguments: leadId:Lead Id, phone:Phone, email:Email, title:Title, website:Website, industry:Industry, scoreField:LeadScore // Declare variables + // Code //Verify that if the fields are null (different from isEmpty()) if(phone.isNull()) { @@ -28,7 +29,7 @@ if(scoreField.isNull() || scoreField.isEmpty()) { scoreField = ""; } -//Start point counting +//Start counting up the points point = 0; if(phone.length() >= 9) { @@ -66,8 +67,4 @@ else if(point >= 1) { else { score = ""; } - -info point; -info score; -updateMap = {scoreField:score}; -updatedResponse = zoho.crm.updateRecord("Leads",leadId,updateMap); +updatedResponse = zoho.crm.updateRecord("Leads",leadId,{"LeadScore":score}); From 6ca22e362575d75c674dba932ba1e011769c5e0d Mon Sep 17 00:00:00 2001 From: georgeotj Date: Thu, 28 Mar 2019 09:14:15 -0500 Subject: [PATCH 26/59] Create Close_Junk_Lead_Tasks.ds --- .../Custom Functions/Close_Junk_Lead_Tasks.ds | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 Deluge Functions/Custom Functions/Close_Junk_Lead_Tasks.ds diff --git a/Deluge Functions/Custom Functions/Close_Junk_Lead_Tasks.ds b/Deluge Functions/Custom Functions/Close_Junk_Lead_Tasks.ds new file mode 100644 index 0000000..2cc05e9 --- /dev/null +++ b/Deluge Functions/Custom Functions/Close_Junk_Lead_Tasks.ds @@ -0,0 +1,21 @@ +This folder will contain custom functions for Zoho CRM. These functions will have the following format + +// Author: georgeotj +// Description: There are many sources for lead generation within Zoho CRM. When you validate the leads during the nurturing process, a few leads will qualify as Junk. Even if you mark a lead as junk, the tasks associated with it will remain open. This function allows you to close tasks associated with junk leads. +// Requirements: No changes necessary for CRM. +// Arguments: LeadID: Lead Id, status: Lead Status + +// Declare variables + +// Code +if(leadStatus.contains("Junk")) +{ + relatedTask = zoho.crm.getRelatedRecords("Tasks","Leads",leadId); + for each task in relatedTask + { + mapVariable = Map(); + mapVariable.put("Status","Completed"); + taskID = task.get("id"); + updateTask = zoho.crm.updateRecord("Tasks",taskID,mapVariable); + } +} From 3775444218db8fb17c2ff784c85e317f43df4a26 Mon Sep 17 00:00:00 2001 From: georgeotj Date: Thu, 28 Mar 2019 09:14:34 -0500 Subject: [PATCH 27/59] Rename leadScoring.ds to Lead_Scoring.ds --- .../Custom Functions/{leadScoring.ds => Lead_Scoring.ds} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Deluge Functions/Custom Functions/{leadScoring.ds => Lead_Scoring.ds} (100%) diff --git a/Deluge Functions/Custom Functions/leadScoring.ds b/Deluge Functions/Custom Functions/Lead_Scoring.ds similarity index 100% rename from Deluge Functions/Custom Functions/leadScoring.ds rename to Deluge Functions/Custom Functions/Lead_Scoring.ds From 337edbd6102da50184597928c7b0e5c0b69fd43c Mon Sep 17 00:00:00 2001 From: georgeotj Date: Thu, 28 Mar 2019 09:15:13 -0500 Subject: [PATCH 28/59] Rename convert_lead_from_quote_view.ds to Convert_Lead_From_Quote_View.ds --- ...rt_lead_from_quote_view.ds => Convert_Lead_From_Quote_View.ds} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Deluge Functions/Custom Functions/{convert_lead_from_quote_view.ds => Convert_Lead_From_Quote_View.ds} (100%) diff --git a/Deluge Functions/Custom Functions/convert_lead_from_quote_view.ds b/Deluge Functions/Custom Functions/Convert_Lead_From_Quote_View.ds similarity index 100% rename from Deluge Functions/Custom Functions/convert_lead_from_quote_view.ds rename to Deluge Functions/Custom Functions/Convert_Lead_From_Quote_View.ds From 7cf63ac8cc2529b5fc2dc47aef3d4a6a62c50e24 Mon Sep 17 00:00:00 2001 From: georgeotj Date: Thu, 28 Mar 2019 10:51:33 -0500 Subject: [PATCH 29/59] Create Capturing_Sales_Region.ds --- .../Capturing_Sales_Region.ds | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 Deluge Functions/Custom Functions/Capturing_Sales_Region.ds diff --git a/Deluge Functions/Custom Functions/Capturing_Sales_Region.ds b/Deluge Functions/Custom Functions/Capturing_Sales_Region.ds new file mode 100644 index 0000000..aa962f4 --- /dev/null +++ b/Deluge Functions/Custom Functions/Capturing_Sales_Region.ds @@ -0,0 +1,29 @@ +This folder will contain custom functions for Zoho CRM. These functions will have the following format + +// Author: georgeotj +// Description: Based on a Lead's country, they will be marked to a specific region in their profile. +// Requirements: Custom field called "Region" in the Leads module inside the Address Information +// Arguments: leadId: Lead Id, country: Country, fieldToUpdate: Region + +// Declare variables +countryList1 = {"united kingdom","uk","great britain","gb"}; +countryList2 = {"united states","usa","us"}; +countryList3 = {"argentina","bolivia","brazil","chile","colombia","ecuadar","guiana","guyana","mexico","paraguay"}; +countryList4 = {"France","Belgium","Germany","Netherlands","Ireland","Israel","South Africa","Italy","United Arab Emirates","Spain"}; +countryList5 = {"Singapore","China","Japan","Thailand","Vietnam","Malaysia","Mauritius","Hongkong","Maldives","Pakistan"}; +countryMap = {"UK":countryList1,"US":countryList2,"SAMERICA":countryList3,"EMEA":countryList4,"APAC":countryList5}; + +countryMapkKey = countryMap.keys(); +mailingRegion = ""; + +// Code +for each region in countryMapkKey +{ + countryListValue = countryMap.get(region); + if(countryListValue.contains(country.toLowerCase())) + { + mailingRegion = region; + } +} +updateMap = {fieldToUpdate:mailingRegion}; +updatedResponse = zoho.crm.updateRecord("Leads",leadId,updateMap); From 8cd9871f8f0544ef510690b1a8be03c06af0076a Mon Sep 17 00:00:00 2001 From: georgeotj Date: Thu, 28 Mar 2019 11:01:02 -0500 Subject: [PATCH 30/59] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ed25398..948d4a7 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ ### Author: - Scott Minter + Scott Minter/Jorge Huerta ### Project Outline and Goals: From 32c61f464b256fc44d615d1ad3f9babbf732824d Mon Sep 17 00:00:00 2001 From: georgeotj Date: Fri, 29 Mar 2019 08:50:58 -0500 Subject: [PATCH 31/59] Update Close_Junk_Lead_Tasks.ds --- Deluge Functions/Custom Functions/Close_Junk_Lead_Tasks.ds | 2 -- 1 file changed, 2 deletions(-) diff --git a/Deluge Functions/Custom Functions/Close_Junk_Lead_Tasks.ds b/Deluge Functions/Custom Functions/Close_Junk_Lead_Tasks.ds index 2cc05e9..525ac02 100644 --- a/Deluge Functions/Custom Functions/Close_Junk_Lead_Tasks.ds +++ b/Deluge Functions/Custom Functions/Close_Junk_Lead_Tasks.ds @@ -1,5 +1,3 @@ -This folder will contain custom functions for Zoho CRM. These functions will have the following format - // Author: georgeotj // Description: There are many sources for lead generation within Zoho CRM. When you validate the leads during the nurturing process, a few leads will qualify as Junk. Even if you mark a lead as junk, the tasks associated with it will remain open. This function allows you to close tasks associated with junk leads. // Requirements: No changes necessary for CRM. From 06e578925e6879f027c24c5f97eeaa2bcd6a9082 Mon Sep 17 00:00:00 2001 From: georgeotj Date: Fri, 29 Mar 2019 12:02:46 -0500 Subject: [PATCH 32/59] Create Mass_Update_of_Child_Contacts.ds --- .../Mass_Update_of_Child_Contacts.ds | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 Deluge Functions/Custom Functions/Mass_Update_of_Child_Contacts.ds diff --git a/Deluge Functions/Custom Functions/Mass_Update_of_Child_Contacts.ds b/Deluge Functions/Custom Functions/Mass_Update_of_Child_Contacts.ds new file mode 100644 index 0000000..78ff06e --- /dev/null +++ b/Deluge Functions/Custom Functions/Mass_Update_of_Child_Contacts.ds @@ -0,0 +1,26 @@ +// Author: georgeotj +// Description: Automatically updates the address of child contacts whenever the address information for the Account is updated. +// Requirements: N/A +// Arguments: accID = Account Id + +// Declare variables +rec = zoho.crm.getRecordById("Accounts",accId); +resp = zoho.crm.getRelatedRecords("Contacts","Accounts",accId); + +// Code +for each ele in resp +{ + mp = Map(); + mp.put("Mailing_Street",rec.get("Billing_Street")); + mp.put("Mailing_City",rec.get("Billing_City")); + mp.put("Mailing_State",rec.get("Billing_State")); + mp.put("Mailing_Zip",rec.get("Billing_Code")); + mp.put("Mailing_Country",rec.get("Billing_Country")); + mp.put("Other_Street",rec.get("Shipping_Street")); + mp.put("Other_City",rec.get("Shipping_City")); + mp.put("Other_State",rec.get("Shipping_State")); + mp.put("Other_Zip",rec.get("Shipping_Code")); + mp.put("Other_Country",rec.get("Shipping_Country")); + contactId = ele.get("id"); + updateResp = zoho.crm.updateRecord("Contacts",ele.get("id"),mp); +} From 0e4a315bbcfdd22c0eeb218ffe4d4133ccf13f84 Mon Sep 17 00:00:00 2001 From: georgeotj Date: Mon, 1 Apr 2019 09:15:32 -0500 Subject: [PATCH 33/59] Create Generate_Total_Revenue_From_Deals --- .../Generate_Total_Revenue_From_Deals | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 Deluge Functions/Custom Functions/Generate_Total_Revenue_From_Deals diff --git a/Deluge Functions/Custom Functions/Generate_Total_Revenue_From_Deals b/Deluge Functions/Custom Functions/Generate_Total_Revenue_From_Deals new file mode 100644 index 0000000..9a59083 --- /dev/null +++ b/Deluge Functions/Custom Functions/Generate_Total_Revenue_From_Deals @@ -0,0 +1,24 @@ +This folder will contain custom functions for Zoho CRM. These functions will have the following format + +// Author: georgeotj +// Description: This function will track total revenue by adding up all the deals +// Requirements: This will require a custom field in the "Accounts" module, it will be called Total Revenue. +// Arguments: accountId:Account Id, Total_Revenue:Total Revenue + +// Declare variables +accountID1 = accountId.toString(); +resp = zoho.crm.getRelatedRecords("Deals","Accounts",accountId); +total = 0.0; + +// Code +for each rec in resp +{ + stage = rec.get("Stage").toLowerCase(); + if(stage.contains("won")) + { + total = total + rec.get("Amount").toDecimal(); + info total; + updateResp = zoho.crm.updateRecord("Accounts",accountId,{"Total_Revenue":total}); + info updateResp; + } +} From aa55f5195d4df2409fc5644d0eb140867da595db Mon Sep 17 00:00:00 2001 From: georgeotj Date: Tue, 2 Apr 2019 10:30:28 -0500 Subject: [PATCH 34/59] Create Create_Projects_While_Winning_Potentials.ds --- ...reate_Projects_While_Winning_Potentials.ds | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 Deluge Functions/Custom Functions/Create_Projects_While_Winning_Potentials.ds diff --git a/Deluge Functions/Custom Functions/Create_Projects_While_Winning_Potentials.ds b/Deluge Functions/Custom Functions/Create_Projects_While_Winning_Potentials.ds new file mode 100644 index 0000000..b5ce4cb --- /dev/null +++ b/Deluge Functions/Custom Functions/Create_Projects_While_Winning_Potentials.ds @@ -0,0 +1,22 @@ +This folder will contain custom functions for Zoho CRM. These functions will have the following format + +// Author: Zach Zivnuska +// Description: This function will automatically create a new Project whenever a deal is created. +// Requirements: Must have an active Zoho Projects account +// Arguments: N/A +// Notes: //In order to get your URL, you must replace the [portalId] with your organization's + //To get your portalId, follow the instructions below + //Go to Zoho Projects --> go to Setup --> Under 'Integration' click "Developer Space" in the page that opens, + //click on "Service Hooks" --> look at the URL's and you will see your organization's portalId. + +// Declare variables +m = {"name":name}; + +// Code +response = invokeurl +[ + url :"https://projectsapi.zoho.com/restapi/portal/[portalId]/projects/" + type :POST + parameters:m + connection:"zoho264" +]; From 303251ab8af8277ecb7357b5dd813ca8f436d43e Mon Sep 17 00:00:00 2001 From: georgeotj Date: Tue, 2 Apr 2019 12:30:50 -0500 Subject: [PATCH 35/59] Create Time_To_Close.ds --- .../Custom Functions/Time_To_Close.ds | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 Deluge Functions/Custom Functions/Time_To_Close.ds diff --git a/Deluge Functions/Custom Functions/Time_To_Close.ds b/Deluge Functions/Custom Functions/Time_To_Close.ds new file mode 100644 index 0000000..b87849c --- /dev/null +++ b/Deluge Functions/Custom Functions/Time_To_Close.ds @@ -0,0 +1,23 @@ +This folder will contain custom functions for Zoho CRM. These functions will have the following format + +// Author: Zach Zivnuska/georgeotj +// Description: This function will calculate how many hours it took to close. +// Requirements: N/A +// Arguments: leadId:Lead Id + +// Declare variables +related = zoho.crm.getRelatedRecords("Activities_History","Leads",leadId); +lead = zoho.crm.getRecordById("Leads",leadId); + +// Code +for each rec in related +{ + ctn = rec.get("Closed_Time"); +} +created = lead.get("Created_Time"); +closedTime = ctn.toDateTime("yyyy-MM-dd'T'HH:mm:ss"); +openedTime = created.toDateTime("yyyy-MM-dd'T'HH:mm:ss"); +tot = (closedTime - openedTime) / (1000 * 3600); +info openedTime; +info closedTime; +info tot; From 502f4a944353658e10619b9f13234dda068ab2de Mon Sep 17 00:00:00 2001 From: georgeotj Date: Wed, 1 May 2019 08:39:12 -0500 Subject: [PATCH 36/59] Create Current_Value_In_Previous.ds --- .../Custom Functions/Current_Value_In_Previous.ds | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 Deluge Functions/Custom Functions/Current_Value_In_Previous.ds diff --git a/Deluge Functions/Custom Functions/Current_Value_In_Previous.ds b/Deluge Functions/Custom Functions/Current_Value_In_Previous.ds new file mode 100644 index 0000000..888a122 --- /dev/null +++ b/Deluge Functions/Custom Functions/Current_Value_In_Previous.ds @@ -0,0 +1,15 @@ +// Author: georgeotj +// Description: To be able to keep a history of status changes, we must ensure that we still keep the previous choice. This will work with a Workflow that will only run when new deals are created. +// Requirements: In the deals module, you must create 2 Custom Fields that will store the current and the previouas status'. +// Arguments: dealId = Deal Id + +// Declare variables +deal = zoho.crm.getRecordById("Deals",dealId); + +//Code +currentClosing = deal.get("Expected_Close_Date"); +previousClosing = deal.get("Previous_Close_Date"); +mp = Map(); +mp.put("Previous_Close_Date",deal.get("Expected_Close_Date")); +updateResp = zoho.crm.updateRecord("Deals",dealId,mp); +info updateResp; From 0248573f086a942745b6609e57d8423743577953 Mon Sep 17 00:00:00 2001 From: georgeotj Date: Wed, 1 May 2019 10:58:38 -0500 Subject: [PATCH 37/59] Create Creare_CF_History_Record.ds --- .../Creare_CF_History_Record.ds | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 Deluge Functions/Custom Functions/Creare_CF_History_Record.ds diff --git a/Deluge Functions/Custom Functions/Creare_CF_History_Record.ds b/Deluge Functions/Custom Functions/Creare_CF_History_Record.ds new file mode 100644 index 0000000..ec3d693 --- /dev/null +++ b/Deluge Functions/Custom Functions/Creare_CF_History_Record.ds @@ -0,0 +1,28 @@ +// Author: georgeotj +// Description: This script will allow you to create a new record to keep a history of the changes made to a specific custom field +// Requirements: Associated Module is Dealsd, Custom Module with fields Name (Single Line), Owner (Lookup), Updated From (Single Line), Updated To (Single line), Deal Associated (Lookup, Deals) +// Arguments: dealId Deal Id + +// Declare variables +deal = zoho.crm.getRecordById("Deals",dealId); +currentClose = deal.get("Expected_Close_Date"); +previousClose = deal.get("Previous_Close_Date"); +dealName = deal.get("Deal_Name"); +lastModified = deal.get("Modified_By"); + +// Code +if(currentClose != previousClose) +{ + mp = Map(); + mp.put("Updated_To",currentClose); + mp.put("Updated_From",previousClose); + mp.put("Client_Name",dealId); + mp.put("Name",dealName); + mp.put("Owner",lastModified); + createRec = zoho.crm.createRecord("Deal_CF_History",mp); + info createRec; +} +updatePrevMap = Map(); +updatePrevMap.put("Previous_Close_Date",currentClose); +updatePrevious = zoho.crm.updateRecord("Deals",dealId,updatePrevMap); +info updatePrevious; From 877702e291830929da98193ea03c75d58314a63e Mon Sep 17 00:00:00 2001 From: georgeotj Date: Wed, 1 May 2019 11:00:36 -0500 Subject: [PATCH 38/59] Rename Creare_CF_History_Record.ds to Create_CF_History_Record.ds --- .../{Creare_CF_History_Record.ds => Create_CF_History_Record.ds} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Deluge Functions/Custom Functions/{Creare_CF_History_Record.ds => Create_CF_History_Record.ds} (100%) diff --git a/Deluge Functions/Custom Functions/Creare_CF_History_Record.ds b/Deluge Functions/Custom Functions/Create_CF_History_Record.ds similarity index 100% rename from Deluge Functions/Custom Functions/Creare_CF_History_Record.ds rename to Deluge Functions/Custom Functions/Create_CF_History_Record.ds From e54d9eb3a005500a625802f363a642105767ff4a Mon Sep 17 00:00:00 2001 From: georgeotj Date: Wed, 1 May 2019 11:05:06 -0500 Subject: [PATCH 39/59] Create Take_Current_CF_Add_To_Previous_CF.ds --- .../Take_Current_CF_Add_To_Previous_CF.ds | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 Deluge Functions/Custom Functions/Take_Current_CF_Add_To_Previous_CF.ds diff --git a/Deluge Functions/Custom Functions/Take_Current_CF_Add_To_Previous_CF.ds b/Deluge Functions/Custom Functions/Take_Current_CF_Add_To_Previous_CF.ds new file mode 100644 index 0000000..2c3a164 --- /dev/null +++ b/Deluge Functions/Custom Functions/Take_Current_CF_Add_To_Previous_CF.ds @@ -0,0 +1,15 @@ +// Author: goergeotj +// Description: To keep track of history of the changes to a specific field, we must preserve the original value. +// Requirements: Associated Mod8ule is Deal also, 2 Custom Fields, in this case "Expected_Close_Date" and "Previous_Close_Date" within the Deals module +// Arguments: dealId = Deal Id + +// Declare variables +deal = zoho.crm.getRecordById("Deals",dealId); +currentClosing = deal.get("Expected_Close_Date"); +previousClosing = deal.get("Previous_Close_Date"); + +// Code +mp = Map(); +mp.put("Previous_Close_Date",deal.get("Expected_Close_Date")); +updateResp = zoho.crm.updateRecord("Deals",dealId,mp); +info updateResp; From f80eeba1c02ddd5ca48bd23b8c8a6f1c90e7fb6b Mon Sep 17 00:00:00 2001 From: georgeotj Date: Fri, 3 May 2019 09:56:58 -0500 Subject: [PATCH 40/59] Update Create_CF_History_Record.ds Added days from last edit feature and auto update for the current/previous fields command. --- .../Create_CF_History_Record.ds | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/Deluge Functions/Custom Functions/Create_CF_History_Record.ds b/Deluge Functions/Custom Functions/Create_CF_History_Record.ds index ec3d693..2dab82b 100644 --- a/Deluge Functions/Custom Functions/Create_CF_History_Record.ds +++ b/Deluge Functions/Custom Functions/Create_CF_History_Record.ds @@ -4,11 +4,16 @@ // Arguments: dealId Deal Id // Declare variables +related = zoho.crm.getRelatedRecords("CF_Updated_History","Deals",dealId); deal = zoho.crm.getRecordById("Deals",dealId); currentClose = deal.get("Expected_Close_Date"); previousClose = deal.get("Previous_Close_Date"); dealName = deal.get("Deal_Name"); lastModified = deal.get("Modified_By"); +now = zoho.currenttime.toDatetime(); +lastEntry = related.get(0); +lastEntryTime = lastEntry.get("Created_Time"); +timeDif = days360(lastEntryTime,today); // Code if(currentClose != previousClose) @@ -16,13 +21,14 @@ if(currentClose != previousClose) mp = Map(); mp.put("Updated_To",currentClose); mp.put("Updated_From",previousClose); - mp.put("Client_Name",dealId); + mp.put("Deal_Associated",dealId); mp.put("Name",dealName); mp.put("Owner",lastModified); + mp.put("Days_Between_Changes",timeDif.toString()); createRec = zoho.crm.createRecord("Deal_CF_History",mp); - info createRec; + // Update fields in Deals Module + updatePrevMap = Map(); + updatePrevMap.put("Previous_Close_Date",currentClose); + updatePrevious = zoho.crm.updateRecord("Deals",dealId,updatePrevMap); + info updatePrevious; } -updatePrevMap = Map(); -updatePrevMap.put("Previous_Close_Date",currentClose); -updatePrevious = zoho.crm.updateRecord("Deals",dealId,updatePrevMap); -info updatePrevious; From 6739e09bd2913477b814a85e5547ad6944195f91 Mon Sep 17 00:00:00 2001 From: georgeotj Date: Mon, 6 May 2019 09:24:59 -0500 Subject: [PATCH 41/59] Update Create_CF_History_Record.ds --- .../Create_CF_History_Record.ds | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/Deluge Functions/Custom Functions/Create_CF_History_Record.ds b/Deluge Functions/Custom Functions/Create_CF_History_Record.ds index 2dab82b..5330cfa 100644 --- a/Deluge Functions/Custom Functions/Create_CF_History_Record.ds +++ b/Deluge Functions/Custom Functions/Create_CF_History_Record.ds @@ -10,12 +10,19 @@ currentClose = deal.get("Expected_Close_Date"); previousClose = deal.get("Previous_Close_Date"); dealName = deal.get("Deal_Name"); lastModified = deal.get("Modified_By"); -now = zoho.currenttime.toDatetime(); -lastEntry = related.get(0); -lastEntryTime = lastEntry.get("Created_Time"); -timeDif = days360(lastEntryTime,today); -// Code +//Code +// Try to create the lastEntry variable but if there's nothing available set it to today. +try +{ + lastEntry = related.get(0).get("Created_Time"); +} + catch (e) +{ lastEntry = today.toDate(); +} +timeDif = days360(lastEntry,today); + +//Create the record if(currentClose != previousClose) { mp = Map(); @@ -30,5 +37,4 @@ if(currentClose != previousClose) updatePrevMap = Map(); updatePrevMap.put("Previous_Close_Date",currentClose); updatePrevious = zoho.crm.updateRecord("Deals",dealId,updatePrevMap); - info updatePrevious; } From 595eecb74f6d35d4e3b9e2694ee1e87d9b65e990 Mon Sep 17 00:00:00 2001 From: georgeotj Date: Fri, 9 Aug 2019 10:03:51 -0500 Subject: [PATCH 42/59] Create upsertSetMockaroo.py --- Python/Zoho_CRM_API/2.0/upsertSetMockaroo.py | 60 ++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 Python/Zoho_CRM_API/2.0/upsertSetMockaroo.py diff --git a/Python/Zoho_CRM_API/2.0/upsertSetMockaroo.py b/Python/Zoho_CRM_API/2.0/upsertSetMockaroo.py new file mode 100644 index 0000000..c507e78 --- /dev/null +++ b/Python/Zoho_CRM_API/2.0/upsertSetMockaroo.py @@ -0,0 +1,60 @@ +import requests, json, time, urllib.request +import getAuthRefresh +from Authentication import tokens, credentials +from Resources import statusCodes + +def upsertRecords(url, headers, body, getAuthRefresh): + # Print Input Data + print('\n---- Request ----') + print('URL: ', url) + print('Head: ', headers) + + # Call API + response = requests.post(url, headers=headers, json=body) + + # Print Output Data + if (response.status_code) == 200: + jsonData = json.loads(response.text) + data = jsonData['data'] + print('\n---- Response ----') + print(json.dumps(data, sort_keys=True, indent=4)) + else: + print(response.status_code) + print(response.text) + token = getAuthRefresh + upsertRecords(url, headers, body, getAuthRefresh) + +# Necessary URLs +url ='https://www.zohoapis.com/crm/v2/{module}/upsert' +urlMockaroo ='https://my.api.mockaroo.com/zohopresalesmegaschema.json?key=58fd1ee0' + +# Reads the Mockaroo data and loads it into the file +data = urllib.request.urlopen(urlMockaroo).read() +mockData = json.loads(data) + +# Get Token and Headers +token = tokens.getAccess() +headers = {'Authorization': token} + +# Build Body +# NOTE: The mockData[x] must be iterated through, still haven't been able to figure it out. +body = { + "data": [ + mockData[0] + ] +} + +url = url.replace('{module}', 'CustomModule1') +upsertRecords(url,headers,body,getAuthRefresh) +url = url.replace('CustomModule1', '{module}') + +url = url.replace('{module}', 'Contacts') +upsertRecords(url,headers,body,getAuthRefresh) +url = url.replace('Contacts', '{module}') + +url = url.replace('{module}', 'Accounts') +upsertRecords(url,headers,body,getAuthRefresh) +url = url.replace('Accounts', '{module}') + +url = url.replace('{module}', 'Deals') +upsertRecords(url,headers,body,getAuthRefresh) From 42cd394ececdea315c56d1d20ceef0501c308644 Mon Sep 17 00:00:00 2001 From: georgeotj Date: Fri, 9 Aug 2019 10:12:16 -0500 Subject: [PATCH 43/59] Fixed formatting --- Python/Zoho_CRM_API/2.0/Authentication/tokens.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Python/Zoho_CRM_API/2.0/Authentication/tokens.py b/Python/Zoho_CRM_API/2.0/Authentication/tokens.py index 5356b34..ecf92ec 100644 --- a/Python/Zoho_CRM_API/2.0/Authentication/tokens.py +++ b/Python/Zoho_CRM_API/2.0/Authentication/tokens.py @@ -2,8 +2,6 @@ import os - - # Token Files THIS_FOLDER = os.path.dirname(os.path.abspath(__file__)) grantTokenFile = os.path.join(THIS_FOLDER, 'grant_token.txt') @@ -46,4 +44,4 @@ def getRefresh (): token = f.readline() f.close() refreshToken = token - return refreshToken \ No newline at end of file + return refreshToken From 7a2e12f005ac24b8e3911d706dff956021335cf4 Mon Sep 17 00:00:00 2001 From: georgeotj Date: Fri, 9 Aug 2019 15:06:49 -0500 Subject: [PATCH 44/59] Fixed formatting --- Python/Zoho_CRM_API/2.0/getAuthRefresh.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/Python/Zoho_CRM_API/2.0/getAuthRefresh.py b/Python/Zoho_CRM_API/2.0/getAuthRefresh.py index 78de645..aba2558 100644 --- a/Python/Zoho_CRM_API/2.0/getAuthRefresh.py +++ b/Python/Zoho_CRM_API/2.0/getAuthRefresh.py @@ -9,7 +9,6 @@ import requests import json - def getAuthRefresh(): # Collect Refresh Token and Build URL url = 'https://accounts.zoho.com/oauth/v2/token?refresh_token={refresh_token}&client_id={client_id}&client_secret={client_secret}&grant_type=refresh_token' @@ -50,5 +49,4 @@ def getAuthRefresh(): # Write Token to File tokens.saveAccess(access) - token = getAuthRefresh() From 7159fb1e0560ecb02b7e178ff93236c30d784974 Mon Sep 17 00:00:00 2001 From: georgeotj Date: Fri, 9 Aug 2019 15:07:19 -0500 Subject: [PATCH 45/59] Fixed formatting --- Python/Zoho_CRM_API/2.0/Authentication/tokens.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/Python/Zoho_CRM_API/2.0/Authentication/tokens.py b/Python/Zoho_CRM_API/2.0/Authentication/tokens.py index ecf92ec..ff54531 100644 --- a/Python/Zoho_CRM_API/2.0/Authentication/tokens.py +++ b/Python/Zoho_CRM_API/2.0/Authentication/tokens.py @@ -7,9 +7,6 @@ grantTokenFile = os.path.join(THIS_FOLDER, 'grant_token.txt') accessTokenFile = os.path.join(THIS_FOLDER, 'access_token.txt') refreshTokenFile = os.path.join(THIS_FOLDER, 'refresh_token.txt') -# grantTokenFile = '2.0/Authentication/grant_token.txt' -# accessTokenFile = '2.0/Authentication/access_token.txt' -# refreshTokenFile = '2.0/Authentication/refresh_token.txt' # Save access token to file def saveAccess (token): From 0ea7dde74a49148fb69307d37665d9de3e1c411f Mon Sep 17 00:00:00 2001 From: georgeotj Date: Wed, 28 Aug 2019 09:49:12 -0500 Subject: [PATCH 46/59] Update upsertSetMockaroo.py added automatic token regeneration --- Python/Zoho_CRM_API/2.0/upsertSetMockaroo.py | 30 +++++++++++--------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/Python/Zoho_CRM_API/2.0/upsertSetMockaroo.py b/Python/Zoho_CRM_API/2.0/upsertSetMockaroo.py index c507e78..5d650ff 100644 --- a/Python/Zoho_CRM_API/2.0/upsertSetMockaroo.py +++ b/Python/Zoho_CRM_API/2.0/upsertSetMockaroo.py @@ -1,4 +1,6 @@ -import requests, json, time, urllib.request +import requests +import json +import urllib.request import getAuthRefresh from Authentication import tokens, credentials from Resources import statusCodes @@ -16,17 +18,19 @@ def upsertRecords(url, headers, body, getAuthRefresh): if (response.status_code) == 200: jsonData = json.loads(response.text) data = jsonData['data'] - print('\n---- Response ----') + print(' \n ---- Response ----') print(json.dumps(data, sort_keys=True, indent=4)) + elif (response.status_code) == 401: + print(response.status_code) + print(response.text) + runAgain = getAuthRefresh else: print(response.status_code) print(response.text) - token = getAuthRefresh - upsertRecords(url, headers, body, getAuthRefresh) # Necessary URLs -url ='https://www.zohoapis.com/crm/v2/{module}/upsert' -urlMockaroo ='https://my.api.mockaroo.com/zohopresalesmegaschema.json?key=58fd1ee0' +url = 'https://www.zohoapis.com/crm/v2/{module}/upsert' +urlMockaroo = 'https://my.api.mockaroo.com/zohopresalesmegaschema.json?key=58fd1ee0' # Reads the Mockaroo data and loads it into the file data = urllib.request.urlopen(urlMockaroo).read() @@ -40,21 +44,21 @@ def upsertRecords(url, headers, body, getAuthRefresh): # NOTE: The mockData[x] must be iterated through, still haven't been able to figure it out. body = { "data": [ - mockData[0] + mockData[0], mockData[1], mockData[2], mockData[3], mockData[4] ] } -url = url.replace('{module}', 'CustomModule1') -upsertRecords(url,headers,body,getAuthRefresh) -url = url.replace('CustomModule1', '{module}') +url = url.replace('{module}', 'Properties') +upsertRecords(url, headers, body, getAuthRefresh) +url = url.replace('Properties', '{module}') url = url.replace('{module}', 'Contacts') -upsertRecords(url,headers,body,getAuthRefresh) +upsertRecords(url, headers, body, getAuthRefresh) url = url.replace('Contacts', '{module}') url = url.replace('{module}', 'Accounts') -upsertRecords(url,headers,body,getAuthRefresh) +upsertRecords(url, headers, body, getAuthRefresh) url = url.replace('Accounts', '{module}') url = url.replace('{module}', 'Deals') -upsertRecords(url,headers,body,getAuthRefresh) +upsertRecords(url, headers, body, getAuthRefresh) From 5f81aee6d4856d4525311594dc36cb96dc6d9e5e Mon Sep 17 00:00:00 2001 From: georgeotj Date: Thu, 5 Sep 2019 10:53:15 -0500 Subject: [PATCH 47/59] Update upsertSetMockaroo.py Reorganized the API calls so that a bug does not affect the script. --- Python/Zoho_CRM_API/2.0/upsertSetMockaroo.py | 32 ++++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/Python/Zoho_CRM_API/2.0/upsertSetMockaroo.py b/Python/Zoho_CRM_API/2.0/upsertSetMockaroo.py index 5d650ff..66bf528 100644 --- a/Python/Zoho_CRM_API/2.0/upsertSetMockaroo.py +++ b/Python/Zoho_CRM_API/2.0/upsertSetMockaroo.py @@ -1,9 +1,10 @@ -import requests -import json -import urllib.request +import requests, json, urllib.request import getAuthRefresh -from Authentication import tokens, credentials -from Resources import statusCodes +from Authentication import tokens + +# Necessary URLs +url ='https://www.zohoapis.com/crm/v2/{module}/upsert' +urlMockaroo ='' def upsertRecords(url, headers, body, getAuthRefresh): # Print Input Data @@ -15,12 +16,12 @@ def upsertRecords(url, headers, body, getAuthRefresh): response = requests.post(url, headers=headers, json=body) # Print Output Data - if (response.status_code) == 200: + if response.status_code == 200: jsonData = json.loads(response.text) data = jsonData['data'] print(' \n ---- Response ----') print(json.dumps(data, sort_keys=True, indent=4)) - elif (response.status_code) == 401: + elif response.status_code == 401: print(response.status_code) print(response.text) runAgain = getAuthRefresh @@ -28,10 +29,6 @@ def upsertRecords(url, headers, body, getAuthRefresh): print(response.status_code) print(response.text) -# Necessary URLs -url = 'https://www.zohoapis.com/crm/v2/{module}/upsert' -urlMockaroo = 'https://my.api.mockaroo.com/zohopresalesmegaschema.json?key=58fd1ee0' - # Reads the Mockaroo data and loads it into the file data = urllib.request.urlopen(urlMockaroo).read() mockData = json.loads(data) @@ -44,21 +41,24 @@ def upsertRecords(url, headers, body, getAuthRefresh): # NOTE: The mockData[x] must be iterated through, still haven't been able to figure it out. body = { "data": [ - mockData[0], mockData[1], mockData[2], mockData[3], mockData[4] + mockData[0] ] } +# Upsert to the Properties module url = url.replace('{module}', 'Properties') upsertRecords(url, headers, body, getAuthRefresh) url = url.replace('Properties', '{module}') -url = url.replace('{module}', 'Contacts') -upsertRecords(url, headers, body, getAuthRefresh) -url = url.replace('Contacts', '{module}') - +# Upsert to the Accounts module url = url.replace('{module}', 'Accounts') upsertRecords(url, headers, body, getAuthRefresh) url = url.replace('Accounts', '{module}') +# Upsert to the Contacts module +url = url.replace('{module}', 'Contacts') +upsertRecords(url, headers, body, getAuthRefresh) +url = url.replace('Contacts', '{module}') + url = url.replace('{module}', 'Deals') upsertRecords(url, headers, body, getAuthRefresh) From f2435f7997fd9b94166564f44c3c042d349a5cd0 Mon Sep 17 00:00:00 2001 From: georgeotj Date: Fri, 20 Sep 2019 11:23:58 -0500 Subject: [PATCH 48/59] Update upsertSetMockaroo.py --- Python/Zoho_CRM_API/2.0/upsertSetMockaroo.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Python/Zoho_CRM_API/2.0/upsertSetMockaroo.py b/Python/Zoho_CRM_API/2.0/upsertSetMockaroo.py index 66bf528..94b4088 100644 --- a/Python/Zoho_CRM_API/2.0/upsertSetMockaroo.py +++ b/Python/Zoho_CRM_API/2.0/upsertSetMockaroo.py @@ -4,7 +4,8 @@ # Necessary URLs url ='https://www.zohoapis.com/crm/v2/{module}/upsert' -urlMockaroo ='' +urlMockaroo ='https://my.api.mockaroo.com/zohopresalesmegaschema.json?key=58fd1ee0' + def upsertRecords(url, headers, body, getAuthRefresh): # Print Input Data @@ -41,21 +42,19 @@ def upsertRecords(url, headers, body, getAuthRefresh): # NOTE: The mockData[x] must be iterated through, still haven't been able to figure it out. body = { "data": [ - mockData[0] + mockData[0], mockData[1], mockData[2], mockData[3] ] } -# Upsert to the Properties module url = url.replace('{module}', 'Properties') upsertRecords(url, headers, body, getAuthRefresh) url = url.replace('Properties', '{module}') -# Upsert to the Accounts module +# #Add the layout number to the url = url.replace('{module}', 'Accounts') upsertRecords(url, headers, body, getAuthRefresh) url = url.replace('Accounts', '{module}') -# Upsert to the Contacts module url = url.replace('{module}', 'Contacts') upsertRecords(url, headers, body, getAuthRefresh) url = url.replace('Contacts', '{module}') From e0e4cc23a07e9eaea412d6a0a47a45eab1a5ccda Mon Sep 17 00:00:00 2001 From: georgeotj Date: Fri, 20 Sep 2019 11:25:32 -0500 Subject: [PATCH 49/59] Update upsertSetMockaroo.py --- Python/Zoho_CRM_API/2.0/upsertSetMockaroo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Python/Zoho_CRM_API/2.0/upsertSetMockaroo.py b/Python/Zoho_CRM_API/2.0/upsertSetMockaroo.py index 94b4088..17ca629 100644 --- a/Python/Zoho_CRM_API/2.0/upsertSetMockaroo.py +++ b/Python/Zoho_CRM_API/2.0/upsertSetMockaroo.py @@ -4,7 +4,7 @@ # Necessary URLs url ='https://www.zohoapis.com/crm/v2/{module}/upsert' -urlMockaroo ='https://my.api.mockaroo.com/zohopresalesmegaschema.json?key=58fd1ee0' +urlMockaroo ='' def upsertRecords(url, headers, body, getAuthRefresh): From 92bd668f201242236ba959105f353ed97ac2f258 Mon Sep 17 00:00:00 2001 From: georgeotj Date: Fri, 1 Nov 2019 15:23:19 -0500 Subject: [PATCH 50/59] Create convertLeadToProspect.ds --- .../Custom Functions/convertLeadToProspect.ds | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 Deluge Functions/Custom Functions/convertLeadToProspect.ds diff --git a/Deluge Functions/Custom Functions/convertLeadToProspect.ds b/Deluge Functions/Custom Functions/convertLeadToProspect.ds new file mode 100644 index 0000000..3dcafd0 --- /dev/null +++ b/Deluge Functions/Custom Functions/convertLeadToProspect.ds @@ -0,0 +1,21 @@ +//Arguments: leadId = Lead ID +rec = zoho.crm.getRecordById("Leads1",leadId); +mp = Map(); +// Get data from the Prospect record and make a Lead record +mp.put("First_Name",rec.get("First_Name")); +mp.put("Last_Name",rec.get("Last_Name")); +mp.put("Email",rec.get("Email")); +if(rec.get("Phone_Type") == "Mobile") +{ + mp.put("Mobile",rec.get("Phone")); +} +else +{ + mp.put("Phone",rec.get("Phone")); +} +createProspect = zoho.crm.createRecord("Leads",mp); +// Delete Prospect record +deleteRecordMap = Map(); +deleteRecordMap = {"module":"Leads1","id":leadId}; +deleteResp = zoho.crm.invokeConnector("crm.delete",deleteRecordMap); +return rec; From de0a5ae7e1971c50b1723a9562f829f9f6e9a6e3 Mon Sep 17 00:00:00 2001 From: georgeotj Date: Fri, 1 Nov 2019 15:24:06 -0500 Subject: [PATCH 51/59] Rename convertLeadToProspect.ds to Convert_Lead_To_Prospect.ds --- .../{convertLeadToProspect.ds => Convert_Lead_To_Prospect.ds} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Deluge Functions/Custom Functions/{convertLeadToProspect.ds => Convert_Lead_To_Prospect.ds} (100%) diff --git a/Deluge Functions/Custom Functions/convertLeadToProspect.ds b/Deluge Functions/Custom Functions/Convert_Lead_To_Prospect.ds similarity index 100% rename from Deluge Functions/Custom Functions/convertLeadToProspect.ds rename to Deluge Functions/Custom Functions/Convert_Lead_To_Prospect.ds From 756f6a8840f0b632176799c9142ad5e47ce7f7d0 Mon Sep 17 00:00:00 2001 From: georgeotj Date: Fri, 1 Nov 2019 18:14:14 -0500 Subject: [PATCH 52/59] Update Convert_Lead_To_Prospect.ds --- .../Custom Functions/Convert_Lead_To_Prospect.ds | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Deluge Functions/Custom Functions/Convert_Lead_To_Prospect.ds b/Deluge Functions/Custom Functions/Convert_Lead_To_Prospect.ds index 3dcafd0..01f17d3 100644 --- a/Deluge Functions/Custom Functions/Convert_Lead_To_Prospect.ds +++ b/Deluge Functions/Custom Functions/Convert_Lead_To_Prospect.ds @@ -15,7 +15,7 @@ else } createProspect = zoho.crm.createRecord("Leads",mp); // Delete Prospect record -deleteRecordMap = Map(); -deleteRecordMap = {"module":"Leads1","id":leadId}; -deleteResp = zoho.crm.invokeConnector("crm.delete",deleteRecordMap); +//deleteRecordMap = Map(); +//deleteRecordMap = {"module":"Leads1","id":leadId}; +//deleteResp = zoho.crm.invokeConnector("crm.delete",deleteRecordMap); return rec; From a1c52511169d816c38839a82efba6ff1d3661f8d Mon Sep 17 00:00:00 2001 From: georgeotj Date: Mon, 4 Nov 2019 09:54:04 -0600 Subject: [PATCH 53/59] Create convert_record_to_other_module.ds --- .../Buttons/convert_record_to_other_module.ds | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 Deluge Functions/Buttons/convert_record_to_other_module.ds diff --git a/Deluge Functions/Buttons/convert_record_to_other_module.ds b/Deluge Functions/Buttons/convert_record_to_other_module.ds new file mode 100644 index 0000000..2ade32e --- /dev/null +++ b/Deluge Functions/Buttons/convert_record_to_other_module.ds @@ -0,0 +1,30 @@ +rec = zoho.crm.getRecordById("Leads",prospectId); +hasPaid = rec.get("Has_Paid"); +name = rec.get("First_Name") + " " + rec.get("Last_Name"); +totalWattage = rec.get("Wattage_Per_Panel") * rec.get("Number_of_Panels"); +mp = Map(); +if(hasPaid == true) +{ + mp.put("Name",name); + mp.put("Email",rec.get("Email")); + mp.put("First_Name",rec.get("First_Name")); + mp.put("Last_Name",rec.get("Last_Name")); + mp.put("Phone",rec.get("Phone")); + mp.put("Mobile",rec.get("Mobile")); + mp.put("Email",rec.get("Email")); + mp.put("Installation_Address",rec.get("Installation_Address")); + mp.put("Installation_City",rec.get("Installation_City")); + mp.put("Installation_State",rec.get("Installation_State")); + mp.put("Installation_Zip_Code",rec.get("Installation_Zip_Code")); + mp.put("Number_of_Panels",rec.get("Number_of_Panels")); + mp.put("Wattage_Per_Panel",rec.get("Wattage_Per_Panel")); + mp.put("Installation_Zip_Code",rec.get("Installation_Zip_Code")); + mp.put("Total_Wattage",totalWattage.toString()); + createClient = zoho.crm.createRecord("Clients",mp); + result = "Success!"; +} +else +{ + result = "ERROR: Prospect has not paid or \"Has Paid\" field hasn't been updated. Please verify these requirements have been met."; +} +return result; From d924224e89dab9c7fa17dec17c44e95e6e9521ef Mon Sep 17 00:00:00 2001 From: georgeotj Date: Mon, 4 Nov 2019 10:40:22 -0600 Subject: [PATCH 54/59] Update convert_record_to_other_module.ds --- Deluge Functions/Buttons/convert_record_to_other_module.ds | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Deluge Functions/Buttons/convert_record_to_other_module.ds b/Deluge Functions/Buttons/convert_record_to_other_module.ds index 2ade32e..0668eb7 100644 --- a/Deluge Functions/Buttons/convert_record_to_other_module.ds +++ b/Deluge Functions/Buttons/convert_record_to_other_module.ds @@ -22,9 +22,15 @@ if(hasPaid == true) mp.put("Total_Wattage",totalWattage.toString()); createClient = zoho.crm.createRecord("Clients",mp); result = "Success!"; + + //Delete Record + //deleteRecordMap = Map(); + //deleteRecordMap = {"module":"{module}","id":prospectId}; + //deleteResp = zoho.crm.invokeConnector("crm.delete",deleteRecordMap); } else { result = "ERROR: Prospect has not paid or \"Has Paid\" field hasn't been updated. Please verify these requirements have been met."; } + return result; From a0f3e41477ecdecb1c83f0aada61f4342b58121b Mon Sep 17 00:00:00 2001 From: georgeotj Date: Mon, 4 Nov 2019 11:26:52 -0600 Subject: [PATCH 55/59] Update convert_record_to_other_module.ds --- .../Buttons/convert_record_to_other_module.ds | 25 +++++++++++++++---- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/Deluge Functions/Buttons/convert_record_to_other_module.ds b/Deluge Functions/Buttons/convert_record_to_other_module.ds index 0668eb7..c571c83 100644 --- a/Deluge Functions/Buttons/convert_record_to_other_module.ds +++ b/Deluge Functions/Buttons/convert_record_to_other_module.ds @@ -1,10 +1,24 @@ -rec = zoho.crm.getRecordById("Leads",prospectId); -hasPaid = rec.get("Has_Paid"); +//Anything within curly brackets will need to be replaced to the correct module, field, or variable. + +// This variable will be important to get the specific fields within the record. +rec = zoho.crm.getRecordById({module},{argumentId}); + +// These variables are used to simplify getting field information name = rec.get("First_Name") + " " + rec.get("Last_Name"); totalWattage = rec.get("Wattage_Per_Panel") * rec.get("Number_of_Panels"); + +// A temporary map is created to store the data from the original record. mp = Map(); -if(hasPaid == true) + +//This if-statement verifies that the user has paid using a field. If the field is selected, it will return true and will +//allow you to convert the record. However, if the field is not selected it will give you an error. +if(rec.get("Has_Paid") == true) { + // These statements follow the format mp.put({fieldInNewModule}, {fieldInOriginalModule}); + // For example in the instructions below, the statement will put the value name from line 7 + // into the keyword "Name". These keys are stored into the map and will then be used to create + // the record in line 37. + mp.put("Name",name); mp.put("Email",rec.get("Email")); mp.put("First_Name",rec.get("First_Name")); @@ -23,14 +37,15 @@ if(hasPaid == true) createClient = zoho.crm.createRecord("Clients",mp); result = "Success!"; + // If you would like to delete the record after it is converted you can uncomment out lines 43-45 by + // removing the double forward slash. //Delete Record //deleteRecordMap = Map(); - //deleteRecordMap = {"module":"{module}","id":prospectId}; + //deleteRecordMap = {"module":"{module}","id":argumentId}; //deleteResp = zoho.crm.invokeConnector("crm.delete",deleteRecordMap); } else { result = "ERROR: Prospect has not paid or \"Has Paid\" field hasn't been updated. Please verify these requirements have been met."; } - return result; From efc2ba0a8725f7af4fef0b31e0ef97177dee411e Mon Sep 17 00:00:00 2001 From: georgeotj Date: Tue, 5 Nov 2019 09:46:34 -0600 Subject: [PATCH 56/59] Update convert_record_to_other_module.ds --- Deluge Functions/Buttons/convert_record_to_other_module.ds | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Deluge Functions/Buttons/convert_record_to_other_module.ds b/Deluge Functions/Buttons/convert_record_to_other_module.ds index c571c83..4d896b6 100644 --- a/Deluge Functions/Buttons/convert_record_to_other_module.ds +++ b/Deluge Functions/Buttons/convert_record_to_other_module.ds @@ -10,8 +10,9 @@ totalWattage = rec.get("Wattage_Per_Panel") * rec.get("Number_of_Panels"); // A temporary map is created to store the data from the original record. mp = Map(); -//This if-statement verifies that the user has paid using a field. If the field is selected, it will return true and will -//allow you to convert the record. However, if the field is not selected it will give you an error. +// This if-statement verifies that the user has paid using a field. If the field is selected, it will return true and will +// allow you to convert the record. However, if the field is not selected it will give you an error. + if(rec.get("Has_Paid") == true) { // These statements follow the format mp.put({fieldInNewModule}, {fieldInOriginalModule}); From ead1eebc62c92e3d995ee97495b9cc55b07b302c Mon Sep 17 00:00:00 2001 From: georgeotj Date: Thu, 19 Dec 2019 16:15:22 -0600 Subject: [PATCH 57/59] Create iterate_through_multiselect_lookupfield.ds --- ...iterate_through_multiselect_lookupfield.ds | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 Deluge Functions/Custom Functions/iterate_through_multiselect_lookupfield.ds diff --git a/Deluge Functions/Custom Functions/iterate_through_multiselect_lookupfield.ds b/Deluge Functions/Custom Functions/iterate_through_multiselect_lookupfield.ds new file mode 100644 index 0000000..1861103 --- /dev/null +++ b/Deluge Functions/Custom Functions/iterate_through_multiselect_lookupfield.ds @@ -0,0 +1,23 @@ + +serverList = zoho.crm.getRelatedRecords("Servers13","Contacts",contid); +listcount = 1; +counter = {0,1,2,3,4,5,6,7,8,9,10}; +listSize = serverList.size(); +for each x in counter +{ + count = x + 1; + if(x < listSize) + { + server = serverList.get(x); + serverInfo = server.get("Servers"); + serverid = serverInfo.get("id"); + url = "https://crm.zoho.com/crm/org672017945/tab/CustomModule1/" + serverid; + update = zoho.crm.updateRecord("Contacts",contid,{"Server" + count:url}); + listcount = listcount + 1; + } + else + { + update = zoho.crm.updateRecord("Contacts",contid,{"Server" + count:""}); + info "removed"; + } +} From c8c0c4b02f353a4477cf8e74b51af7d8a3208597 Mon Sep 17 00:00:00 2001 From: georgeotj Date: Mon, 3 Feb 2020 09:34:57 -0600 Subject: [PATCH 58/59] Create Creating_Sales_Order_For_Zoho_Books_From_Zoho_CRM.ds --- ...ales_Order_For_Zoho_Books_From_Zoho_CRM.ds | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 Deluge Functions/Custom Functions/Creating_Sales_Order_For_Zoho_Books_From_Zoho_CRM.ds diff --git a/Deluge Functions/Custom Functions/Creating_Sales_Order_For_Zoho_Books_From_Zoho_CRM.ds b/Deluge Functions/Custom Functions/Creating_Sales_Order_For_Zoho_Books_From_Zoho_CRM.ds new file mode 100644 index 0000000..a4c9eb6 --- /dev/null +++ b/Deluge Functions/Custom Functions/Creating_Sales_Order_For_Zoho_Books_From_Zoho_CRM.ds @@ -0,0 +1,25 @@ +sOrderObj = zoho.crm.getRecordById("Sales_Orders", id); +crmSOProductLst = sOrderObj.get("Product_Details"); +crmContactId = ifnull(sOrderObj.get("Contact_Name"),{"id", null}).get("id"); +crmAccountId = ifnull(sOrderObj.get("Account_Name"),{"id", null}).get("id"); +prodList=List(); +for each product in crmSOProductLst +{ + pId = product.get("product").get("id"); + quantity = product.get("quantity"); + listPrice = product.get("list_price").toDecimal(); + zbPId = zoho.books.getRecords("Items", "668072369","zcrm_product_id="+pId).get("items").get(0).get("item_id"); + prodmp = map(); + prodmp.put("item_id",zbPId); + prodmp.put("rate",listPrice); + prodmp.put("quantity",quantity); + prodList.add(prodmp); +} +customerid = zoho.books.getRecords("Contacts", "668072369","zcrm_account_id="+crmAccountId).get("contacts").get(0).get("contact_id"); +mp = map(); +mp.put("customer_id",customerid); +mp.put("line_items",prodList); +mp.put("date",today); +mp.put("custom_fields", [{"label": "Third Party Cleaned", "value": sOrderObj.get(“Cleaned_By_Joe”)},{"label":"Con Note No", "value": sOrderObj.get(“Consignment_Note_Number”)},{“label":"DATE INVOICE SENT", "value": sOrderObj.get(“DATE_INVOICE_SENT”)},{“label":"Delivery Terms", "value": sOrderObj.get(“Delivery_Terms”)},{“label":"Shipment Date", "value": sOrderObj.get(“Ready_For_Despatch_Date”)},{“label":"Freight Company", "value": sOrderObj.get(“Freight_Company_Out”)},{“label":"Freight Company", "value": sOrderObj.get(“Freight_Company_Out”)},{“label":"Payment Received Date", "value": sOrderObj.get(“Payment_Received_Date”)},{“label":"PO Received Date", "value": sOrderObj.get(“PO_Received_Date”)},{“label":"Sales Order#", "value": sOrderObj.get(“Project_Quote_Number”)},{“label":"PO Number", "value": sOrderObj.get(“Purchase_Order”)},{“label":"Quote Category", "value": sOrderObj.get(“Quote_Category”)},{“label":"Sales Order Type", "value": sOrderObj.get(“Sales_Order_Type”)},{“label":"Status", "value": sOrderObj.get(“Status”)},{“label":"Subject", "value": sOrderObj.get(“Subject”)}]); +createSoInZBRes = zoho.books.createRecord("SalesOrders","668072369", mp); +info createSoInZBRes; From 3f65fddeed8573bab8b2ad91ac1b215f5845c5a6 Mon Sep 17 00:00:00 2001 From: georgeotj Date: Mon, 24 Feb 2020 10:30:11 -0600 Subject: [PATCH 59/59] Create Show_Related_Addresses_Of_Account.ds Part of an extended project to make a dynamic form that isn't normally supported in the CRM so it was made in Creator with allows for more freedom for the user. --- .../Show_Related_Addresses_Of_Account.ds | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 Deluge Functions/Custom Functions/Show_Related_Addresses_Of_Account.ds diff --git a/Deluge Functions/Custom Functions/Show_Related_Addresses_Of_Account.ds b/Deluge Functions/Custom Functions/Show_Related_Addresses_Of_Account.ds new file mode 100644 index 0000000..1d1adaf --- /dev/null +++ b/Deluge Functions/Custom Functions/Show_Related_Addresses_Of_Account.ds @@ -0,0 +1,15 @@ +// Author: georgeotj +// Description: When your CRM has a lot of customers with different shipping addresses, managing them could become a pain. Using this, a user can create a Zoho Creator application that will allow the user to modify a Creator form that would easily change the shipping address depending on which Account the user selects. +// Requirements: Several modifications are required for this script to run correctly, this includes creating a new module and related list. +// Arguments: N/A + +// Declare variables +accountId = input.Account_Name.toLong(); +relRecs = zoho.crm.getRelatedRecords("Associated_Shipping_Location","Accounts",accountId); + +// Code +clear Shipping_Address; +for each rec in relRecs +{ + input.Shipping_Address:ui.add(rec.get("Name")); +}