Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Outlook categories - include or exclude from sync #313

Closed
workjoeea opened this issue Feb 7, 2023 · 12 comments
Closed

Outlook categories - include or exclude from sync #313

workjoeea opened this issue Feb 7, 2023 · 12 comments

Comments

@workjoeea
Copy link

Is there a way to include or exclude certain categories from an Outlook calendar from syncing?

@jonas0b1011001
Copy link
Collaborator

Until we have a more sophisticated filtering option implemented you can manually add filters in Helpers.gs L184

result = result.filter(function(event){
    try{
      return (event.getFirstPropertyValue('categories').toString() != "Category to exclude");
    }catch(e){
      return true;
    }
  });

@workjoeea
Copy link
Author

thank you @jonas0b1011001 ...this is excellent. I'm not against doing things manually, but I'm a little confused as to execution. I would have to add this string for every category that I'd like to exclude? That's okay, I just need to know the process. Thank you.

@jonas0b1011001
Copy link
Collaborator

If you need to exclude multiple categories:
return !(["exclude 1","exclude 2","exclude 3"].includes(event.getFirstPropertyValue('categories').toString()));

or to only sync specific caategories:
return (["include 1","include 2","include 3"].includes(event.getFirstPropertyValue('categories').toString()));

@workjoeea
Copy link
Author

@jonas0b1011001 thank you for that clarification.

@workjoeea
Copy link
Author

workjoeea commented Feb 24, 2023

Ok, I gave it a try, tells me syntax error. So I clearly misunderstand something. Here's my line 184-190:

result = result.filter(function(event){
    try{
      return !(["Blue category","Yellow category","Green category","Orange category","Purple category","Red category"].includes(event.getFirstPropertyValue('categories').toString() != "Category to exclude");
    }catch(e){
      return true;
    }
  });

Thank you for your help so far.

@jonas0b1011001
Copy link
Collaborator

Should be

result = result.filter(function(event){
    try{
      return !(["Blue category","Yellow category","Green category","Orange category","Purple category","Red category"].includes(event.getFirstPropertyValue('categories').toString()));
    }catch(e){
      return true;
    }
  });

@workjoeea
Copy link
Author

Ok, so I copied and pasted exactly this code to line 184 in helper.gs, and yet the excluded categories still sync. Thoughts?

@jonas0b1011001
Copy link
Collaborator

Download your *.ics, open it in a texteditor and check if outlook is actually using the categories parameter, might be some nonstandard outlook parameter. If so, change the getFirstPropertyValue('categories') accordingly.

@workjoeea
Copy link
Author

Thanks for that tip. I don't see "Categories" anywhere, nevermind a parameter that shows any of the colors (I just searched the text). Is there a way for me to make Outlook generate that in the ICS file? Or is there another solution?

@jonas0b1011001
Copy link
Collaborator

I don't know much about outlook, maybe @derekantrican has an idea.

@cephas20012
Copy link

Hi, I'm trying to follow along too. My work calendar is too detailed to share with my family, I want to just share the Personal and Info Share categories. I've saved my Outlook ics and verify it is using categories, for example one of my events with this line:
BEGIN:VEVENT
CATEGORIES:Info Share

I tried both ways, listing the include filters with the return ( line or the exclude filters with the return !( line but still all of my calendar is showing up.

There is a block of code for cancelled events from L176-183 already with a result = result.filter(function(event){

I tried just adding my block below at L184, or do I need to edit the cancelled events result.filter?

  result = result.filter(function(event){
    try{
      return (["Personal","Info Share"].includes(event.getFirstPropertyValue('CATEGORIES').toString()));
    }catch(e){
      return true;
    }
  });

@cephas20012
Copy link

Ah! Actually when I saved my ics from Outlook desktop the categories show. But the office365 web link for the ics that I am using in this script does not have categories, even though I have selected to share full details! Hmmm...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

3 participants