![]() |
VOOZH | about |
The CData Cmdlets for Bullhorn CRM are standard PowerShell cmdlets that make it easy to accomplish data cleansing, normalization, backup, and other integration tasks by enabling real-time and bidirectional access to Bullhorn CRM.
The Cmdlets are not only a PowerShell interface to Bullhorn CRM, but also an SQL interface; this tutorial shows how to use both to create, retrieve, update, and delete Bullhorn CRM data. We also show examples of the ADO.NET equivalent, which is possible with the CData ADO.NET Provider for Bullhorn CRM. To access Bullhorn CRM data from other .NET applications, like LINQPad, use the CData ADO.NET Provider for Bullhorn CRM.
Once you have acquired the necessary connection properties, accessing Bullhorn CRM data in PowerShell can be enabled in three steps.
Begin by providing your Bullhorn CRM account credentials in the following:
If you are uncertain about your data center code, codes like CLS2, CLS21, etc. are cluster IDs that are contained in a user's browser URL (address bar) once they are logged in.
Example: https://cls21.bullhornstaffing.com/BullhornSTAFFING/MainFrame.jsp?#no-ba... indicates that the logged in user is on CLS21.
Bullhorn CRM uses the OAuth 2.0 authentication standard. To authenticate using OAuth, create and configure a custom OAuth app. See the Help documentation for more information.
Install the module:
Install-Module BullhornCRMCmdlets
Connect:
$bullhorncrm = Connect-BullhornCRM -DataCenterCode "$DataCenterCode" -OAuthClientId "$OAuthClientId" -OAuthClientSecret "$OAuthClientSecret" -InitiateOAuth "$InitiateOAuth"
Search for and retrieve data:
$candidatename = "Jane Doe" $candidate = Select-BullhornCRM -Connection $bullhorncrm -Table "Candidate" -Where "CandidateName = `'$CandidateName`'" $candidate
You can also use the Invoke-BullhornCRM cmdlet to execute SQL commands:
$candidate = Invoke-BullhornCRM -Connection $bullhorncrm -Query 'SELECT * FROM Candidate WHERE CandidateName = @CandidateName' -Params @{'@CandidateName'='Jane Doe'}
Load the provider's assembly:
[Reflection.Assembly]::LoadFile("C:\Program Files\CData\CData ADO.NET Provider for Bullhorn CRM\lib\System.Data.CData.BullhornCRM.dll")
Connect to Bullhorn CRM:
$conn= New-Object System.Data.CData.BullhornCRM.BullhornCRMConnection("DataCenterCode=CLS33;OAuthClientId=myoauthclientid;OAuthClientSecret=myoauthclientsecret;InitiateOAuth=GETANDREFRESH;")
$conn.Open()
Instantiate the BullhornCRMDataAdapter, execute an SQL query, and output the results:
$sql="SELECT Id, CandidateName from Candidate"
$da= New-Object System.Data.CData.BullhornCRM.BullhornCRMDataAdapter($sql, $conn)
$dt= New-Object System.Data.DataTable
$da.Fill($dt)
$dt.Rows | foreach {
Write-Host $_.id $_.candidatename
}
Update-BullhornCRM -Connection $BullhornCRM -Columns @('Id','CandidateName') -Values @('MyId', 'MyCandidateName') -Table Candidate -Id "MyId"
$cmd = New-Object System.Data.CData.BullhornCRM.BullhornCRMCommand("UPDATE Candidate SET CandidateName='Jane Doe' WHERE Id = @myId", $conn)
$cmd.Parameters.Add((New-Object System.Data.CData.BullhornCRM.BullhornCRMParameter("@myId","10456255-0015501366")))
$cmd.ExecuteNonQuery()
Add-BullhornCRM -Connection $BullhornCRM -Table Candidate -Columns @("Id", "CandidateName") -Values @("MyId", "MyCandidateName")
$cmd = New-Object System.Data.CData.BullhornCRM.BullhornCRMCommand("INSERT INTO Candidate (CandidateName) VALUES (@myCandidateName)", $conn)
$cmd.Parameters.Add((New-Object System.Data.CData.BullhornCRM.BullhornCRMParameter("@myCandidateName","Jane Doe")))
$cmd.ExecuteNonQuery()
Remove-BullhornCRM -Connection $BullhornCRM -Table "Candidate" -Id "MyId"
$cmd = New-Object System.Data.CData.BullhornCRM.BullhornCRMCommand("DELETE FROM Candidate WHERE Id=@myId", $conn)
$cmd.Parameters.Add((New-Object System.Data.CData.BullhornCRM.BullhornCRMParameter("@myId","001d000000YBRseAAH")))
$cmd.ExecuteNonQuery()
CodeProject
Download a free trial of the Bullhorn CRM Data Provider to get started:
Download NowLearn more:
👁 Bullhorn CRM IconRapidly create and deploy powerful .NET applications that integrate with Bullhorn CRM.