Create a set programmatically

In answering a recent question, I provided an example of how to create a set programmatically.  Creating a set is no different than creating a group or person with one caveat.  A set requires a display name and a filter.  The display name is a simple string as expected, but the filter is a string that must contain a WS-Enumeration filter element.  Looking at schema alone you – and I – would assume to simply provide the XPath filter in the attribute value.  Instead you must wrap the XPath filter in the XML WS-Enumeration filter element.

Here is a working example from Release Candidate of ILM “2’ and the public client:

ResourceManagementObject rmObject = new ResourceManagementObject("Set");

rmObject["DisplayName"] = new ResourceManagementAttribute("DisplayName", "CreatedSet");

rmObject["Filter"] = new ResourceManagementAttribute("Filter", "<Filter xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" Dialect=\"http://schemas.microsoft.com/2006/11/XPathFilterDialect\" xmlns=\"http://schemas.xmlsoap.org/ws/2004/09/enumeration\">/Person</Filter>");

 

String newGroupId = transferClient.Create(rmObject);

Hope that helps!