pacx rel poly create - neronotte/Greg.Xrm.Command GitHub Wiki
Creates a new many-to-one polymorphic relationship between Dataverse tables
Aliases
pacx rel poli create
pacx rel create poly
pacx rel create poli
Usage
This command allows to easily create polymorphic relationships between Dataverse tables, a feature that is not yet available via UI, but it's fully supported via API.
Please note that this command assumes that the relationship behavior is equal for all the parent tables. If you need to specify different behaviors, you need to create the relationship manually via API, or you can change it later via UI
All you need to pass is:
- The schema name of the table that will contain the lookup column (the child table)
- The list schema names of the table that will be referenced by the lookup column (the parents table), separated by comma or pipe
- The display name of the lookup attribute (the lookupDisplayName arg)
all other info, if not passed explicitly, is automatically inferred from the provided arguments.
pacx rel create poly -ldn "Referenced By" -c custom_table --p "custom_parent1,custom_parent2,custom_parent3"
The following default logic applies when a given argument is not explicitly passed to the command:
- The schema name of the lookup attribute is inferred from the display name. Only chars, numbers and underscores are extracted and put lowercase. The schema name is obtained concatenating the publisher prefix (from the selected solution), the "cleaned" display name, and the string "id".
- The relationship name is obtained concatenating the schema name of the lookup attribute, the schema name of the child table, and a suffix, all lowercase, separated by underscores.
- The relationship name suffix is obtained from the display name of the lookup attribute, by removing all chars that are not letters, numbers or underscores, and putting everything lowercase.
- The menu behavior is set to "DoNotDisplay" for all the relationships.
- The lookup behavior is set to Referential / Restrict Delete for all the relationships.
- The lookup attribute is set as optional.
Arguments
| Long Name | Short Name | Required? | Description | Default value | Valid values |
|---|---|---|---|---|---|
child |
c |
Y | The child table (N side of the relationship) | - | String |
parents |
p |
Y | A comma or pipe separated list of entities that will act as parent for the relationship | - | String |
lookupDisplayName |
ldn |
Y | The display name of the lookup attribute. | - | String |
lookupSchemaName |
lsn |
N | The schema name of the lookup attribute. If not specified, it is inferred by the display name. | - | String |
requiredLevel |
r |
N | The required level of the lookup attribute. | - | None, SystemRequired, ApplicationRequired, Recommended |
relNameSuffix |
suff |
N | The suffix to append to the relationship name. If not provided, will be set equal to the display name of the lookup attribute (only letters, numbers, or underscores, lowercase). | - | String |
cascadeAssign |
caass |
N | The behavior to apply to child records when the parent record is assigned to another owner (values: Cascade, Active, UserOwned, NoCascade) (default: NoCascade) | - | see description |
cascadeArchive |
caarc |
N | The behavior to apply to child records when the parent record is archived (not available via UI) (default: NoCascade) | - | see description |
cascadeShare |
cas |
N | The behavior to apply to child records when the parent record is shared (values: Cascade, Active, UserOwned, NoCascade) (default: NoCascade) | - | see description |
cascadeUnshare |
cau |
N | The behavior to apply to child records when the parent record is unshared (values: Cascade, Active, UserOwned, NoCascade) (default: NoCascade) | - | see description |
cascadeDelete |
cad |
N | The behavior to apply when the parent record is deleted (values: Restrict, RemoveLink) (default: Restrict) | Restrict |
see description |
cascadeMerge |
cam |
N | The behavior to apply to child records when the parent record is merged to another one (not available via UI) (default: NoCascade) | - | see description |
cascadeReparent |
car |
N | The behavior to apply to child records when the parent record is reparented (values: Cascade, Active, UserOwned, NoCascade) (default: NoCascade) | - | see description |
menuBehavior |
m |
N | Indicates how the child entity is displayed in the parent navbar | DoNotDisplay |
UseCollectionName, UseLabel, DoNotDisplay |
menuLabel |
ml |
N | Associated menu label. To be specified only if the menuBehavior arg is set to UseLabel | - | String |
menuGroup |
mg |
N | Associated menu group. To be specified only if the menuBehavior arg is set to UseLabel or UseCollectionName | Details |
Details, Sales, Service, Marketing |
menuOrder |
mo |
N | Associated menu order. To be specified only if the menuBehavior arg is set to UseLabel or UseCollectionName | 10000 |
Int32 |
solution |
s |
N | The name of the unmanaged solution to which you want to add this relationship. | - | String |