Utilising the Salesforce Calendar for events has many benefits compared to using Outlook.
One of my clients came across a limitation recently when they create a weekly re-occurring event for their team member. The problem is that when the staff member cannot attend the appointment they then need to re-assign it to someone else.
With the current version of Salesforce you cannot do this, you can only reassign the complete series to someone else.
The good thing is that with a bit of research I found that each occurrence is a record. So my first attempt was to find the event and then using a Visual Force page I asked who they want to reassign it to.
I wrote some Apex code to update the record to the newly assigned user, but the Salesforce business rules do not allow this.
So the solution was to clone the event into a new object, delete the original and insert the new. This worked beautifully.
public class ReassignEventController { public String assignTo { get; set; } public List getUsers() { List options = new List(); for(User u :[SELECT Id, Name FROM User]) { options.add(new SelectOption(u.id, u.Name)); } return options; } public Event getEvent() { return [SELECT Id, Description, Owner.Id, Owner.Name FROM Event WHERE Id = :ApexPages.currentPage().getParameters().get('id')]; } public PageReference reassign() { System.debug('Save clicked: ' + assignTo); Event ev = [SELECT Id, WhoId, WhatId, Subject, Location, IsAllDayEvent, ActivityDateTime, ActivityDate, DurationInMinutes, StartDateTime, EndDateTime, Description, AccountId, OwnerId, Type, IsReminderSet FROM Event WHERE Id = :ApexPages.currentPage().getParameters().get('id')]; ev.OwnerId = assignTo; Event ev2 = ev.clone(false,true); ev2.OwnerId = assignTo; Insert ev2; Delete ev; PageReference redirecturl = new PageReference('/' + ev2.Id); return redirecturl; } }
Once the event has been created then it redirects to the newly created one details page.
The Visual Force page is very simple and I will probably include this in the Event details page.
I hope this helps you if you come across the same situation too. Leave a comment if you need help.
It’s hard to find your articles in google. I found it on 16 spot,
you should build quality backlinks , it will
help you to rank to google top 10. I know how to help you, just search in google
– k2 seo tips
I see a lot of interesting posts on your website.
You have to spend a lot of time writing, i know how to save you a lot of
work, there is a tool that creates high quality, google friendly posts in couple of
minutes, just search in google – k2 unlimited content
I read a lot of interesting posts here. Probably you spend a lot of time writing, i know how
to save you a lot of time, there is an online tool that creates unique, SEO friendly posts in minutes,
just type in google – laranitas free content source
I used to be suggested this web site through my cousin. I’m not certain whether or not this put up
is written by him as nobody else recognise such special about my trouble.
You are incredible! Thanks!