Not getting first time uploaded docs in list items for publishing portal site

Yuvraj Patil 361 Reputation points
2022-09-30T11:46:17.807+00:00

Hello,

I am loading listitem from document lib of publishing portal site and I am not getting any item as list items.
Steps:

  1. Created publishing portal site
  2. Uploaded a doc in documents lib(by default it is checked out, keep it as is).
  3. using CSOM get list items

ListItems says areItemsAvailable true but count of item is zero. I tried same on other sample application there is it working fine. so not sure what is happening. PFA for the quick watch of listitems.

The issue is with first time uploaded docs. If we checkin then we get as listitems and if after checkin again checkout then we get as list items.

Issue is facing when tried with bearer token. If I give credentials then it works fine. Could be some issue with token.

246501-temp.png

site = clientContext.Site.OpenWebById(ParentSiteID);  
list = site.Lists.GetById(ListId);  
clientContext.Load(list);  
clientContext.ExecuteQuery();  
  
// Load the items.  
camlQuery = new CamlQuery();  
camlQuery.ViewXml= "<View Scope=\'RecursiveAll\'><RowLimit>1000</RowLimit></View>";   
ListItemCollection listItems = list.GetItems(camlQuery);  
clientContext.Load(listItems);  
clientContext.ExecuteQuery();  

@RaytheonXie_MSFT

Thanks!

SharePoint Development
SharePoint Development
SharePoint: A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.Development: The process of researching, productizing, and refining new or existing technologies.
2,666 questions
SharePoint Server Development
SharePoint Server Development
SharePoint Server: A family of Microsoft on-premises document management and storage systems.Development: The process of researching, productizing, and refining new or existing technologies.
1,573 questions
{count} votes

Accepted answer
  1. RaytheonXie_MSFT 31,071 Reputation points Microsoft Vendor
    2022-10-05T07:36:42.027+00:00

    Hi @Yuvraj Patil ,
    Per my test, I agree with your guess.

    Web web = cc.Site.OpenWebById(new Guid("xxxxxx-e733-47a2-b7ca-f6f6368092c1"));  
    List list = web.Lists.GetById(new Guid("xxxx-b29c-4f2c-93d9-4440794408f0"));  
    cc.Load(list);  
    cc.ExecuteQuery();  
      
    CheckedOutFileCollection files = list.GetCheckedOutFiles();  
      
    cc.Load(files);  
    cc.ExecuteQuery();  
      
    Console.WriteLine("GetCheckedOutFiles() method result ------------------->" + files.Count);  
    

    First I upload a file and it's checked out as default. Then the code returns 1 as result. Then I check in and check out the file, the result turns out to be 0
    247683-image.png


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.



0 additional answers

Sort by: Most helpful