Pretty self-explanatory really. Something to be cautious about but it took me so long to do that I needed an article here to help me if ever I get asked to do it again. Siimply put, Zoho Analytics can't see the Zoho People Salary table within the built-in integration / synchronization.
Why?
My use-case is for a client who has over 1200 employees but similar to performance goals, we need to write code to push the salary data out to a Zoho Analytics table.
How?
Sounds like you could just do as we did with the P_Goals table but I need this to run every night picking up salary changes as well. I don't want to use up 1200+ API calls either to do it which my script for performance goals did. The below will do it with 7 calls (to get 7 pages of 200 records) and 1 call to push into Zoho Analytics...
Create the Zoho Analytics table
You can do this any way you find best but this is how I do it as quick as I can:
- Create a blank Excel file / spreadsheet / csv
- Give it the headings: ID,Employee ID,Effective From,Currency,Amount Per Annum,Created Time,Modified Time,Created By,Modified By,Pay Schedule
- Enter sample data in the first 2 columns of the 2nd row to convince Analytics there is some data in the table we are going to import.
- I'm going to save this file as Zoho_Analytics_Salaries.xlsx
- Login to Zoho Analytics and browse to your Zoho People workspace
- Click the big plus icon in the left sidebar at the top, then click on New Table / Import Data
- Select "Files" (has the icon of MS Excel on it)
- Give it a table name. I've used my creative mind and gone with Salary
- File Type I said was Excel and then clicked on "Choose File" (with data location set to "Local Drive")
- Click on Next, have a quick glance of the preview and then click on Next
- First row contains column names = Yes, leave everything else as plain text except for Description which you should change to a Multi Line Text.
- Click on Create.
A few more things to configure
- Get the ZohoAnalytics Org ID:
- Login to ZohoAnalytics and ensure you are at the "Home" level
- Click on the cog icon in the top-right for "Settings"
- You should be in the "Organization Settings"
- Your Org ID is in the URL as the last number after the slash /org-details/###### (eg. "123456789")
- Note this down for later use
- Create a connection to Zoho Analytics:
- Above the function in Zoho People > Connections > Create Connection
- Select Zoho Analytics and give the required scopes. We need ZohoAnalytics.data.create (I've cheated and gone for ZohoAnalytics.fullaccess.all)
- Note the connection link name (mine is called "zanalytics")
Schedule the function (for Zoho People v5)
- Login to Zoho People as an Administrator
- Click on the cog icon in the top right to go to Settings
- Click on "Employee Information"
- Click on "Automation"
- Expand "Schedulers"
- "Add Custom Scheduler"
- I'm calling mine "Scheduled Salary Sync"
- It will run at 01:00 AM starting from tomorrow.
- I set the Frequency to "Daily"
- And gave it the code below
- Save
the Code
copyraw
/* *******************************************************************************
Function: void Check_for_Salary()
Label: Fn - Push Salary Data to Analytics
Trigger: Workflow when an objective is created or edited.
Purpose: Pushes the data and columns we need to Zoho Analytics to produce an Objectives report with the requested columns.
Inputs: int p_RecordID
Outputs: -
Date Created: 2026-03-26 (Joel Lipman)
- Initial release
Date Modified: ???
- ???
https://www.zoho.com/people/api/compensation/fetch_salary.html
https://www.zoho.com/analytics/api/v2/bulk-api/import-data/existing-table.html
******************************************************************************* */
//
// init
v_StartIndex = 1;
v_CountTotal = 0;
l_ColumnsData = List();
l_Pages = {1,2,3,4,5,6,7};
//
v_Headings = "ID,Employee ID,Effective From,Currency,Amount Per Annum,Created Time,Modified Time,Created By,Modified By,Pay Schedule";
l_CsvRows.add(v_Headings.toList().toString());
//
// the zoho analytics org ID noted earlier
v_AnalyticsOrgID = "123456879";
//
// in analytics, browse to the target table and note the URL IDs after workspace and view
v_WorkspaceID = "1234567000008912345";
v_ViewID = "9876543000002198765";
//
// loop through all employees, this will do 1400
for each v_Page in l_Pages
{
//
// query goals endpoint
v_Endpoint_Salary = "https://people.zoho.com/api/compensation/v1/salary?mode=all&startIndex=" + v_StartIndex;
r_SalaryData = invokeurl
[
url :v_Endpoint_Salary
type :GET
connection:"zpeople"
];
//info r_SalaryData;
//
// parse the response loop through each record returned
m_SalaryResponse = ifnull(r_SalaryData.get("response"),Map());
l_SalaryRecords = ifnull(m_SalaryResponse.get("result"),List());
for each m_SalaryRecord in l_SalaryRecords
{
//
// start an increment for counting the records processed
v_CountTotal = v_CountTotal + 1;
v_StartIndex = v_StartIndex + 1;
m_ColumnsData = Map();
//
// date transform
v_DateTransform = ifnull(m_SalaryRecord.get("Effective_From"),zoho.currentdate.toString("dd-MMM-yyyy"));
m_DateMonthMap = {"Jan":"01","Feb":"02","Mar":"03","Apr":"04","May":"05","Jun":"06","Jul":"07","Aug":"08","Sep":"09","Oct":"10","Nov":"11","Dec":"12"};
l_DateEffectiveFromParts = v_DateTransform.toList("-");
v_SqlDate = if(l_DateEffectiveFromParts.size() > 1,l_DateEffectiveFromParts.get(2) + "-" + m_DateMonthMap.get(l_DateEffectiveFromParts.get(1)) + "-" + l_DateEffectiveFromParts.get(0),null);
//
// v2: data
m_ColumnsData.put("ID",m_SalaryRecord.get("Salary_Id"));
m_ColumnsData.put("Employee ID",m_SalaryRecord.get("Erecno"));
m_ColumnsData.put("Effective From",v_SqlDate);
m_ColumnsData.put("Currency",m_SalaryRecord.get("Currency"));
m_ColumnsData.put("Amount Per Annum",m_SalaryRecord.get("CTC"));
m_ColumnsData.put("Created Time",zoho.currenttime.toString("yyyy-MM-dd HH:mm:ss"));
m_ColumnsData.put("Modified Time",zoho.currenttime.toString("yyyy-MM-dd HH:mm:ss"));
m_ColumnsData.put("Pay Schedule",m_SalaryRecord.get("Pay_Schedule"));
l_ColumnsData.add(m_ColumnsData);
}
}
//
// authorisation header
m_Header = Map();
m_Header.put("ZANALYTICS-ORGID",v_AnalyticsOrgID);
//
// v2 config
m_Config = Map();
m_Config.put("importType","updateadd");
m_Config.put("fileType","json");
m_Config.put("autoIdentify","true");
// update on key
m_Config.put("matchingColumns",{"ID"});
//
// v2 data
m_Params = Map();
m_Params.put("CONFIG",m_Config.toString());
m_Params.put("DATA",l_ColumnsData);
//
v_Endpoint_v2 = "https://analyticsapi.zoho.com/restapi/v2/workspaces/" + v_WorkspaceID + "/views/" + v_ViewID + "/data";
info v_Endpoint_v2;
//
r_FileUpload = invokeurl
[
url :v_Endpoint_v2
type :POST
parameters:m_Params
headers:m_Header
connection:"abanalytics"
];
info r_FileUpload;
//
info "Processed " + v_CountTotal + " record(s)";
- /* *******************************************************************************
- Function: void Check_for_Salary()
- Label: Fn - Push Salary Data to Analytics
- Trigger: Workflow when an objective is created or edited.
- Purpose: Pushes the data and columns we need to Zoho Analytics to produce an Objectives report with the requested columns.
- Inputs: int p_RecordID
- Outputs: -
- Date Created: 2026-03-26 (Joel Lipman)
- - Initial release
- Date Modified: ???
- - ???
- https://www.zoho.com/people/api/compensation/fetch_salary.html
- https://www.zoho.com/analytics/api/v2/bulk-api/import-data/existing-table.html
- ******************************************************************************* */
- //
- // init
- v_StartIndex = 1;
- v_CountTotal = 0;
- l_ColumnsData = List();
- l_Pages = {1,2,3,4,5,6,7};
- //
- v_Headings = "ID,Employee ID,Effective From,Currency,Amount Per Annum,Created Time,Modified Time,Created By,Modified By,Pay Schedule";
- l_CsvRows.add(v_Headings.toList().toString());
- //
- // the zoho analytics org ID noted earlier
- v_AnalyticsOrgID = "123456879";
- //
- // in analytics, browse to the target table and note the URL IDs after workspace and view
- v_WorkspaceID = "1234567000008912345";
- v_ViewID = "9876543000002198765";
- //
- // loop through all employees, this will do 1400
- for each v_Page in l_Pages
- {
- //
- // query goals endpoint
- v_Endpoint_Salary = "https://people.zoho.com/api/compensation/v1/salary?mode=all&startIndex=" + v_StartIndex;
- r_SalaryData = invokeurl
- [
- url :v_Endpoint_Salary
- type :GET
- connection:"zpeople"
- ];
- //info r_SalaryData;
- //
- // parse the response loop through each record returned
- m_SalaryResponse = ifnull(r_SalaryData.get("response"),Map());
- l_SalaryRecords = ifnull(m_SalaryResponse.get("result"),List());
- for each m_SalaryRecord in l_SalaryRecords
- {
- //
- // start an increment for counting the records processed
- v_CountTotal = v_CountTotal + 1;
- v_StartIndex = v_StartIndex + 1;
- m_ColumnsData = Map();
- //
- // date transform
- v_DateTransform = ifnull(m_SalaryRecord.get("Effective_From"),zoho.currentdate.toString("dd-MMM-yyyy"));
- m_DateMonthMap = {"Jan":"01","Feb":"02","Mar":"03","Apr":"04","May":"05","Jun":"06","Jul":"07","Aug":"08","Sep":"09","Oct":"10","Nov":"11","Dec":"12"};
- l_DateEffectiveFromParts = v_DateTransform.toList("-");
- v_SqlDate = if(l_DateEffectiveFromParts.size() > 1,l_DateEffectiveFromParts.get(2) + "-" + m_DateMonthMap.get(l_DateEffectiveFromParts.get(1)) + "-" + l_DateEffectiveFromParts.get(0),null);
- //
- // v2: data
- m_ColumnsData.put("ID",m_SalaryRecord.get("Salary_Id"));
- m_ColumnsData.put("Employee ID",m_SalaryRecord.get("Erecno"));
- m_ColumnsData.put("Effective From",v_SqlDate);
- m_ColumnsData.put("Currency",m_SalaryRecord.get("Currency"));
- m_ColumnsData.put("Amount Per Annum",m_SalaryRecord.get("CTC"));
- m_ColumnsData.put("Created Time",zoho.currenttime.toString("yyyy-MM-dd HH:mm:ss"));
- m_ColumnsData.put("Modified Time",zoho.currenttime.toString("yyyy-MM-dd HH:mm:ss"));
- m_ColumnsData.put("Pay Schedule",m_SalaryRecord.get("Pay_Schedule"));
- l_ColumnsData.add(m_ColumnsData);
- }
- }
- //
- // authorisation header
- m_Header = Map();
- m_Header.put("ZANALYTICS-ORGID",v_AnalyticsOrgID);
- //
- // v2 config
- m_Config = Map();
- m_Config.put("importType","updateadd");
- m_Config.put("fileType","json");
- m_Config.put("autoIdentify","true");
- // update on key
- m_Config.put("matchingColumns",{"ID"});
- //
- // v2 data
- m_Params = Map();
- m_Params.put("CONFIG",m_Config.toString());
- m_Params.put("DATA",l_ColumnsData);
- //
- v_Endpoint_v2 = "https://analyticsapi.zoho.com/restapi/v2/workspaces/" + v_WorkspaceID + "/views/" + v_ViewID + "/data";
- info v_Endpoint_v2;
- //
- r_FileUpload = invokeurl
- [
- url :v_Endpoint_v2
- type :POST
- parameters:m_Params
- headers:m_Header
- connection:"abanalytics"
- ];
- info r_FileUpload;
- //
- info "Processed " + v_CountTotal + " record(s)";
Error(s) Encountered
- copyrawI tried uploading a CSV to Zoho Analytics... Specifically the "file" attribute in the invokeUrl... I spent too long but thought I could send DATA instead of FILE. At time of print, the official documentation didn't document how to do this. So I found this way to do it as long as it remained in JSON as well.
{ "status": "failure", "summary": "COMMON_INTERNAL_SERVER_ERROR", "data": { "errorCode": 7005, "errorMessage": "Sorry, an unexpected error occurred when performing this operation. The error has been logged and will be looked into.\n\nIt would be of great help if you could provide us with additional information using the ''Feedback'' link." } }- {
- "status": "failure",
- "summary": "COMMON_INTERNAL_SERVER_ERROR",
- "data": {
- "errorCode": 7005,
- "errorMessage": "Sorry, an unexpected error occurred when performing this operation. The error has been logged and will be looked into.\n\nIt would be of great help if you could provide us with additional information using the ''Feedback'' link."
- }
- }
Caveat(s)
- Created Time will always be the time when updating as well... haven't found a way around this as I would need to check if the record exists in Zoho Analytics before updating it... This would use up more API calls then I'd care to.
Scrap Notes - Not used for the above but things I tried and didn't go anywhere
copyraw
/* *******************************************************************************
Function: void Check_for_Salary()
Label: Fn - Push Salary Data to Analytics
Trigger: Workflow when an objective is created or edited.
Purpose: Pushes the data and columns we need to Zoho Analytics to produce an Objectives report with the requested columns.
Inputs: int p_RecordID
Outputs: -
Date Created: 2026-03-26 (Joel Lipman)
- Initial release
Date Modified: ???
- ???
https://www.zoho.com/people/api/compensation/fetch_salary.html
https://www.zoho.com/analytics/api/v2/bulk-api/import-data/existing-table.html
******************************************************************************* */
//
// init
v_StartIndex = 1;
v_CountTotal = 0;
l_CsvRows = List();
l_ColumnsData = List();
l_Pages = {1,2,3,4,5,6,7};
//
v_Headings = "ID,Employee ID,Effective From,Currency,Amount Per Annum,Created Time,Modified Time,Created By,Modified By,Pay Schedule";
l_CsvRows.add(v_Headings.toList().toString());
//
// the zoho analytics org ID noted earlier
v_AnalyticsOrgID = "123456879";
//
// in analytics, browse to the target table and note the URL IDs after workspace and view
v_WorkspaceID = "1234567000008912345";
v_ViewID = "9876543000002198765";
//
// loop through all employees, this will do 1400
for each v_Page in l_Pages
{
//
// query goals endpoint
v_Endpoint_Salary = "https://people.zoho.com/api/compensation/v1/salary?mode=all&startIndex=" + v_StartIndex;
r_SalaryData = invokeurl
[
url :v_Endpoint_Salary
type :GET
connection:"zpeople"
];
//info r_SalaryData;
//
// parse the response loop through each record returned
m_SalaryResponse = ifnull(r_SalaryData.get("response"),Map());
l_SalaryRecords = ifnull(m_SalaryResponse.get("result"),List());
for each m_SalaryRecord in l_SalaryRecords
{
//
// start an increment for counting the records processed
v_CountTotal = v_CountTotal + 1;
v_StartIndex = v_StartIndex + 1;
l_CsvRow = List();
m_ColumnsData = Map();
//
// v2: file
l_CsvRow.add("\"" + m_SalaryRecord.get("Salary_Id") + "\"");
l_CsvRow.add("\"" + m_SalaryRecord.get("Erecno") + "\"");
//
// date transform
v_DateTransform = ifnull(m_SalaryRecord.get("Effective_From"),zoho.currentdate.toString("dd-MMM-yyyy"));
m_DateMonthMap = {"Jan":"01","Feb":"02","Mar":"03","Apr":"04","May":"05","Jun":"06","Jul":"07","Aug":"08","Sep":"09","Oct":"10","Nov":"11","Dec":"12"};
l_DateEffectiveFromParts = v_DateTransform.toList("-");
v_SqlDate = if(l_DateEffectiveFromParts.size() > 1,l_DateEffectiveFromParts.get(2) + "-" + m_DateMonthMap.get(l_DateEffectiveFromParts.get(1)) + "-" + l_DateEffectiveFromParts.get(0),null);
l_CsvRow.add(v_SqlDate);
//
// other fields
l_CsvRow.add(m_SalaryRecord.get("Currency"));
l_CsvRow.add(m_SalaryRecord.get("CTC"));
l_CsvRow.add(zoho.currenttime.toString("yyyy-MM-dd HH:mm:ss"));
l_CsvRow.add(zoho.currenttime.toString("yyyy-MM-dd HH:mm:ss"));
l_CsvRow.add(null);
l_CsvRow.add(null);
l_CsvRow.add(m_SalaryRecord.get("Pay_Schedule"));
l_CsvRows.add(l_CsvRow.toString());
//
// v2: data
m_ColumnsData.put("ID",m_SalaryRecord.get("Salary_Id"));
m_ColumnsData.put("Employee ID",m_SalaryRecord.get("Salary_Id"));
m_ColumnsData.put("Effective From",v_SqlDate);
m_ColumnsData.put("Currency",m_SalaryRecord.get("Currency"));
m_ColumnsData.put("Amount Per Annum",m_SalaryRecord.get("CTC"));
m_ColumnsData.put("Created Time",zoho.currenttime.toString("yyyy-MM-dd HH:mm:ss"));
m_ColumnsData.put("Modified Time",zoho.currenttime.toString("yyyy-MM-dd HH:mm:ss"));
m_ColumnsData.put("Pay Schedule",m_SalaryRecord.get("Pay_Schedule"));
l_ColumnsData.add(m_ColumnsData);
}
}
//
//
// generate a CSV
v_NewLine = hexToText("0A");
f_SalariesCSV = l_CsvRows.toString(v_NewLine).toFile("Salaries.csv");
f_SalariesCSV.setParamName("file");
/*
m_Config.put("dateFormat","yyyy-MM-dd");
m_Config.put("onError","setcolumnempty");
m_Config.put("skipTop",1);
*/
//v_Params = "CONFIG=" + zoho.encryption.urlEncode(m_Config.toString());
//
//
/*
// COMMON PARAMS
m_Params = Map();
m_Params.put("ZOHO_ACTION","IMPORT");
m_Params.put("ZOHO_OUTPUT_FORMAT","JSON");
m_Params.put("ZOHO_ERROR_FORMAT","JSON");
m_Params.put("ZOHO_API_VERSION","1.0");
// ACTION SPECIFIC PARAMS
m_Params.put("ZOHO_IMPORT_TYPE","UPDATEADD");
m_Params.put("ZOHO_AUTO_IDENTIFY","TRUE");
m_Params.put("ZOHO_ON_IMPORT_ERROR","SETCOLUMNEMPTY");
m_Params.put("ZOHO_CREATE_TABLE","FALSE");
//
//
*/
/*
r_SalariesCSV = invokeurl
[
url: "https://test.com/tmp/salaries.csv"
type: GET
];
f_SalariesCSV = r_SalariesCSV.toFile("Salaries.csv");
f_SalariesCSV.setParamName("file");
//
v_QueryParam = "";
l_Keys = m_Params.keys();
for each v_Key in l_Keys
{
v_QueryParam = v_QueryParam + "&" + v_Key + "=" + m_Params.get(v_Key);
}
//
*/
//
//
/*
v_OwnerEmail = zoho.encryption.urlEncode("the_super_admin_email");
v_WorkspaceName = zoho.encryption.urlEncode("Zoho People Analytics");
v_ViewName = zoho.encryption.urlEncode("Test");
v_Endpoint_v1 = "https://analyticsapi.zoho.com/api/" + v_OwnerEmail + "/" + v_WorkspaceName + "/" + v_ViewName + "?" + v_QueryParam.getSuffix("&");
//info v_Endpoint_v1;
*/
//
// authorisation header
m_Header = Map();
//m_Header.put("Content-Type","multipart/form-data");
m_Header.put("ZANALYTICS-ORGID",v_AnalyticsOrgID);
//info m_Header;
//
// v2 config
m_Config = Map();
m_Config.put("importType","updateadd");
m_Config.put("fileType","json");
m_Config.put("autoIdentify","true");
// update on key
m_Config.put("matchingColumns",{"ID"});
//
// v2 data
m_Params = Map();
m_Params.put("CONFIG",m_Config.toString());
m_Params.put("DATA",l_ColumnsData);
//
v_Endpoint_v2 = "https://analyticsapi.zoho.com/restapi/v2/workspaces/" + v_WorkspaceID + "/views/" + v_ViewID + "/data";
info v_Endpoint_v2;
//
r_FileUpload = invokeurl
[
url :v_Endpoint_v2
type :POST
parameters:m_Params
headers:m_Header
connection:"zanalytics"
];
info r_FileUpload;
//
sendmail
[
from :zoho.adminuserid
to :"moi"
subject :"DEBUGGING - Salary File - TO BE PERMANENTLY DELETED"
message :m_Config
Attachments :file:f_SalariesCSV
]
//
info "Processed " + v_CountTotal + " record(s)";
- /* *******************************************************************************
- Function: void Check_for_Salary()
- Label: Fn - Push Salary Data to Analytics
- Trigger: Workflow when an objective is created or edited.
- Purpose: Pushes the data and columns we need to Zoho Analytics to produce an Objectives report with the requested columns.
- Inputs: int p_RecordID
- Outputs: -
- Date Created: 2026-03-26 (Joel Lipman)
- - Initial release
- Date Modified: ???
- - ???
- https://www.zoho.com/people/api/compensation/fetch_salary.html
- https://www.zoho.com/analytics/api/v2/bulk-api/import-data/existing-table.html
- ******************************************************************************* */
- //
- // init
- v_StartIndex = 1;
- v_CountTotal = 0;
- l_CsvRows = List();
- l_ColumnsData = List();
- l_Pages = {1,2,3,4,5,6,7};
- //
- v_Headings = "ID,Employee ID,Effective From,Currency,Amount Per Annum,Created Time,Modified Time,Created By,Modified By,Pay Schedule";
- l_CsvRows.add(v_Headings.toList().toString());
- //
- // the zoho analytics org ID noted earlier
- v_AnalyticsOrgID = "123456879";
- //
- // in analytics, browse to the target table and note the URL IDs after workspace and view
- v_WorkspaceID = "1234567000008912345";
- v_ViewID = "9876543000002198765";
- //
- // loop through all employees, this will do 1400
- for each v_Page in l_Pages
- {
- //
- // query goals endpoint
- v_Endpoint_Salary = "https://people.zoho.com/api/compensation/v1/salary?mode=all&startIndex=" + v_StartIndex;
- r_SalaryData = invokeurl
- [
- url :v_Endpoint_Salary
- type :GET
- connection:"zpeople"
- ];
- //info r_SalaryData;
- //
- // parse the response loop through each record returned
- m_SalaryResponse = ifnull(r_SalaryData.get("response"),Map());
- l_SalaryRecords = ifnull(m_SalaryResponse.get("result"),List());
- for each m_SalaryRecord in l_SalaryRecords
- {
- //
- // start an increment for counting the records processed
- v_CountTotal = v_CountTotal + 1;
- v_StartIndex = v_StartIndex + 1;
- l_CsvRow = List();
- m_ColumnsData = Map();
- //
- // v2: file
- l_CsvRow.add("\"" + m_SalaryRecord.get("Salary_Id") + "\"");
- l_CsvRow.add("\"" + m_SalaryRecord.get("Erecno") + "\"");
- //
- // date transform
- v_DateTransform = ifnull(m_SalaryRecord.get("Effective_From"),zoho.currentdate.toString("dd-MMM-yyyy"));
- m_DateMonthMap = {"Jan":"01","Feb":"02","Mar":"03","Apr":"04","May":"05","Jun":"06","Jul":"07","Aug":"08","Sep":"09","Oct":"10","Nov":"11","Dec":"12"};
- l_DateEffectiveFromParts = v_DateTransform.toList("-");
- v_SqlDate = if(l_DateEffectiveFromParts.size() > 1,l_DateEffectiveFromParts.get(2) + "-" + m_DateMonthMap.get(l_DateEffectiveFromParts.get(1)) + "-" + l_DateEffectiveFromParts.get(0),null);
- l_CsvRow.add(v_SqlDate);
- //
- // other fields
- l_CsvRow.add(m_SalaryRecord.get("Currency"));
- l_CsvRow.add(m_SalaryRecord.get("CTC"));
- l_CsvRow.add(zoho.currenttime.toString("yyyy-MM-dd HH:mm:ss"));
- l_CsvRow.add(zoho.currenttime.toString("yyyy-MM-dd HH:mm:ss"));
- l_CsvRow.add(null);
- l_CsvRow.add(null);
- l_CsvRow.add(m_SalaryRecord.get("Pay_Schedule"));
- l_CsvRows.add(l_CsvRow.toString());
- //
- // v2: data
- m_ColumnsData.put("ID",m_SalaryRecord.get("Salary_Id"));
- m_ColumnsData.put("Employee ID",m_SalaryRecord.get("Salary_Id"));
- m_ColumnsData.put("Effective From",v_SqlDate);
- m_ColumnsData.put("Currency",m_SalaryRecord.get("Currency"));
- m_ColumnsData.put("Amount Per Annum",m_SalaryRecord.get("CTC"));
- m_ColumnsData.put("Created Time",zoho.currenttime.toString("yyyy-MM-dd HH:mm:ss"));
- m_ColumnsData.put("Modified Time",zoho.currenttime.toString("yyyy-MM-dd HH:mm:ss"));
- m_ColumnsData.put("Pay Schedule",m_SalaryRecord.get("Pay_Schedule"));
- l_ColumnsData.add(m_ColumnsData);
- }
- }
- //
- //
- // generate a CSV
- v_NewLine = hexToText("0A");
- f_SalariesCSV = l_CsvRows.toString(v_NewLine).toFile("Salaries.csv");
- f_SalariesCSV.setParamName("file");
- /*
- m_Config.put("dateFormat","yyyy-MM-dd");
- m_Config.put("onError","setcolumnempty");
- m_Config.put("skipTop",1);
- */
- //v_Params = "CONFIG=" + zoho.encryption.urlEncode(m_Config.toString());
- //
- //
- /*
- // COMMON PARAMS
- m_Params = Map();
- m_Params.put("ZOHO_ACTION","IMPORT");
- m_Params.put("ZOHO_OUTPUT_FORMAT","JSON");
- m_Params.put("ZOHO_ERROR_FORMAT","JSON");
- m_Params.put("ZOHO_API_VERSION","1.0");
- // ACTION SPECIFIC PARAMS
- m_Params.put("ZOHO_IMPORT_TYPE","UPDATEADD");
- m_Params.put("ZOHO_AUTO_IDENTIFY","TRUE");
- m_Params.put("ZOHO_ON_IMPORT_ERROR","SETCOLUMNEMPTY");
- m_Params.put("ZOHO_CREATE_TABLE","FALSE");
- //
- //
- */
- /*
- r_SalariesCSV = invokeurl
- [
- url: "https://test.com/tmp/salaries.csv"
- type: GET
- ];
- f_SalariesCSV = r_SalariesCSV.toFile("Salaries.csv");
- f_SalariesCSV.setParamName("file");
- //
- v_QueryParam = "";
- l_Keys = m_Params.keys();
- for each v_Key in l_Keys
- {
- v_QueryParam = v_QueryParam + "&" + v_Key + "=" + m_Params.get(v_Key);
- }
- //
- */
- //
- //
- /*
- v_OwnerEmail = zoho.encryption.urlEncode("the_super_admin_email");
- v_WorkspaceName = zoho.encryption.urlEncode("Zoho People Analytics");
- v_ViewName = zoho.encryption.urlEncode("Test");
- v_Endpoint_v1 = "https://analyticsapi.zoho.com/api/" + v_OwnerEmail + "/" + v_WorkspaceName + "/" + v_ViewName + "?" + v_QueryParam.getSuffix("&");
- //info v_Endpoint_v1;
- */
- //
- // authorisation header
- m_Header = Map();
- //m_Header.put("Content-Type","multipart/form-data");
- m_Header.put("ZANALYTICS-ORGID",v_AnalyticsOrgID);
- //info m_Header;
- //
- // v2 config
- m_Config = Map();
- m_Config.put("importType","updateadd");
- m_Config.put("fileType","json");
- m_Config.put("autoIdentify","true");
- // update on key
- m_Config.put("matchingColumns",{"ID"});
- //
- // v2 data
- m_Params = Map();
- m_Params.put("CONFIG",m_Config.toString());
- m_Params.put("DATA",l_ColumnsData);
- //
- v_Endpoint_v2 = "https://analyticsapi.zoho.com/restapi/v2/workspaces/" + v_WorkspaceID + "/views/" + v_ViewID + "/data";
- info v_Endpoint_v2;
- //
- r_FileUpload = invokeurl
- [
- url :v_Endpoint_v2
- type :POST
- parameters:m_Params
- headers:m_Header
- connection:"zanalytics"
- ];
- info r_FileUpload;
- //
- sendmail
- [
- from :zoho.adminuserid
- to :"moi"
- subject :"DEBUGGING - Salary File - TO BE PERMANENTLY DELETED"
- message :m_Config
- Attachments :file:f_SalariesCSV
- ]
- //
- info "Processed " + v_CountTotal + " record(s)";
Category: Zoho People :: Article: 1724


