4

I have a Calendar in my SharePoint online Project. It has both recurring and none recurring events.

enter image description here

Is there some way that I can make a Column or something, where I can see if it's, is or not a recurring event?

The reason why I need this is that I'm displaying an amount the events in a Template on my page. But I would get a property like Location that contains the information about if the event is or not recurring.

1

The column to the left of the Title column is the recurrence indicator column. Please find the difference below :

enter image description here

UPDATED as per comment :

Client Side Rendering is usually the adopted method to achieve this kind of requirement, however CSR does not work with Calendars. So I have created a JSOM implementation that gets your requriement done.

Since you want the recurrence value to be shown in another column, the below JSOM script that will read the Recurrence column in the calendar(internalName : fRecurrence) and updates the Title column with corresponding value(whether recurring or not).

Use the below code after proper code clean up as it was tested only for functionality implementation and not production ready.

enter image description here

<script language="javascript" type="text/javascript">

$(document).ready(function() {

    SP.SOD.executeOrDelayUntilScriptLoaded(queryListItems, "sp.js");

});
var oWebsite ;

var context; 
function queryListItems() {  
     context = new SP.ClientContext();  

     var list = context.get_web().get_lists().getByTitle('TestCalendar');           
     var caml = SP.CamlQuery.createAllItemsQuery();    

     returnedItems = list.getItems(caml);  
     context.load(returnedItems);            
     context.executeQueryAsync(onSucceededCallback, onFailedCallback);  
  }    

  function onSucceededCallback(sender, args) {  

     var itemArray = [];
     var i =0;
     var enumerator = returnedItems.getEnumerator();  

     while (enumerator.moveNext()) {         
     var listItem = enumerator.get_current();  

     //Remove this alert after testing
     alert('Recurrence: ' + listItem.get_item('fRecurrence') );       

     itemArray[i] = listItem; 
     var value = listItem.get_item('fRecurrence');
     if(value != true)         {
       listItem.set_item('Title', 'Not Recurring!');  
       listItem.update();
     } 
     else{
     listItem.set_item('Title', 'Recurring!');  
       listItem.update();
    }
      context.load(itemArray[i++]);

  }  
    context.executeQueryAsync(onQuerySucceeded, onQueryFailed);
 }  

 function onFailedCallback(sender, args) {  
  alert('Message: ' + args.get_message()); 
}  
function onQuerySucceeded() {
  alert('Items Updated');
}

function onQueryFailed(sender, args) {
alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
}
 </script>

Note : The JSOM code will run on every page load and populate the title column. You will have to check for any other race condition dependencies yourself.

2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.