Group caching: remove additional filter when leaving context (basic)

Uncategorized

For smartlists we introduced a new property which allows to not persist additional filters.

By default smartlists are created in the old way where additional filters are saved to the database.  Using the API script (example will be provided below) smartlist can be set to non-persisted.

Non-persisted means that additional filter data (filters, columns, view, number of the items per page, sorting) are cleared after a timeout. This timeout  is a new  system parameter RefinesSelectionExpirationTimeout with Id = 397 and default value 120 minutes.

The only thing that remains stored on non-persisted smartlists is column sizes, when no columns where added or removed to the additional smartlist.

If a user has logged out, his temporal additional filter data is cleared (with the exception of column size).

Example script that updates Smartlist with id 1953 to non-persisted mode and sets RefinesSelectionExpirationTimeout to 1 minute. Can be run as 1-time execution formula on the Formula page.

Note: If smartlist persistance changed by the script, for users who has this smartlist opened in the broser, smartlist view cannot  be changed untill the page refresh. 

using TenForce.Execution.Api2;
using TenForce.Execution.Api2.Objects;
namespace TenForce.Execution.Scripting
{
    public class ExampleScript : Script<ScriptContext>
    {
        private const int SmartlistId = 1953; //id of the Smartlist in the url
        private const string Timeout = "1";//minutes
        private const bool PersistUserSettings = false; //parameter indicating if filter data will be persisted
        private readonly IApi _api = Factory.Instance;
        [EntryPoint]
        public void RunCode()
        {
            ISmartListProvider smartListProvider = _api.SmartLists;
            IParameterProvider parametersProvider = _api.Parameters;
            var parameter = parametersProvider.Read(397);
            if (parameter.Id > 0)
            {
                AddFeedBack("Timeout parameter is = "+parameter.Value + ".");
                if (!Timeout.Equals(parameter.Value))
                {
                    parameter.Value = Timeout;
 
                    if (parametersProvider.Update(parameter))
                    {
                        AddFeedBack("Timeout parameter is updated to " + parameter.Value + ".  Done.");
                    }
                    else
                        AddFeedBack("Exception" + parametersProvider.ErrorMessage);
                }
            }
            else
            {
                AddFeedBack("Exception" + parametersProvider.ErrorMessage);
            }
 
            SmartList smartList = smartListProvider.Read(SmartlistId);
            if (smartList.Id > 0)
            {
                if (smartList.PersistUserRefinings != PersistUserSettings)
                {
                    smartList.PersistUserRefinings = PersistUserSettings;
 
                    if (smartListProvider.Update(smartList))
                    {
                        AddFeedBack("Smart list is updated");
                    }
                    else
                        AddFeedBack("Exception" + smartListProvider.ErrorMessage);
                }
            }
            else
            {
                AddFeedBack("Exception" + smartListProvider.ErrorMessage);
            }
        }
    }
}