About assigning users and groups in the XML

You can assign users or groups to data filters in the XML, as an alternative to doing this through the user interface. Assigning users and groups to data filters in the XML is available only when you use manual specification to create the data filters.

You can use a wild card, #user_login#, that automatically creates data filters based on the user's Unica Platform login name.

You use the AddAssignments XML element block to associate users or groups with your data filters.

Scenario used in the example

The example uses the following scenario.

An organization uses Unica Collaborate and wants to create data filters that allow field marketers to see only the customers in the region to which they are assigned. Thus, each user requires his or her own data filter.

In Unica Collaborate the list display and the form templates are set up based on region. This configuration is described in more detail in the Unica Collaborate Administrator's Guide.

The audience level is Customer.

The data filters are created against four tables in the exampleSchema database, as described in the following table.

Table 1. Tables and fields used in the examples
Table Fields
exampleSchema.Corporate_Lists UserID, State, and RegionID

This is the list display table set up in Unica Collaborate. The UserID column contains the Unica Platform login names of the field marketers. This table associates field marketer Unica Platform login names with their assigned region.

exampleSchema.customer_contact Indiv_ID, Region_ID, and State fields for customers
exampleSchema.lkup_state A lookup table for the state_name field
exampleSchema.lkup_region A lookup table for the region_id field

Example: Using the wild card to assign group members to data filters

To create a separate data filter for each member of a specified group, you do the following.

  • Create logical fields as usual.
  • Create a single data filter with the wild card #user_login# in the expression element.
  • Under the AssignmentByName element, set the principalType to 2, set the principalName element to the group name, and set the dataObjectId element to the ID of the wild card data filter.
  • Create audience associations as usual.

The following XML illustrates this method, using the scenario described above.


<ExecuteBatch>
                <!-- ********************************** -->
                <!--          Data configuration        -->
                <!-- ********************************** -->
    <name>SeedData</name>
    <operations>
        <ExecuteBatch>
            <name>DataFiltering</name>
            <operations>
                <AddDataConfiguration>
                    <dataConfiguration>
                        <id>1</id>
                        <name>collaborate</name>
                    </dataConfiguration>
                </AddDataConfiguration>
            </operations>
        </ExecuteBatch>
                <!-- ********************************** -->
                <!--         Logical fields             -->
                <!-- ********************************** -->        
        <AddLogicalFields>
            <logicalFields>
                <LogicalField>
                    <id>1</id>
                    <name>Customer_ID</name>
                    <type>java.lang.String</type>
                </LogicalField>

                <LogicalField>
                    <id>2</id>
                    <name>AudienceLevel</name>
                    <type>java.lang.String</type>
                </LogicalField>

                <LogicalField>
                    <id>3</id>
                    <name>UserID</name>
                    <type>java.lang.String</type>
                </LogicalField>

                <LogicalField>
                    <id>4</id>
                    <name>State_code</name>
                    <type>java.lang.String</type>
                </LogicalField>

                <LogicalField>
                    <id>5</id>
                    <name>Region</name>
                    <type>java.lang.Long</type>
                </LogicalField>
            </logicalFields>
        </AddLogicalFields>
                <!-- ********************************** -->
                <!--       Wild card data filter        -->
                <!-- ********************************** -->
        <AddDataFilters>
            <dataFilters>
                <DataFilter><
                    <configId>1</configId>
                    <id>1</id>
                    <fieldConstraints>
                        <FieldConstraint>
                            <logicalFieldId>3</logicalFieldId>
                            <expression>#user_login#</expression>
                        </FieldConstraint>
                    </fieldConstraints>
                </DataFilter>
            </dataFilters>
        </AddDataFilters>
                <!-- ********************************************************* -->
                <!--                     Add data tables                       -->
                <!-- ********************************************************* -->

        <ExecuteBatch>
            <name>addTables</name>
            <operations>
                <!-- ********************************************************* -->
                <!--           Table exampleSchema.Corporate_Lists             -->
                <!-- ********************************************************* -->
                 <AddDataTable>
                    <dataTable>
                        <id>1</id>
                        <name>exampleSchema.Corporate_Lists</name>
                        <fields>
                            <TableField>
                                <tableId>1</tableId>
                                <name>UserID</name>
                                <logicalFieldId>3</logicalFieldId>
                            </TableField>
                            <TableField>
                                <tableId>1</tableId>
                                <name>State</name>
                                <logicalFieldId>4</logicalFieldId>
                            </TableField>
                            <TableField>
                                <tableId>1</tableId>
                                <name>Region_ID</name>
                                <logicalFieldId>5</logicalFieldId>
                            </TableField>
                        </fields>
                    </dataTable>
                </AddDataTable>
                <!-- ********************************************************* -->
                <!--           Table exampleSchema.customer_contact            -->
                <!-- ********************************************************* -->
                <AddDataTable>
                    <dataTable>
                        <id>2</id>
                        <name>exampleSchema.customer_contact</name>
                        <fields>
                            <TableField>
                                <tableId>2</tableId>
                                <name>Indiv_ID</name>
                                <logicalFieldId>1</logicalFieldId>
                            </TableField>
                            <TableField>
                                <tableId>2</tableId>
                                <name>Region_ID</name>
                                <logicalFieldId>5</logicalFieldId>
                            </TableField>
                            <TableField>
                                <tableId>2</tableId>
                                <name>State</name>
                                <logicalFieldId>4</logicalFieldId>
                            </TableField>
                        </fields>
                    </dataTable>
                </AddDataTable>
                <!-- ********************************************************* -->
                <!--              Table exampleSchema.lkup_state               -->
                <!-- ********************************************************* -->
                <AddDataTable>
                    <dataTable>
                        <id>3</id>
                        <name>example.schema.lkup_state</name>
                        <fields>
                            <TableField>
                                <tableId>3</tableId>
                                <name>state_name</name>
                                <logicalFieldId>4</logicalFieldId>
                            </TableField>
                        </fields>
                    </dataTable>
                </AddDataTable>
                <!-- ********************************************************* -->
                <!--              Table exampleSchema.lkup_region              -->
                <!-- ********************************************************* -->
                <AddDataTable>
                    <dataTable>
                        <id>4</id>
                        <name>exampleSchema.lkup_region</name>
                        <fields>
                            <TableField>
                                <tableId>4</tableId>
                                <name>Region_ID</name>
                                <logicalFieldId>5</logicalFieldId>
                            </TableField>
                        </fields>
                    </dataTable>
                </AddDataTable>
            </operations>
        </ExecuteBatch>
                <!-- ********************************************************* -->
                <!--              Audience table associations                  -->
                <!-- ********************************************************* -->
        <ExecuteBatch>
            <name>addAudiences</name>
            <operations>
                <AddAudience>
                    <audience>
                        <id>1</id>
                        <name>Customer</name>
                        <fields>
                            <AudienceField>
                                <logicalFieldId>2</logicalFieldId>
                                <fieldOrder>0</fieldOrder>
                            </AudienceField>
                        </fields>
                    </audience>
                </AddAudience>

                <AddAudience>
                    <audience>
                        <id>2</id>
                        <name>default</name>
                        <fields>
                            <AudienceField>
                                <logicalFieldId>2</logicalFieldId>
                                <fieldOrder>0</fieldOrder>
                            </AudienceField>
                        </fields>
                    </audience>
                </AddAudience>
            </operations>
        </ExecuteBatch>

        <ExecuteBatch>
            <name>addAudienceTableAssociations</name>
            <operations>
                <AddAudienceTableAssociation>
                    <audienceTableAssociation>
                        <audienceId>1</audienceId>
                        <tableId>1</tableId>
                        <configId>1</configId>
                    </audienceTableAssociation>
                </AddAudienceTableAssociation>

                <AddAudienceTableAssociation>
                    <audienceTableAssociation>
                        <audienceId>1</audienceId>
                        <tableId>2</tableId>
                        <configId>1</configId>
                    </audienceTableAssociation>
                </AddAudienceTableAssociation>

                <AddAudienceTableAssociation>
                    <audienceTableAssociation>
                        <audienceId>2</audienceId>
                        <tableId>3</tableId>
                        <configId>1</configId>
                    </audienceTableAssociation>
                </AddAudienceTableAssociation>

                <AddAudienceTableAssociation>
                    <audienceTableAssociation>
                        <audienceId>2</audienceId>
                        <tableId>4</tableId>
                        <configId>1</configId>
                    </audienceTableAssociation>
                </AddAudienceTableAssociation>

            </operations>
        </ExecuteBatch>
                <!-- ********************************************************* -->
                <!--           Link filters (dataObjectId) to group            -->
                <!-- ********************************************************* -->
        <AddAssignments>
            <assignments>
                 <AssignmentByName>
                    <namespaceId>1</namespaceId>
                    <dataObjectId>1</dataObjectId>
                    <principalType>2</principalType>
                    <principalName>FieldMarketer</principalName>
                </AssignmentByName>
            </assignments>
        </AddAssignments>
    </operations>
</ExecuteBatch>