![]() |
VOOZH | about |
The CData Cmdlets for Tableau CRM Analytics 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 Tableau CRM Analytics.
The Cmdlets are not only a PowerShell interface to Tableau CRM Analytics, but also an SQL interface; this tutorial shows how to use both to create, retrieve, update, and delete Tableau CRM Analytics data. We also show examples of the ADO.NET equivalent, which is possible with the CData ADO.NET Provider for Tableau CRM Analytics. To access Tableau CRM Analytics data from other .NET applications, like LINQPad, use the CData ADO.NET Provider for Tableau CRM Analytics.
Once you have acquired the necessary connection properties, accessing Tableau CRM Analytics data in PowerShell can be enabled in three steps.
Tableau CRM Analytics uses the OAuth 2 authentication standard. Obtain the OAuthClientId and OAuthClientSecret by registering an app with Tableau CRM Analytics.
See the Getting Started section of the Help documentation for an authentication guide.
If the connected Salesforce org has MFA enforcement enabled, set MFACode to the time-based one-time passcode (TOTP) generated by your authenticator app (such as Salesforce Authenticator or Google Authenticator). MFACode applies alongside the standard OAuth flow.
Install the module:
Install-Module TableauCRMCmdlets
Connect:
$tableaucrm = Connect-TableauCRM -OAuthClientId "$OAuthClientId" -OAuthClientSecret "$OAuthClientSecret" -CallbackURL "$CallbackURL" -InitiateOAuth "$InitiateOAuth" -MFACode "$MFACode"
Search for and retrieve data:
$stagename = "Closed Won" $dataset_opportunity = Select-TableauCRM -Connection $tableaucrm -Table "Dataset_Opportunity" -Where "StageName = `'$StageName`'" $dataset_opportunity
You can also use the Invoke-TableauCRM cmdlet to execute SQL commands:
$dataset_opportunity = Invoke-TableauCRM -Connection $tableaucrm -Query 'SELECT * FROM Dataset_Opportunity WHERE StageName = @StageName' -Params @{'@StageName'='Closed Won'}
Load the provider's assembly:
[Reflection.Assembly]::LoadFile("C:\Program Files\CData\CData ADO.NET Provider for Tableau CRM Analytics\lib\System.Data.CData.TableauCRM.dll")
Connect to Tableau CRM Analytics:
$conn= New-Object System.Data.CData.TableauCRM.TableauCRMConnection("OAuthClientId=MyConsumerKey;OAuthClientSecret=MyConsumerSecret;CallbackURL=http://localhost:portNumber;InitiateOAuth=GETANDREFRESH;MFACode=YourMFACode")
$conn.Open()
Instantiate the TableauCRMDataAdapter, execute an SQL query, and output the results:
$sql="SELECT Name, CloseDate from Dataset_Opportunity"
$da= New-Object System.Data.CData.TableauCRM.TableauCRMDataAdapter($sql, $conn)
$dt= New-Object System.Data.DataTable
$da.Fill($dt)
$dt.Rows | foreach {
Write-Host $_.name $_.closedate
}
Update-TableauCRM -Connection $TableauCRM -Columns @('Name','CloseDate') -Values @('MyName', 'MyCloseDate') -Table Dataset_Opportunity -Id "MyId"
$cmd = New-Object System.Data.CData.TableauCRM.TableauCRMCommand("UPDATE Dataset_Opportunity SET StageName='Closed Won' WHERE Id = @myId", $conn)
$cmd.Parameters.Add((New-Object System.Data.CData.TableauCRM.TableauCRMParameter("@myId","10456255-0015501366")))
$cmd.ExecuteNonQuery()
Add-TableauCRM -Connection $TableauCRM -Table Dataset_Opportunity -Columns @("Name", "CloseDate") -Values @("MyName", "MyCloseDate")
$cmd = New-Object System.Data.CData.TableauCRM.TableauCRMCommand("INSERT INTO Dataset_Opportunity (StageName) VALUES (@myStageName)", $conn)
$cmd.Parameters.Add((New-Object System.Data.CData.TableauCRM.TableauCRMParameter("@myStageName","Closed Won")))
$cmd.ExecuteNonQuery()
Remove-TableauCRM -Connection $TableauCRM -Table "Dataset_Opportunity" -Id "MyId"
$cmd = New-Object System.Data.CData.TableauCRM.TableauCRMCommand("DELETE FROM Dataset_Opportunity WHERE Id=@myId", $conn)
$cmd.Parameters.Add((New-Object System.Data.CData.TableauCRM.TableauCRMParameter("@myId","001d000000YBRseAAH")))
$cmd.ExecuteNonQuery()
CodeProject
Download a free trial of the Tableau CRM Analytics Data Provider to get started:
Download NowLearn more:
👁 Tableau CRM Analytics IconRapidly create and deploy powerful .NET applications that integrate with Tableau CRM Analytics.