• SkyMatix_Dev
  • NEWBIE
  • 0 Points
  • Member since 2008

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 3
    Replies
I have an class that follows closely to the opportunity wizard code in the cookbook that I have customized to fit...

I have also created a test class to verify... I get 100% coverage when I run it, but when I run all tests for the main class, it is not covering any of the lines.

Any ideas where I am going wrong?


< class code> ---------------------------------
public class newSchedule{

Account a;
Opportunity o;
Event e;


public Account getAccount(){
if(a == null) a = new Account();
return a;
}

public Opportunity getOpportunity(){
if(o == null) o = new Opportunity();
return o;
}

public Event getEvent(){
if(e == null) e = new Event();
return e;
}


public PageReference save() {

//Insert Account
insert a;

//Opportunity ID = Account ID

o.accountId = a.id;

//Set the Opportunity Stage
o.stageName = 'Scheduled';


datetime d = o.Start_Date__c;
o.closeDate = date.NewInstance(d.year(),d.month(),d.day());

//Set the Opportunity Name
o.name = a.name + '-' + o.closeDate;

insert o; //Insert Opportunity

Event s = new Event(); //Create new instance the Event


e.WhatId = o.accountId; // associates the account
e.ShowAs = 'Busy'; //Set show time as
e.Subject = o.name; // uses the opportunity name as the subject
e.StartDateTime = o.Start_Date__c; // start date time
e.EndDateTime = o.End_Date__c; // end date time

//Create the event
insert e;

//Page Redirect
PageReference confirm = new PageReference('/apex/' + 'confirm_page');
Scheduler_confirm.setRedirect(true);
return confirm;

}

}


< TEST class code> ---------------------------------

@isTest
private class testApex{

static testMethod void validatenewAPEX(){

// declare variables
date d = date.today();
integer i = 1;
datetime dt = datetime.now();


//set variables for account create method and insert
Account a = new Account(name='Test', phone='555-555-5555', Unit__c='a048000000AfPU4');
insert a;

//set variables for opportunity create method and insert
Opportunity o = new Opportunity (Name = 'APEX TEST', Resource__c = 'a0380000005y7jS', StageName='NULL', CloseDate = d);
insert o;

//set variables for event create method and insert
Event e = new Event (subject='TestSubject', DurationInMinutes = i, ActivityDateTime = dt);
insert e;

//Retrieve values from inserted objects.
a = [SELECT name, phone, Unit__c FROM account where Id =: a.id];
o = [SELECT Aircraft__c, Start_Date__c, End_Date__c FROM opportunity where Id =: o.id];
e = [SELECT showAs, subject, startDateTime, endDateTime, DurationInMinutes, ActivityDateTime from event where Id =: e.id];

// Test the values actually being inserted into the objects.
System.assertEquals('Test', a.name);
System.assertEquals('555-555-5555', a.phone);
System.assertEquals('a048000000AfPU4', a.Unit__c);
System.assertEquals('a0380000005y7jS', o.Resource__c);
System.assertEquals('TestSubject', e.subject);
System.assertEquals( i, e.DurationInMinutes);
System.assertEquals(dt, e.ActivityDateTime);


}




}

Message Edited by SkyMatix_Dev on 11-25-2008 11:34 AM
Are datetime fields going to be exposed on a visualforce page accessible via force.com sites when it goes GA?

I am currently building a force.com sites form via VForce and need datetime fields...

Has anyone been able to get around this or have another solution I should try?

Thanks!
Are datetime fields going to be exposed on a visualforce page accessible via force.com sites when it goes GA?

I am currently building a force.com sites form via VForce and need datetime fields...

Has anyone been able to get around this or have another solution I should try?

Thanks!
Hi,
 
Using the API I'm trying to create an event and invite an attendee to that event.
 
I'm finding that I can't create an Event followed by an EventAttendee as I get the following error:
CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY
 
Is it possible to do what I'm looking for?
 
Thanks in advance
Matt
  • November 11, 2008
  • Like
  • 0