Automate Zoho CRM Integration Tasks from PowerShell
The CData ADO.NET Provider for Zoho CRM is a standard ADO.NET Provider that make it easy to accomplish data cleansing, normalization, backup, and other integration tasks by enabling real-time and bidirectional access to Zoho CRM.
ADO.NET Provider
The ADO.NET Provider provides a SQL interface for Zoho CRM; this tutorial shows how to use the Provider to create, retrieve, update, and delete Zoho CRM data.
Once you have acquired the necessary connection properties, accessing Zoho CRM data in PowerShell can be enabled in three steps.
The connector is already registered with Zoho CRM as an OAuth application. As such, OAuth Credentials are embedded by default. If you would prefer to use your own custom OAuth app, see the Custom Credentials section in the Help documentation.
-
Load the provider's assembly:
[Reflection.Assembly]::LoadFile("C:\Program Files\CData\CData ADO.NET Provider for Zoho CRM\lib\System.Data.CData.ZohoCRM.dll") -
Connect to Zoho CRM:
$conn= New-Object System.Data.CData.ZohoCRM.ZohoCRMConnection("InitiateOAuth=GETANDREFRESH;") $conn.Open() -
Instantiate the ZohoCRMDataAdapter, execute an SQL query, and output the results:
$sql="SELECT Account_Name, Annual_Revenue from Accounts" $da= New-Object System.Data.CData.ZohoCRM.ZohoCRMDataAdapter($sql, $conn) $dt= New-Object System.Data.DataTable $da.Fill($dt) $dt.Rows | foreach { Write-Host $_.account_name $_.annual_revenue }
Update Zoho CRM Data
$cmd = New-Object System.Data.CData.ZohoCRM.ZohoCRMCommand("UPDATE Accounts SET Industry='Data/Telecom OEM' WHERE Id = @myId", $conn)
$cmd.Parameters.Add((New-Object System.Data.CData.ZohoCRM.ZohoCRMParameter("@myId","10456255-0015501366")))
$cmd.ExecuteNonQuery()
Insert Zoho CRM Data
$cmd = New-Object System.Data.CData.ZohoCRM.ZohoCRMCommand("INSERT INTO Accounts (Industry) VALUES (@myIndustry)", $conn)
$cmd.Parameters.Add((New-Object System.Data.CData.ZohoCRM.ZohoCRMParameter("@myIndustry","Data/Telecom OEM")))
$cmd.ExecuteNonQuery()
Delete Zoho CRM Data
$cmd = New-Object System.Data.CData.ZohoCRM.ZohoCRMCommand("DELETE FROM Accounts WHERE Id=@myId", $conn)
$cmd.Parameters.Add((New-Object System.Data.CData.ZohoCRM.ZohoCRMParameter("@myId","001d000000YBRseAAH")))
$cmd.ExecuteNonQuery()
CodeProject