• tvaughan
  • NEWBIE
  • 0 Points
  • Member since 2012

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 2
    Replies

We've got a custom object named SE_Request__c that lets people add a request for support from our sales engineering team.  A request might be something like "I need a demo of xyz, via webex, to client Foo on 2012/03/02"

 

What I'm trying to do is write a trigger on the Object to write a new Event to a shared calendar after insert.  Our SF admin has set up a shared calendar named "Ops Calendar", but I can't figure out how to get a userId from that name for use in creating a new Event object.

 

Here's what I have, with a comment showing where I'm stuck...

 

 

trigger SE_Request_Calendar_Trigger on SE_Request__c (after insert) {
	 list<event> newEvents = new list<event>();
	 
	 string salesOpsCalendar = 'Ops Calendar';

	 for (SE_Request__c seRequest : System.Trigger.new) {
	     try {
	         newEvents.add(new Event(
	             
	             //  How do I convert 'Ops Calendar' to an id that owns our shared calendar?	             
	             OwnerId = ???, 

	             ActivityDateTime = seRequest.Date_of_Requested_Demo__c,

		         DurationInMinutes = 60,

		         // Local or on-site
		         Location = seRequest.Type_of_Demo__c,

		         Subject = 'Give a demo of ' + Products_for_Demo__c + ' for ' + seRequest.Requester_Name__c
		       )
		      );
	     }
	     catch(Exception e){
	         system.debug(e);
	     }
	 } 
	 
	 insert newEvents;
}

 

 

We've got a custom object named SE_Request__c that lets people add a request for support from our sales engineering team.  A request might be something like "I need a demo of xyz, via webex, to client Foo on 2012/03/02"

 

What I'm trying to do is write a trigger on the Object to write a new Event to a shared calendar after insert.  Our SF admin has set up a shared calendar named "Ops Calendar", but I can't figure out how to get a userId from that name for use in creating a new Event object.

 

Here's what I have, with a comment showing where I'm stuck...

 

 

trigger SE_Request_Calendar_Trigger on SE_Request__c (after insert) {
	 list<event> newEvents = new list<event>();
	 
	 string salesOpsCalendar = 'Ops Calendar';

	 for (SE_Request__c seRequest : System.Trigger.new) {
	     try {
	         newEvents.add(new Event(
	             
	             //  How do I convert 'Ops Calendar' to an id that owns our shared calendar?	             
	             OwnerId = ???, 

	             ActivityDateTime = seRequest.Date_of_Requested_Demo__c,

		         DurationInMinutes = 60,

		         // Local or on-site
		         Location = seRequest.Type_of_Demo__c,

		         Subject = 'Give a demo of ' + Products_for_Demo__c + ' for ' + seRequest.Requester_Name__c
		       )
		      );
	     }
	     catch(Exception e){
	         system.debug(e);
	     }
	 } 
	 
	 insert newEvents;
}