Change defaults on calendar object - Forum - Rollbase - Progress Community

Change defaults on calendar object

 Forum

Change defaults on calendar object

  • I'd like to change the default for the types of records displayed as well as display only my tasks and events by default.  Is there a way to change these onload of the tab since they aren't in the calendar configuration?

  • Hi Jason,

    I have verified that the filter options are not available in the configuration of the calendar component. You can post this as an enhancement request to the ideas section of Rollbase.

    I will check for a workaround solution to this limitation and let you know how it goes.


    Regards,
    Godfrey
  • I thought that might be the case. I'm hoping I can write something in the on load section of that tab to change the value in the interim.  If you find something, please advice.

    Thanks,

    Jason

  • Adding a code to the onload section of the calendar page does not actually solve the problem because the calendar component takes a few seconds to load completely. A part of the code could run prior to the loading of the calendar component.

    Even so, I was able to find a workaround using undocumented functions from the JS libraries used by Rollbase. Please paste the code below your calendar:

    <script type="text/javascript">
    function setCalendarFilters() {
    	/* 
    	Description: Use to set 'Show' filter
    	Possible values for objectFilter variable:
    	 1. -1 => All Tasks & Events
    	 2. -10 => All Tasks
    	 3. -20 => All Events
    	 4. <Object Definition ID> => Specific Object(e.g 110006390) 
    	*/
    	var objectFilter = '110006358';
    	$("#rbe_objectsFilter").val(objectFilter);
    	
    	/* 
    	Description: Use to set 'Assigned To' filer
    	Possible values for assignedToFilter variable:
    	 1. Me => Only Me
    	 2. ALL_USERS => Any Users
    	 3. R<Role ID> => Specific role(e.g R90)
    	 4. G<Group ID> => Specific group(e.g G110007529)
    	*/
    	var assignedToFilter = 'R90';
    	$("#rbe_assignedToFilter").val(assignedToFilter);
    	
    	rbf_refreshData();
    }
    
    rbf_addOnLoadMethod(setCalendarFilters);
    </script>

    Note: You will have to manually change the value objectFilter and assignedToFilter variables depending on the filter you need. 

    Please remember that undocumented functions can change between major version releases. Its usage is not recommended but so far this is the only workaround solution I can provide.

  • I added this code as a script component on the home page below my calendar.  It appears to correctly change the values in the combo boxes, but the calendar refresh finished first and had data based on the default values.  Am I missing something in how I have this set up?

  • The workaround was setup correctly because the result you had is the expected behavior. The code updates the default filter and then reloads the calendar using the new filter values.

  • This isn't reloading with the new filters.  It still shows the old data based on any users.

    My initial login shows the combo boxes are correctly defaulted to the values I set in the script component. However, the date showing in tasks on the calendar below is not for my user.

    Now if I click on my browser refresh, the combo boxes are still defaulted correctly and the tasks are updated to remove those that aren't mine. 

    This is what I want to happen upon initial login.

    Make sense?

  • Please replace the content of the script component with the code below:

    <script type="text/javascript">
    function setCalendarFilters() {
    	/* 
    	Description: Use to set 'Show' filter
    	Possible values for objectFilter variable:
    	 1. -1 => All Tasks & Events
    	 2. -10 => All Tasks
    	 3. -20 => All Events
    	 4. <Object Definition ID> => Specific Object(e.g 110006390) 
    	*/
    	var objectFilter = '110006358';
    	$("#rbe_objectsFilter").val(objectFilter);
    	
    	/* 
    	Description: Use to set 'Assigned To' filer
    	Possible values for assignedToFilter variable:
    	 1. Me => Only Me
    	 2. ALL_USERS => Any Users
    	 3. R<Role ID> => Specific role(e.g R90)
    	 4. G<Group ID> => Specific group(e.g G110007529)
    	*/
    	var assignedToFilter = 'Me';
    	$("#rbe_assignedToFilter").val(assignedToFilter);
    }
    
    
    rbf_addOnLoadMethod(setCalendarFilters);
    rbf_addOnLoadMethod(rbf_refreshData);
    </script>

    Let me know if it works.

  • Unfortunately it is still not working.  Same result.

  • I'm experiencing the same situation, but the page loads with the correct filters set and applied for about 2.5 seconds, then it pulls in all tasks and events for all users (defaults). I have tried adding the code to both the page onload and as a script component, but it didn't make a difference.

  • Mine does the same thing.  It appears to happen at login that way for me. If I refresh the page after login, it correctly displays.  

  • Adding a 1-second delay on the code might do the trick. Please try the code below and adjust the 'delayInMilliseconds' as needed:

    <style>body { display: none; }</style>
    <script type="text/javascript">
    function setCalendarFilters() {
    	/* 
    	Description: Use to set 'Show' filter
    	Possible values for objectFilter variable:
    	 1. -1 => All Tasks & Events
    	 2. -10 => All Tasks
    	 3. -20 => All Events
    	 4. <Object Definition ID> => Specific Object(e.g 110006390) 
    	*/
    	var objectFilter = '-20';
    	$("#rbe_objectsFilter").val(objectFilter);
    	
    	/* 
    	Description: Use to set 'Assigned To' filer
    	Possible values for assignedToFilter variable:
    	 1. Me => Only Me
    	 2. ALL_USERS => Any Users
    	 3. R<Role ID> => Specific role(e.g R90)
    	 4. G<Group ID> => Specific group(e.g G110007529)
    	*/
    	var assignedToFilter = 'Me';
    	$("#rbe_assignedToFilter").val(assignedToFilter);
    }
    
    function delayedRefresh() {
    	delayInMilliseconds = 1000;
    	setTimeout(function() {
    		rbf_refreshData();
    		$('body').show();	
    	}, delayInMilliseconds);
    }
    
    rbf_addOnLoadMethod(setCalendarFilters);
    rbf_addOnLoadMethod(delayedRefresh);
    </script>

  • It seems that a 3500 millisecond delay has been working pretty consistently so far without being too intrusive. 4000 milliseconds was a bit annoying, but it does refresh the whole page.  Can $('body').show(); be replaced with whatever designates the calendar component?

  • That did it for me.  Thank you very much for your help.

  • This version hides the section of the calendar component instead of the whole body. Since the code used to hide the calendar component is JavaScript, there might be a short execution delay. 

    <script type="text/javascript">
    calendarSectionName = 'Calendar';
    
    function setCalendarFilters() {
    	/* 
    	Description: Use to set 'Show' filter
    	Possible values for objectFilter variable:
    	 1. -1 => All Tasks & Events
    	 2. -10 => All Tasks
    	 3. -20 => All Events
    	 4. <Object Definition ID> => Specific Object(e.g 110006390) 
    	*/
    	var objectFilter = '-20';
    	$("#rbe_objectsFilter").val(objectFilter);
    	
    	/* 
    	Description: Use to set 'Assigned To' filer
    	Possible values for assignedToFilter variable:
    	 1. Me => Only Me
    	 2. ALL_USERS => Any Users
    	 3. R<Role ID> => Specific role(e.g R90)
    	 4. G<Group ID> => Specific group(e.g G110007529)
    	*/
    	var assignedToFilter = 'Me';
    	$("#rbe_assignedToFilter").val(assignedToFilter);
    }
    
    function delayedRefresh() {
    	delayInMilliseconds = 1000;
    	setTimeout(function() {
    		rbf_refreshData();
    		$("div[name='"+calendarSectionName+"']").show();	
    	}, delayInMilliseconds);
    }
    
    $("div[name='"+calendarSectionName+"']").hide();
    rbf_addOnLoadMethod(setCalendarFilters);
    rbf_addOnLoadMethod(delayedRefresh);
    </script>

    Please change the value of 'calendarSectionName' with the section name of calendar component.