Updating Related Users (Array of Guids) doesn't show in

Posted by Community Admin on 04-Aug-2018 18:59

Updating Related Users (Array of Guids) doesn't show in backend

All Replies

Posted by Community Admin on 30-Oct-2017 00:00

Hello all,

I have the below code sample attaching users to a company:

 protected DynamicContent AddUserToCompany(Guid userId, Type companyType)
       
            var manger = DynamicModuleManager.GetManager();

            var identity = ClaimsManager.GetCurrentIdentity();
            DynamicContent companyItem = manger.GetDataItems(companyType)
                        .Where(x => x.Status == Telerik.Sitefinity.GenericContent.Model.ContentLifecycleStatus.Live)
                        .Where(x => x.GetValue<Guid[]>("RelatedUsers").Contains(identity.UserId)).First();

            List<Guid> users = companyItem.GetValue<Guid[]>("RelatedUsers").ToList();
            users.Add(userId);

            companyItem.SetValue("RelatedUsers", users.ToArray());
            manger.Provider.SuppressSecurityChecks = true;
            companyItem.SetWorkflowStatus(manger.Provider.ApplicationName, "Published");
            manger.SaveChanges();
            manger.Provider.SuppressSecurityChecks = false;

            DynamicContent companyItem2 = manger.GetDataItems(companyType)
                        .Where(x => x.Status == Telerik.Sitefinity.GenericContent.Model.ContentLifecycleStatus.Live)
                        .Where(x => x.GetValue<Guid[]>("RelatedUsers").Contains(identity.UserId)).First();
            //need after this for stuff
            return companyItem2;
       

The code saves fine and I can see the changed list programmatically, however the Dynamic content backend UI does not show the added user. It's setup as an array of GUIDs selecting users.

 

This thread is closed