< Back

Invoke-CrmAction

Sat Jan 18, 2020 4:03 pm

NAME Invoke-CrmAction



SYNOPSIS







SYNTAX

Invoke-CrmAction [-conn <CrmServiceClient>] [-Name] <String> [[-Parameters] <Hashtable>] [[-Target]

<EntityReference>] [-Raw <SwitchParameter>] [<CommonParameters>]





DESCRIPTION







PARAMETERS

-conn <CrmServiceClient>





Required? false

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-Name <String>





Required? true

Position? 1

Default value

Accept pipeline input? false

Accept wildcard characters? false



-Parameters <Hashtable>





Required? false

Position? 2

Default value

Accept pipeline input? false

Accept wildcard characters? false



-Target <EntityReference>





Required? false

Position? 3

Default value

Accept pipeline input? true (ByValue)

Accept wildcard characters? false



-Raw [<SwitchParameter>]





Required? false

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).



INPUTS









OUTPUTS

System.Collections.Hashtable





Microsoft.Xrm.Sdk.OrganizationResponse







NOTES









-------------------------- -------------------------- Example 1 --------------------------

--------------------------



Invoke-CrmAction -conn $conn -Name "new_NoOutputs"



This example shows the execution of a custom unbound action named "new_NoOutputs" that doesn't accept any input

arguments and doesn't return any output arguments. There is no output because the action doesn't have any output

arguments.







-------------------------- -------------------------- Example 2 --------------------------

--------------------------



Invoke-CrmAction -conn $conn -Name 'new_NoInputs'



This example shows the execution of a custom unbound action named 'new_NoInputs' that doesn't accept any input

arguments and returns the output arguments in a [hashtable]. The output consists of a single Boolean argument

named 'Output'.







Name Value

---- -----

Output True



-------------------------- -------------------------- Example 3 --------------------------

--------------------------



Invoke-CrmAction -conn $conn -Name 'new_Echo' -Parameters @{BooleanInput=$true;DateTimeInput=[DateTime]::Now}



This example shows the execution of a custom unbound action named 'new_Echo' that accepts two input arguments and

returns them as output argments in a hastable, along with returning one output argument for each type of each

possible output argument type supported by actions.







Name Value

---- -----

BooleanOutput True

DateTimeOutput 3/2/2017 6:51:20 AM

IntegerOutput 1234

PicklistOutput Microsoft.Xrm.Sdk.OptionSetValue

FloatOutput 1.234

EntityReferenceOutput Microsoft.Xrm.Sdk.EntityReference

StringOutput This is a string

DecimalOutput 1.234

MoneyOutput Microsoft.Xrm.Sdk.Money



-------------------------- -------------------------- Example 4 --------------------------

--------------------------



Invoke-CrmAction -conn $conn -Name 'new_ContactBound' -Target $contactRef -Parameters @{Activate = $true }



This example shows the execution of an unbound action named 'new_ContactBound' that is bound to the contact

entity, with the contact record to process being the $contactRef [Microsoft.Xrm.Sdk.EntityReference] object (see

New-CrmEntityReference). There are no output arguments and as no return value.







-------------------------- -------------------------- Example 5 --------------------------

--------------------------



$contactRef1,$contactRef2 | Invoke-CrmAction -conn $conn -Name 'new_ContactBound' -Parameters @{Activate = $true }

-Raw



This example shows the execution of an unbound action named 'new_ContactBound' that is bound to the contact

entity, with the contact records to process being piped to Invoke-CrmAction, and the use of the -Raw switch. The

action doesn't have any output arguments and as such would normally not have any output, but because the -Raw

switch is used the output includes the two original unparsed [Microsoft.Xrm.Sdk.OrganizationResponse] objects, one

for each invocation of the action.







ResponseName Results ExtensionData

------------ ------- -------------

new_ContactBound {} System.Runtime.Serialization.ExtensionDataObject

new_ContactBound {} System.Runtime.Serialization.ExtensionDataObject





RELATED LINKS