I am updating a document and I try to check it out first. If it is already checked out by the current user I do nothing. If it is not checked out I check it out. For this I have the following code to get the checked out user -
var item = list.GetItemById(ItemId); clientContext.Load(item.File, f => f.CheckedOutByUser.LoginName); clientContext.ExecuteQuery();
Since the document is not checked out the server side object is null and 'ClientObject.m_setAsNull' base member is set to true. After checking out the document I try to get the 'CheckedOutByUser.LoginName' value using the following code
var item = list.GetItemById(ItemId); clientContext.Load(item.File.CheckedOutByUser); clientContext.ExecuteQuery();
This loads all the scalar properties of the 'User' object but the 'ClientObject.m_setAsNull' is not reset to false. Hence even though the LoginName property exists in the internal dictionarty I get the ServerObjectNullReferenceException.
Any idea how I should achieve what I want - Get the checkedout user when the value was null previously?