Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This is the code for a page launched from an Event. It links the Event to a custom object Business_trip__c via a junction object Trip_meeting__c using the Event's ID as a text key. I am having issue running the test - I think I am not properly setting the page and am returning the titular error "List has no rows for assignment to SObject" for the EventIdString query.


public class NewTripMeetingExtension {

    private ApexPages.StandardController sc;
    public trip_meeting__c TM {get;set;}
    public List <Event> EventId {get;set;}
    public String EventIdString {get;set;}
    public String EventReference {get;set;}

    public NewTripMeetingExtension (ApexPages.StandardController StandardController) {
        sc = standardController;

        EventIdString = (String)[select id from Event where Id=: (ApexPages.currentPage().getParameters().get('EventId'))].Id;
        Eventreference= [select subject from Event where Id=: (ApexPages.currentPage().getParameters().get('EventId'))].subject;
        TM = new Trip_meeting__c ();


    public PageReference Cancel(){
        PageReference cancelUrl=new PageReference('/'+EventIdString);
        return cancelUrl;

    public PageReference Save(){
        PageReference SaveUrl=new PageReference('/'+EventIdString);
        Trip_meeting__c TM1 = (trip_meeting__c)sc.GetRecord();
        Database.insert(TM1, false);
        return SaveUrl;


Test Code:

public class testNewTripMeetingExtension {
     static testMethod void  testNewTripMeeting(){

        Account acc = new Account(Name='Abce');
        insert acc;

        Account a = new Account (name='Banson Quixotics');
        Insert a;

        Business_trip__c BT = new Business_trip__c (name='Name', Location__c='location', Start_date__c,;
        insert BT;

        Event TestEvent = new Event ();
        TestEvent.subject='meeting subject';
        TestEvent.ActivityDateTime =;
        TestEvent.Description='here are the notes in the field required to be there';
        inSert TestEvent;    

        Trip_meeting__c TM = new Trip_meeting__c();;
        Tm.Meeting__c = String.valueOf(;
        Insert TM;

        PageReference pageRef = Page.NewTripMeetingEntry;   

         ApexPages.StandardController sc = new ApexPages.standardController(TestEvent);
         NewTripMeetingExtension  controller = new NewTripMeetingExtension(sc);



share|improve this question
up vote 1 down vote accepted

Change this line




You don't have to pass ?, = and & when setting.

share|improve this answer
thanks. happy that I got as far as i did – jaw999 Mar 28 at 18:16

instead try this


this will solve your issue..

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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