Developer forum

Forum » Development » User Addin that has User object without loading all the CustomFieldValues

User Addin that has User object without loading all the CustomFieldValues

Rui Silva
Reply

I've made a User add in to export the user to an external endpoint and notice that the user object does not load all the custom fields values.

To a better understanding I've made the screencast: http://screencast.com/t/VazeeowYl

Can you verify if this is the correct behavior that I should expect?

Best,

Rui Silva

 


Replies

 
Dmitriy Benyuk
Reply

Hi Rui,
it is not clear what is on right side of your Linq expression, since it is not visible on the video.
The problem may be because of the cached user, The DataContext.Datasource User and User.GetUserById returns the same cached user,
so when you get user from the sql it is not from the cache.
Could write your Linq statements?
Regards, Dmitrij

 
Rui Silva
Reply

Hi Dmitriy,

Here is the method code:

        private void SyncObject(object sender, EventArgs e)
        {
            bool bResult;
            string sObject = "object";

            if (base.Ribbon.DataContext.DataSource is User)
            {
                var source = (User)Ribbon.DataContext.DataSource;
#if DEBUG
                System.Diagnostics.Debug.WriteLine("(AddIn object) fields without value = {0}", source.CustomFieldValues.Count(x => x.Value == null));
                source = User.GetUserByID(source.ID);
                System.Diagnostics.Debug.WriteLine("(User object) fields without value = {0}", source.CustomFieldValues.Count(x => x.Value == null));
#endif
                source = User.GetUserBySql("select * from accessuser au where au.AccessUserID = " + source.ID);
#if DEBUG
                System.Diagnostics.Debug.WriteLine("(UserSql object) fields without value = {0}", source.CustomFieldValues.Count(x => x.Value == null));
#endif
                bResult = source.SynchronizeUsingLiveIntegration();
                sObject = "User";
            }
            else if (base.Ribbon.DataContext.DataSource is Group)
            {
                var source = (Group)base.Ribbon.DataContext.DataSource;
                bResult = source.SynchronizeUsingLiveIntegration();
                sObject = "Group";
            }
            else
                return;

            HttpContext.Current.Session[SessionKey] = string.Format("The {0} has {1} sync with the ERP!", sObject,
                bResult ? "successfully" : "unsuccessfully");
        }


 

 
Dmitriy Benyuk
Reply

Hi Rui,
I was not able reproduce this, all statements returned me same zero values. What version of Dynamicweb are you using?

 
Rui Silva
Reply

Hi Dmitriy,

I've test this in 2 version 8.8.1.6 and 8.8.1.13. I understand that DW can be caching the User object, but should it not be cached with all the data loaded?

Best,

Rui Silva

 

 

 

You must be logged in to post in the forum