< Back

Add-CrmRecordAssociation

Sat Jan 18, 2020 3:57 pm

NAME Add-CrmRecordAssociation



SYNOPSIS

Associates two records for N:N relationship.





SYNTAX

Add-CrmRecordAssociation [-conn <CrmServiceClient>] [-CrmRecord1] <PSObject> [-CrmRecord2] <PSObject>

[-RelationshipName] <String> [<CommonParameters>]



Add-CrmRecordAssociation [-conn <CrmServiceClient>] [-EntityLogicalName1] <String> [-Id1] <Guid>

[-EntityLogicalName2] <String> [-Id2] <Guid> [-RelationshipName] <String> [<CommonParameters>]





DESCRIPTION

The Add-CrmRecordAssociation cmdlet lets you associate two records for N:N relationship by specifying relatioship

logical name.



There are two ways to specify records.

1. Pass EntityLogicalName and record's Id for both records.

2. Get a record object by using Get-CrmRecord/Get-CrmRecords cmdlets, and pass it for both records.



You can specify relationship logical name for the association.





PARAMETERS

-conn <CrmServiceClient>

A connection to your CRM organization. Use $conn = Get-CrmConnection <Parameters> to generate it.



Required? false

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-CrmRecord1 <PSObject>

A first record object which is obtained via Get-CrmRecord/Get-CrmRecords. When you pass CrmRecord, then you

don't use EntityLogicalName/Id.



Required? true

Position? 1

Default value

Accept pipeline input? false

Accept wildcard characters? false



-CrmRecord2 <PSObject>

A second record object which is obtained via Get-CrmRecord/Get-CrmRecords. When you pass CrmRecord, then you

don't use EntityLogicalName/Id.



Required? true

Position? 2

Default value

Accept pipeline input? false

Accept wildcard characters? false



-RelationshipName <String>

A N:N relationship logical name.



Required? true

Position? 5

Default value

Accept pipeline input? false

Accept wildcard characters? false



-EntityLogicalName1 <String>

A logicalname for first Entity. i.e.)accout, contact, lead, etc..



Required? true

Position? 1

Default value

Accept pipeline input? false

Accept wildcard characters? false



-Id1 <Guid>

An Id (guid) of first record



Required? true

Position? 2

Default value

Accept pipeline input? false

Accept wildcard characters? false



-EntityLogicalName2 <String>

A logicalname for second Entity. i.e.)accout, contact, lead, etc..



Required? true

Position? 3

Default value

Accept pipeline input? false

Accept wildcard characters? false



-Id2 <Guid>

An Id (guid) of second record



Required? true

Position? 4

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









NOTES









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



Add-CrmRecordAssociation -conn $conn -EntityLogicalName1 account -Id1 00005a70-6317-e511-80da-c4346bc43d94

-EntityLogicalName2 contact -Id2 66005a70-6317-e511-80da-c4346bc43d94 -RelationshipName new_accounts_contacts



This example associates an account and a contact records through new_accounts_contacts custom N:N relationship.







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



Add-CrmRecordAssociation account 00005a70-6317-e511-80da-c4346bc43d94 contact 66005a70-6317-e511-80da-c4346bc43d94

new_accounts_contacts



This example associates an account and a contact records through new_accounts_contacts custom N:N relationship by

ommiting parameters names.

When ommiting parameter names, you do not provide $conn, cmdlets automatically finds it.







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



PS C:\\>$account = Get-CrmRecord account 00005a70-6317-e511-80da-c4346bc43d94 name



PS C:\\>$contact = Get-CrmRecord contact 66005a70-6317-e511-80da-c4346bc43d94 fullname



PS C:\\>Add-CrmRecordAssociation -conn $conn -CrmRecord1 $account -CrmRecord2 $contact -RelationshipName

new_accounts_contacts



This example retrieves and stores an account and a contact records to variables, then pass them to

Add-CrmRecordAssociation cmdlets.







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



PS C:\\>$account = Get-CrmRecord account 00005a70-6317-e511-80da-c4346bc43d94 name



PS C:\\>$contact = Get-CrmRecord contact 66005a70-6317-e511-80da-c4346bc43d94 fullname



PS C:\\>Add-CrmRecordAssociation $account $contact new_accounts_contacts



This example retrieves and stores an account and a contact records to variables, then pass them to

Add-CrmRecordAssociation cmdlets.









RELATED LINKS