Functions/Client/Add-CdsRecord.ps1
<#
.SYNOPSIS Create entity record in CDS. #> function Add-CdsRecord { [CmdletBinding()] [OutputType([Guid])] param ( [Parameter(Mandatory=$false, ValueFromPipeline)] [Microsoft.Xrm.Tooling.Connector.CrmServiceClient] $CdsClient = $Global:CdsClient, [Parameter(Mandatory=$true, ValueFromPipeline)] [Microsoft.Xrm.Sdk.Entity] $Record, [Parameter(Mandatory=$false)] [switch] $BypassCustomPluginExecution = $false ) begin { $StopWatch = [System.Diagnostics.Stopwatch]::StartNew(); Trace-CdsFunction -Name $MyInvocation.MyCommand.Name -Stage Start -Parameters ($MyInvocation.MyCommand.Parameters); } process { $request = New-CdsRequest -Name "Create"; $request | Add-CdsRequestParameter -Name "Target" -Value $Record | Out-Null; if($BypassCustomPluginExecution) { $request | Add-CdsRequestParameter -Name "BypassCustomPluginExecution" -Value $true | Out-Null; } $response = Invoke-CdsRequest -CdsClient $CdsClient -Request $request; $id = $response.Results["id"]; $id; } end { $StopWatch.Stop(); Trace-CdsFunction -Name $MyInvocation.MyCommand.Name -Stage Stop -StopWatch $StopWatch; } } Export-ModuleMember -Function Add-CdsRecord -Alias *; |