public void CreateManytoMany(Guid municipioId, Guid accountid) { CreateManyToManyRequest create = new CreateManyToManyRequest(); CreateManyToManyRequest createManyToManyRelationshipRequest = new CreateManyToManyRequest { IntersectEntitySchemaName = "itbc_account_itbc_municipios", ManyToManyRelationship = new ManyToManyRelationshipMetadata { SchemaName = "new_accounts_campaigns", Entity1LogicalName = "account", Entity1AssociatedMenuConfiguration = new AssociatedMenuConfiguration { Behavior = AssociatedMenuBehavior.UseLabel, Group = AssociatedMenuGroup.Details, Label = new Label("Conta", 1033), Order = 10000 }, Entity2LogicalName = "itbc_municipio", Entity2AssociatedMenuConfiguration = new AssociatedMenuConfiguration { Behavior = AssociatedMenuBehavior.UseLabel, Group = AssociatedMenuGroup.Details, Label = new Label("Municipio", 1033), Order = 10000 } } }; }
public bool CreateManyToMany(IOrganizationService service, XRMSpeedyRelationship relationship, string prefix, int languageCode) { try { CreateManyToManyRequest createManyToManyRelationshipRequest = new CreateManyToManyRequest { IntersectEntitySchemaName = relationship.SchemaName, ManyToManyRelationship = new ManyToManyRelationshipMetadata { SchemaName = relationship.SchemaName, Entity1LogicalName = relationship.Entity1, Entity1AssociatedMenuConfiguration = new AssociatedMenuConfiguration { Behavior = AssociatedMenuBehavior.UseLabel, Group = AssociatedMenuGroup.Details, Label = new Label(relationship.Entity1Display, languageCode), Order = 10000 }, Entity2LogicalName = relationship.Entity2, Entity2AssociatedMenuConfiguration = new AssociatedMenuConfiguration { Behavior = AssociatedMenuBehavior.UseLabel, Group = AssociatedMenuGroup.Details, Label = new Label(relationship.Entity2Display, languageCode), Order = 10000 } } }; CreateManyToManyResponse createManytoManyRelationshipResponse = (CreateManyToManyResponse)service.Execute(createManyToManyRelationshipRequest); return(true); } catch (FaultException <OrganizationServiceFault> ) { throw; } }
/// <summary> /// Create and configure the organization service proxy. /// Create one-to-many relationship. /// Create many-to-many relationship. /// Optionally delete any entity records that were created for this sample. /// </summary> /// <param name="serverConfig">Contains server connection information.</param> /// <param name="promptForDelete">When True, the user will be prompted to delete all /// created entities.</param> public void Run(ServerConnection.Configuration serverConfig, bool promptForDelete) { try { // Connect to the Organization service. // The using statement assures that the service proxy will be properly disposed. using (_serviceProxy = new OrganizationServiceProxy(serverConfig.OrganizationUri, serverConfig.HomeRealmUri, serverConfig.Credentials, serverConfig.DeviceCredentials)) { // This statement is required to enable early-bound type support. _serviceProxy.EnableProxyTypes(); //<snippetWorkWithRelationships1> bool eligibleCreateOneToManyRelationship = EligibleCreateOneToManyRelationship("account", "campaign"); if (eligibleCreateOneToManyRelationship) { CreateOneToManyRequest createOneToManyRelationshipRequest = new CreateOneToManyRequest { OneToManyRelationship = new OneToManyRelationshipMetadata { ReferencedEntity = "account", ReferencingEntity = "campaign", SchemaName = "new_account_campaign", AssociatedMenuConfiguration = new AssociatedMenuConfiguration { Behavior = AssociatedMenuBehavior.UseLabel, Group = AssociatedMenuGroup.Details, Label = new Label("Account", 1033), Order = 10000 }, CascadeConfiguration = new CascadeConfiguration { Assign = CascadeType.NoCascade, Delete = CascadeType.RemoveLink, Merge = CascadeType.NoCascade, Reparent = CascadeType.NoCascade, Share = CascadeType.NoCascade, Unshare = CascadeType.NoCascade } }, Lookup = new LookupAttributeMetadata { SchemaName = "new_parent_accountid", DisplayName = new Label("Account Lookup", 1033), RequiredLevel = new AttributeRequiredLevelManagedProperty(AttributeRequiredLevel.None), Description = new Label("Sample Lookup", 1033) } }; CreateOneToManyResponse createOneToManyRelationshipResponse = (CreateOneToManyResponse)_serviceProxy.Execute( createOneToManyRelationshipRequest); _oneToManyRelationshipId = createOneToManyRelationshipResponse.RelationshipId; _oneToManyRelationshipName = createOneToManyRelationshipRequest.OneToManyRelationship.SchemaName; Console.WriteLine( "The one-to-many relationship has been created between {0} and {1}.", "account", "campaign"); } //</snippetWorkWithRelationships1> //<snippetWorkWithRelationships2> bool accountEligibleParticipate = EligibleCreateManyToManyRelationship("account"); bool campaignEligibleParticipate = EligibleCreateManyToManyRelationship("campaign"); if (accountEligibleParticipate && campaignEligibleParticipate) { CreateManyToManyRequest createManyToManyRelationshipRequest = new CreateManyToManyRequest { IntersectEntitySchemaName = "new_accounts_campaigns", ManyToManyRelationship = new ManyToManyRelationshipMetadata { SchemaName = "new_accounts_campaigns", Entity1LogicalName = "account", Entity1AssociatedMenuConfiguration = new AssociatedMenuConfiguration { Behavior = AssociatedMenuBehavior.UseLabel, Group = AssociatedMenuGroup.Details, Label = new Label("Account", 1033), Order = 10000 }, Entity2LogicalName = "campaign", Entity2AssociatedMenuConfiguration = new AssociatedMenuConfiguration { Behavior = AssociatedMenuBehavior.UseLabel, Group = AssociatedMenuGroup.Details, Label = new Label("Campaign", 1033), Order = 10000 } } }; CreateManyToManyResponse createManytoManyRelationshipResponse = (CreateManyToManyResponse)_serviceProxy.Execute( createManyToManyRelationshipRequest); _manyToManyRelationshipId = createManytoManyRelationshipResponse.ManyToManyRelationshipId; _manyToManyRelationshipName = createManyToManyRelationshipRequest.ManyToManyRelationship.SchemaName; Console.WriteLine( "The many-to-many relationship has been created between {0} and {1}.", "account", "campaign"); } //</snippetWorkWithRelationships2> // Publish the customization changes. _serviceProxy.Execute(new PublishAllXmlRequest()); //<snippetWorkWithRelationships.RetrieveRelationship> //You can use either the Name or the MetadataId of the relationship. //Retrieve the One-to-many relationship using the MetadataId. RetrieveRelationshipRequest retrieveOneToManyRequest = new RetrieveRelationshipRequest { MetadataId = _oneToManyRelationshipId }; RetrieveRelationshipResponse retrieveOneToManyResponse = (RetrieveRelationshipResponse)_serviceProxy.Execute(retrieveOneToManyRequest); Console.WriteLine("Retrieved {0} One-to-many relationship by id", retrieveOneToManyResponse.RelationshipMetadata.SchemaName); //Retrieve the Many-to-many relationship using the Name. RetrieveRelationshipRequest retrieveManyToManyRequest = new RetrieveRelationshipRequest { Name = _manyToManyRelationshipName }; RetrieveRelationshipResponse retrieveManyToManyResponse = (RetrieveRelationshipResponse)_serviceProxy.Execute(retrieveManyToManyRequest); Console.WriteLine("Retrieved {0} Many-to-Many relationship by Name", retrieveManyToManyResponse.RelationshipMetadata.MetadataId); //</snippetWorkWithRelationships.RetrieveRelationship> DeleteRequiredRecords(promptForDelete); } } // Catch any service fault exceptions that Microsoft Dynamics CRM throws. catch (FaultException <Microsoft.Xrm.Sdk.OrganizationServiceFault> ) { // You can handle an exception here or pass it back to the calling method. throw; } }
private void CreateNNRelation(string entityLogicalName, AttributeTemplate attributeTemplate) { string entity1Logical, entity2Logical; var displayNames = attributeTemplate.DisplayName.Split(';'); var entity1Display = displayNames.First(); var entity2Display = displayNames.Last(); if (attributeTemplate.Description == "1") { entity1Logical = attributeTemplate.LogicalName; entity2Logical = attributeTemplate.LookupEntityLogicalName; } else { entity1Logical = attributeTemplate.LookupEntityLogicalName; entity2Logical = attributeTemplate.LogicalName; } AssociatedMenuBehavior? entity1Behavior = entity1Display == entity1Logical ? AssociatedMenuBehavior.DoNotDisplay : AssociatedMenuBehavior.UseLabel; AssociatedMenuBehavior? entity2Behavior = entity2Display == entity2Logical ? AssociatedMenuBehavior.DoNotDisplay : AssociatedMenuBehavior.UseLabel; var createManyToManyRelationshipRequest = new CreateManyToManyRequest { IntersectEntitySchemaName = attributeTemplate.LogicalName, ManyToManyRelationship = new ManyToManyRelationshipMetadata { SchemaName = attributeTemplate.LogicalName, Entity1LogicalName = entity1Logical, Entity1AssociatedMenuConfiguration = new AssociatedMenuConfiguration { Behavior = entity1Behavior, Group = AssociatedMenuGroup.Details, Label = new Label(entity1Display, 1033), Order = 10000 }, Entity2LogicalName = entity2Logical, Entity2AssociatedMenuConfiguration = new AssociatedMenuConfiguration { Behavior = entity2Behavior, Group = AssociatedMenuGroup.Details, Label = new Label(entity2Display, 1033), Order = 10000 } } }; ExecuteOperation(GetSharedOrganizationService(), createManyToManyRelationshipRequest, string.Format("An error occured while creating the NN: {0}", attributeTemplate.LogicalName)); }
[STAThread] // Required to support the interactive login experience static void Main(string[] args) { CrmServiceClient service = null; try { service = SampleHelpers.Connect("Connect"); if (service.IsReady) { // Create any entity records that the demonstration code requires SetUpSample(service); #region Demonstrate bool eligibleCreateOneToManyRelationship = EligibleCreateOneToManyRelationship(service, "account", "contact"); if (eligibleCreateOneToManyRelationship) { var createOneToManyRelationshipRequest = new CreateOneToManyRequest { OneToManyRelationship = new OneToManyRelationshipMetadata { ReferencedEntity = "account", ReferencingEntity = "contact", SchemaName = "new_account_contact", AssociatedMenuConfiguration = new AssociatedMenuConfiguration { Behavior = AssociatedMenuBehavior.UseLabel, Group = AssociatedMenuGroup.Details, Label = new Label("Account", 1033), Order = 10000 }, CascadeConfiguration = new CascadeConfiguration { Assign = CascadeType.NoCascade, Delete = CascadeType.RemoveLink, Merge = CascadeType.NoCascade, Reparent = CascadeType.NoCascade, Share = CascadeType.NoCascade, Unshare = CascadeType.NoCascade } }, Lookup = new LookupAttributeMetadata { SchemaName = "new_parent_accountid", DisplayName = new Label("Account Lookup", 1033), RequiredLevel = new AttributeRequiredLevelManagedProperty(AttributeRequiredLevel.None), Description = new Label("Sample Lookup", 1033) } }; var createOneToManyRelationshipResponse = (CreateOneToManyResponse)service.Execute( createOneToManyRelationshipRequest); _oneToManyRelationshipId = createOneToManyRelationshipResponse.RelationshipId; _oneToManyRelationshipName = createOneToManyRelationshipRequest.OneToManyRelationship.SchemaName; Console.WriteLine( "The one-to-many relationship has been created between {0} and {1}.", "account", "contact"); } bool accountEligibleParticipate = EligibleCreateManyToManyRelationship(service, "account"); bool campaignEligibleParticipate = EligibleCreateManyToManyRelationship(service, "contact"); if (accountEligibleParticipate && campaignEligibleParticipate) { var createManyToManyRelationshipRequest = new CreateManyToManyRequest { IntersectEntitySchemaName = "new_accounts_contacts", ManyToManyRelationship = new ManyToManyRelationshipMetadata { SchemaName = "new_accounts_contacts", Entity1LogicalName = "account", Entity1AssociatedMenuConfiguration = new AssociatedMenuConfiguration { Behavior = AssociatedMenuBehavior.UseLabel, Group = AssociatedMenuGroup.Details, Label = new Label("Account", 1033), Order = 10000 }, Entity2LogicalName = "contact", Entity2AssociatedMenuConfiguration = new AssociatedMenuConfiguration { Behavior = AssociatedMenuBehavior.UseLabel, Group = AssociatedMenuGroup.Details, Label = new Label("Contact", 1033), Order = 10000 } } }; var createManytoManyRelationshipResponse = (CreateManyToManyResponse)service.Execute( createManyToManyRelationshipRequest); _manyToManyRelationshipId = createManytoManyRelationshipResponse.ManyToManyRelationshipId; _manyToManyRelationshipName = createManyToManyRelationshipRequest.ManyToManyRelationship.SchemaName; Console.WriteLine( "The many-to-many relationship has been created between {0} and {1}.", "account", "contact"); } // Publish the customization changes. service.Execute(new PublishAllXmlRequest()); //You can use either the Name or the MetadataId of the relationship. //Retrieve the One-to-many relationship using the MetadataId. var retrieveOneToManyRequest = new RetrieveRelationshipRequest { MetadataId = _oneToManyRelationshipId }; var retrieveOneToManyResponse = (RetrieveRelationshipResponse)service.Execute(retrieveOneToManyRequest); Console.WriteLine("Retrieved {0} One-to-many relationship by id", retrieveOneToManyResponse.RelationshipMetadata.SchemaName); //Retrieve the Many-to-many relationship using the Name. var retrieveManyToManyRequest = new RetrieveRelationshipRequest { Name = _manyToManyRelationshipName }; var retrieveManyToManyResponse = (RetrieveRelationshipResponse)service.Execute(retrieveManyToManyRequest); Console.WriteLine("Retrieved {0} Many-to-Many relationship by Name", retrieveManyToManyResponse.RelationshipMetadata.MetadataId); #endregion Demonstrate #region Clean up CleanUpSample(service); #endregion Clean up } else { const string UNABLE_TO_LOGIN_ERROR = "Unable to Login to Microsoft Dataverse"; if (service.LastCrmError.Equals(UNABLE_TO_LOGIN_ERROR)) { Console.WriteLine("Check the connection string values in cds/App.config."); throw new Exception(service.LastCrmError); } else { throw service.LastCrmException; } } } catch (Exception ex) { SampleHelpers.HandleException(ex); } finally { if (service != null) { service.Dispose(); } Console.WriteLine("Press <Enter> to exit."); Console.ReadLine(); } }
public void CreateOrUpdateRelationship(string schemaName, string entityType1, string entityType2, bool entityType1DisplayRelated, bool entityType2DisplayRelated) { var metadata = new ManyToManyRelationshipMetadata(); lock (LockObject) { var exists = RelationshipExists(schemaName); if (exists) metadata = GetRelationshipMetadata(schemaName); metadata.SchemaName = schemaName; metadata.IntersectEntityName = schemaName; metadata.Entity1LogicalName = entityType1; metadata.Entity2LogicalName = entityType2; metadata.Entity1AssociatedMenuConfiguration = new AssociatedMenuConfiguration() { Behavior = entityType1DisplayRelated ? AssociatedMenuBehavior.UseCollectionName : AssociatedMenuBehavior.DoNotDisplay }; metadata.Entity2AssociatedMenuConfiguration = new AssociatedMenuConfiguration() { Behavior = entityType2DisplayRelated ? AssociatedMenuBehavior.UseCollectionName : AssociatedMenuBehavior.DoNotDisplay }; if (exists) { var request = new UpdateRelationshipRequest { Relationship = metadata }; Execute(request); } else { var request = new CreateManyToManyRequest { IntersectEntitySchemaName = schemaName, ManyToManyRelationship = metadata }; Execute(request); } RefreshRelationshipMetadata(schemaName); } }
/// <summary> /// Create and configure the organization service proxy. /// Create one-to-many relationship. /// Create many-to-many relationship. /// Optionally delete any entity records that were created for this sample. /// </summary> /// <param name="serverConfig">Contains server connection information.</param> /// <param name="promptForDelete">When True, the user will be prompted to delete all /// created entities.</param> public void Run(ServerConnection.Configuration serverConfig, bool promptForDelete) { try { // Connect to the Organization service. // The using statement assures that the service proxy will be properly disposed. using (_serviceProxy = new OrganizationServiceProxy(serverConfig.OrganizationUri, serverConfig.HomeRealmUri,serverConfig.Credentials, serverConfig.DeviceCredentials)) { // This statement is required to enable early-bound type support. _serviceProxy.EnableProxyTypes(); //<snippetWorkWithRelationships1> bool eligibleCreateOneToManyRelationship = EligibleCreateOneToManyRelationship("account", "campaign"); if (eligibleCreateOneToManyRelationship) { CreateOneToManyRequest createOneToManyRelationshipRequest = new CreateOneToManyRequest { OneToManyRelationship = new OneToManyRelationshipMetadata { ReferencedEntity = "account", ReferencingEntity = "campaign", SchemaName = "new_account_campaign", AssociatedMenuConfiguration = new AssociatedMenuConfiguration { Behavior = AssociatedMenuBehavior.UseLabel, Group = AssociatedMenuGroup.Details, Label = new Label("Account", 1033), Order = 10000 }, CascadeConfiguration = new CascadeConfiguration { Assign = CascadeType.NoCascade, Delete = CascadeType.RemoveLink, Merge = CascadeType.NoCascade, Reparent = CascadeType.NoCascade, Share = CascadeType.NoCascade, Unshare = CascadeType.NoCascade } }, Lookup = new LookupAttributeMetadata { SchemaName = "new_parent_accountid", DisplayName = new Label("Account Lookup", 1033), RequiredLevel = new AttributeRequiredLevelManagedProperty(AttributeRequiredLevel.None), Description = new Label("Sample Lookup", 1033) } }; CreateOneToManyResponse createOneToManyRelationshipResponse = (CreateOneToManyResponse)_serviceProxy.Execute( createOneToManyRelationshipRequest); _oneToManyRelationshipId = createOneToManyRelationshipResponse.RelationshipId; _oneToManyRelationshipName = createOneToManyRelationshipRequest.OneToManyRelationship.SchemaName; Console.WriteLine( "The one-to-many relationship has been created between {0} and {1}.", "account", "campaign"); } //</snippetWorkWithRelationships1> //<snippetWorkWithRelationships2> bool accountEligibleParticipate = EligibleCreateManyToManyRelationship("account"); bool campaignEligibleParticipate = EligibleCreateManyToManyRelationship("campaign"); if (accountEligibleParticipate && campaignEligibleParticipate) { CreateManyToManyRequest createManyToManyRelationshipRequest = new CreateManyToManyRequest { IntersectEntitySchemaName = "new_accounts_campaigns", ManyToManyRelationship = new ManyToManyRelationshipMetadata { SchemaName = "new_accounts_campaigns", Entity1LogicalName = "account", Entity1AssociatedMenuConfiguration = new AssociatedMenuConfiguration { Behavior = AssociatedMenuBehavior.UseLabel, Group = AssociatedMenuGroup.Details, Label = new Label("Account", 1033), Order = 10000 }, Entity2LogicalName = "campaign", Entity2AssociatedMenuConfiguration = new AssociatedMenuConfiguration { Behavior = AssociatedMenuBehavior.UseLabel, Group = AssociatedMenuGroup.Details, Label = new Label("Campaign", 1033), Order = 10000 } } }; CreateManyToManyResponse createManytoManyRelationshipResponse = (CreateManyToManyResponse)_serviceProxy.Execute( createManyToManyRelationshipRequest); _manyToManyRelationshipId = createManytoManyRelationshipResponse.ManyToManyRelationshipId; _manyToManyRelationshipName = createManyToManyRelationshipRequest.ManyToManyRelationship.SchemaName; Console.WriteLine( "The many-to-many relationship has been created between {0} and {1}.", "account", "campaign"); } //</snippetWorkWithRelationships2> // Publish the customization changes. _serviceProxy.Execute(new PublishAllXmlRequest()); //<snippetWorkWithRelationships.RetrieveRelationship> //You can use either the Name or the MetadataId of the relationship. //Retrieve the One-to-many relationship using the MetadataId. RetrieveRelationshipRequest retrieveOneToManyRequest = new RetrieveRelationshipRequest { MetadataId = _oneToManyRelationshipId }; RetrieveRelationshipResponse retrieveOneToManyResponse = (RetrieveRelationshipResponse)_serviceProxy.Execute(retrieveOneToManyRequest); Console.WriteLine("Retrieved {0} One-to-many relationship by id", retrieveOneToManyResponse.RelationshipMetadata.SchemaName); //Retrieve the Many-to-many relationship using the Name. RetrieveRelationshipRequest retrieveManyToManyRequest = new RetrieveRelationshipRequest { Name = _manyToManyRelationshipName}; RetrieveRelationshipResponse retrieveManyToManyResponse = (RetrieveRelationshipResponse)_serviceProxy.Execute(retrieveManyToManyRequest); Console.WriteLine("Retrieved {0} Many-to-Many relationship by Name", retrieveManyToManyResponse.RelationshipMetadata.MetadataId); //</snippetWorkWithRelationships.RetrieveRelationship> DeleteRequiredRecords(promptForDelete); } } // Catch any service fault exceptions that Microsoft Dynamics CRM throws. catch (FaultException<Microsoft.Xrm.Sdk.OrganizationServiceFault>) { // You can handle an exception here or pass it back to the calling method. throw; } }
internal override OrganizationRequest Map(object[] dataRowValues) { var request = new CreateManyToManyRequest { ManyToManyRelationship = new ManyToManyRelationshipMetadata { Entity1AssociatedMenuConfiguration = new AssociatedMenuConfiguration { Behavior = AssociatedMenuBehavior.DoNotDisplay, Group = AssociatedMenuGroup.Details, Order = 10000 }, Entity2AssociatedMenuConfiguration = new AssociatedMenuConfiguration { Behavior = AssociatedMenuBehavior.DoNotDisplay, Group = AssociatedMenuGroup.Details, Order = 10000 } } }; foreach (var column in Columns) { var value = dataRowValues[column.Position - 1]; var field = (ConfigurationFile.ManyToManyFields)column.TargetField; if (value != null) { switch (field) { case ConfigurationFile.ManyToManyFields.SolutionUniqueName: request.SolutionUniqueName = value as string; break; case ConfigurationFile.ManyToManyFields.Entity1LogicalName: request.ManyToManyRelationship.Entity1LogicalName = (value as string).ToLower(); break; case ConfigurationFile.ManyToManyFields.Entity1MenuBehavior: request.ManyToManyRelationship.Entity1AssociatedMenuConfiguration.Behavior = (AssociatedMenuBehavior)EnumUtils.GetSelectedOption(field, value); break; case ConfigurationFile.ManyToManyFields.Entity1MenuGroup: request.ManyToManyRelationship.Entity1AssociatedMenuConfiguration.Group = (AssociatedMenuGroup)EnumUtils.GetSelectedOption(field, value); break; case ConfigurationFile.ManyToManyFields.Entity1MenuCustomLabel: request.ManyToManyRelationship.Entity1AssociatedMenuConfiguration.Label = new Label(value as string, LcId); break; case ConfigurationFile.ManyToManyFields.Entity1MenuOrder: request.ManyToManyRelationship.Entity1AssociatedMenuConfiguration.Order = Convert.ToInt32(value); break; case ConfigurationFile.ManyToManyFields.Entity2LogicalName: request.ManyToManyRelationship.Entity2LogicalName = (value as string).ToLower(); break; case ConfigurationFile.ManyToManyFields.Entity2MenuBehavior: request.ManyToManyRelationship.Entity2AssociatedMenuConfiguration.Behavior = (AssociatedMenuBehavior)EnumUtils.GetSelectedOption(field, value); break; case ConfigurationFile.ManyToManyFields.Entity2MenuGroup: request.ManyToManyRelationship.Entity2AssociatedMenuConfiguration.Group = (AssociatedMenuGroup)EnumUtils.GetSelectedOption(field, value); break; case ConfigurationFile.ManyToManyFields.Entity2MenuCustomLabel: request.ManyToManyRelationship.Entity2AssociatedMenuConfiguration.Label = new Label(value as string, LcId); break; case ConfigurationFile.ManyToManyFields.Entity2MenuOrder: request.ManyToManyRelationship.Entity2AssociatedMenuConfiguration.Order = Convert.ToInt32(value); break; case ConfigurationFile.ManyToManyFields.SchemaName: request.ManyToManyRelationship.SchemaName = value as string; break; case ConfigurationFile.ManyToManyFields.IntersectEntitySchemaName: request.IntersectEntitySchemaName = value as string; break; case ConfigurationFile.ManyToManyFields.Searchable: request.ManyToManyRelationship.IsValidForAdvancedFind = (bool)EnumUtils.GetSelectedOption(field, value); break; } } else if (!EnumUtils.IsOptional(field)) { throw new ArgumentException($"Mandatory data field {EnumUtils.Label(field)} does not contain a value."); } } return(request); }