Add restrictions to the selection
CS
Initialize and declare the variables
The first few lines of the codes initialize and declare the variables that we plan to use in the code.- storageType - we use the Criteria type since this is a selection
-
providerName - we use
ContactDynamicSelectionsince we plan to create a dynamic selection -
storageKey - we use
selection=61since this will allow us to create a restriction for that particular selection ID. In the statement,selectionis the name of the table and 61 is the primary key ID (selection_id). -
staticColumns - we use
nameandcontactId -
handledColumns - retrieved based on
storageTypeandproviderName
CS
GetSpecifiedCriteriaInformationWithDefaults
CS
Create variable to store restrictions
The next step is to create a variable that could be used to store the restrictions.CS
Dictionary class from the System.Collection.Generic namespace is used to store the restriction as a key-value pair. The key is the name of the field the restriction is on, and the value is the ArchiveRestrictionInfo object that describes the restriction itself.
Once this is done we may add the necessary restrictions as shown below.
CS
Save
Once all the required restrictions have been added the created restriction can be saved by executing the following statement.CS
Though we have added only 2 restrictions explicitly, it can be seen that there are many conditions. This is because we have got the criteria with the
GetSpecifiedCriteriaInformationWithDefaults method, which returns all criteria with default values. However, this would not be affecting the outcome of the selection since the other criteria are not active - they have no values to search for.View the result with SelectionAgent or ArchiveAgent
We may also be able to view the results of the restriction with theSelectionAgent or the ArchiveAgent.
The following code shows how we can use the SelectionAgent to retrieve information about the particular selection.
ArchiveAgent. After authenticating, set the parameters like below.
CS
GetArchiveListByColumns() and follow the patten for getting selection members.
Output: