Functions/Client/Add-CdsRecord.ps1
<#
.SYNOPSIS Create new entity in CRM. #> function Add-CdsRecord { [CmdletBinding()] param ( [Parameter(Mandatory = $false, ValueFromPipeline)] [Microsoft.Xrm.Tooling.Connector.CrmServiceClient] $XrmClient = $Global:XrmClient, [Parameter(Mandatory = $true)] [Microsoft.Xrm.Sdk.Entity] $Record ) begin { $StopWatch = [System.Diagnostics.Stopwatch]::StartNew(); Trace-CdsFunction -Name $MyInvocation.MyCommand.Name -Stage Start -Parameters ($MyInvocation.MyCommand.Parameters); } process { $id = Protect-CdsCommand -ScriptBlock { $XrmClient.Create($Record) }; $id; } end { $StopWatch.Stop(); Trace-CdsFunction -Name $MyInvocation.MyCommand.Name -Stage Stop -StopWatch $StopWatch; } } Export-ModuleMember -Function Add-CdsRecord -Alias *; |