Forum Discussion

lychee996's avatar
lychee996
Copper Contributor
Jun 27, 2024

Sharepoint list "group by" and "filter" function not working correctly after editing items

Hi everyone!

I currently have a sharepoint list with a column named [Print Status], which has two options [Pending Print] & [Printed]. Previously when i edit all item under [Pending Print] & [Printed], all items will move to the correct group immediately. However, with the new User Interface, I encounted this problem (as shown below), whereby the items will not move to the correct group automatically, and some columns appear as [object Object].

 

^ all items in this example have already been changed to [Printed], but still appears as [Pending Print]

However once i refresh the page, the items move according. Is there any way to fix this such that I don't need a manual refresh for the page everytime? Thanks!

  • NikolinoDE's avatar
    NikolinoDE
    Gold Contributor

    lychee996 

    It looks like you are experiencing a common issue in SharePoint Online where the user interface (UI) does not immediately reflect changes made to list items, especially when using the "group by" and "filter" functions. This issue typically occurs due to the asynchronous nature of SharePoint's modern UI.

    Here is how you can approach resolving this issue:

    Solutions

    1. Use a Custom Script to Force Refresh

    You can use a small script to automatically refresh the view when an item is edited. This can be done by adding a custom script to your SharePoint page or using a SharePoint Framework (SPFx) extension. However, it requires some knowledge of JavaScript and SharePoint development.

    Here is an example of a script that can be used with a content editor web part or a script editor web part:

    Javascript code is untested. Please take all safety precautions before using the code.

     

    (function () {
        var refreshInterval = 3000; // 3 seconds
        var listName = "YourListName"; // Replace with your list name
        var fieldName = "PrintStatus"; // Internal name of the field
    
        function refreshList() {
            var list = SP.ClientContext.get_current().get_web().get_lists().getByTitle(listName);
            var camlQuery = new SP.CamlQuery();
            camlQuery.set_viewXml('<View><Query><Where><Neq><FieldRef Name="' + fieldName + '"/><Value Type="Choice">Pending Print</Value></Neq></Where></Query></View>');
    
            var items = list.getItems(camlQuery);
            var context = SP.ClientContext.get_current();
            context.load(items);
    
            context.executeQueryAsync(
                function() {
                    location.reload();
                },
                function(sender, args) {
                    console.log('Error: ' + args.get_message());
                }
            );
        }
    
        setInterval(refreshList, refreshInterval);
    })();

     

    Replace "YourListName" and "PrintStatus" with the actual internal names of your list and field. Note that this script refreshes the page every 3 seconds if there are any changes. Adjust the interval as needed.

    2. Using Power Automate

    If you prefer not to use custom scripts, you can set up a Power Automate flow to handle the process. This flow will trigger whenever an item in the SharePoint list is modified and can include a step to update another column or perform a minor action to trigger the UI refresh indirectly.

    Here’s how you can create a simple flow:

    1. Create a new flow in Power Automate:
      • Go to Power Automate.
      • Click on Create and choose Automated flow.
    2. Trigger the flow when an item is modified:
      • Choose SharePoint and then When an item is modified.
    3. Add an action to update the item:
      • Add a new step and choose SharePoint - Update item.
      • Configure it to update the same item. You can update a hidden field or a field that does not impact your business logic. This will force SharePoint to refresh the list item in the UI.
    4. Save and test the flow.

    This approach indirectly refreshes the item in the UI, potentially updating the grouping and filtering.

    3. Ensure Modern UI Settings Are Properly Configured

    Make sure that the modern UI settings and views are properly configured:

    1. Check View Settings:
      • Ensure that the view settings in your SharePoint list are properly configured to use modern UI features. Sometimes switching to classic view and back to modern view can resolve UI refresh issues.
    2. Browser Caching:
      • Ensure that browser caching is not causing the issue. Clear the browser cache and see if the issue persists.

    Summary

    The issue you're encountering is related to the asynchronous behavior of SharePoint's modern UI. To resolve this, you can:

    • Use a custom script to automatically refresh the view.
    • Implement a Power Automate flow to indirectly trigger a UI refresh.
    • Ensure that your modern UI settings are properly configured and check browser caching.

    By using these approaches, you can reduce or eliminate the need for manual page refreshes and ensure that your SharePoint list reflects the correct groupings and filters immediately after edits.

     

    NOTE: My knowledge of this topic is limited, but since no one has answered it for at least one day or more, I entered your question in AI. The text and the steps are the result of AI. Maybe it will help you further in your project, if not please just ignore it.

     

    My answers are voluntary and without guarantee!

     

    Hope this will help you.

    Was the answer useful? Mark as best response and Like it!

    This will help all forum participants.

Resources