CreateOneToManyRequest

// ** CreateOneToManyRequest **

// creates an entity relationship between Account and Campaign entities by using CreateOneToManyRequest

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.Cascade,

                    Delete = CascadeType.Cascade,

                    Merge = CascadeType.Cascade,

                    Reparent = CascadeType.Cascade,

                    Share = CascadeType.Cascade,

                    Unshare = CascadeType.Cascade

                }

            },

            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)_service.Execute(createOneToManyRelationshipRequest);