The following code snippet shows how to get and set values for a User type attribute of data type Set using the SystemWeaver API:
// Setting value. public void SetAttributeValue_OnAttributeWith_DataTypeUser_And_DimensionSet() { // Set up attribute type. var attributeType = SWConnection.Instance.Broker.CreateAttributeType("ABCD", "User", "", SWAttributeDataType.User, SWAttributeDataDimension.Set, null, null); // Create or get users and add them to a Users list. var user1 = SWConnection.Instance.Broker.CreateUser("ch", "Charles", "ABC123"); var user2 = SWConnection.Instance.Broker.CreateUser("ro", "Robin", "DEF456"); //var user1 = SWConnection.Instance.Broker.GetUserWithName("ch"); //var user2 = SWConnection.Instance.Broker.GetUserWithName("ro"); var userList = SWConnection.Instance.Broker.Lists.NewUserList(); userList.Add(user1); userList.Add(user2); // Create item and add an attribute of type ABCD/User. var item = SWConnection.Instance.Broker.TopLibrary.CreateItem("I", "Test Item"); item.AddAttribute(attributeType); IswAttribute attribute = item.GetAttributeOfType(attributeType); // Set users to the attribute. ((IswUserAttribute)attribute).Users = userList; } // Getting value. public void GetAttributeValue_OnAttributeWith_DataTypeUser_And_DimensionSet() { // Get attributeType and item. var attributeType = SWConnection.Instance.Broker.AttributeType("ABCD"); var item = SWConnection.Instance.Broker.GetItem(SWHandleUtility.ToHandle("x0400000123456789")); // Get the attribute from the item and access its users. IswAttribute attribute = item.GetAttributeOfType(attributeType); var users = ((IswUserAttribute)attribute).Users; }