• PranavL
  • NEWBIE
  • 0 Points
  • Member since 2011

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 3
    Replies

We use Common Ground and it uses a field called Head of Household and a field called Primary Contact.
Currently we just want to use the field Primary Contact and move all the information from Head of Household to Primary Contact. That part is easy to handle via data loader.
We also want to modify the Casual Salutation and Formal Salutation to tie with the Primary Contact and not the household contact which is currently done by a managed package trigger.

I wanted to know what would be the best way to update the Casual Salutation Text field which is just the first name of the Primary Contact (lookup field) and formal salutation (which would contain Mr.,Mrs.). I am assuming a trigger. If not please suggest.

Is there any code available that has updated the salutation field by reading from the contacts object salutation and then inserting that to the account's object formal salutation text field?

Thanks for reading.

Hello,

 

I am getting the above failure message in my test code when I am run the tests.

 

The problem area is the submit() function in the test code. When I call the function from the controller it gives me the failure message.

 

System.DmlException: Insert failed. First exception on row 0 with id 001Z0000002ZmiEIAS; first error: INVALID_FIELD_FOR_INSERT_UPDATE, cannot specify Id in an insert call: [Id]

 

TEST CODE IS AS FOLLOWS:

@isTest
public class TSWPageControllerTest {
static testMethod void validateSubmit() {
TSWPagecontroller twsc2 = new TSWPagecontroller();
Account acc123 = new Account();
acc123.Name = 'POLDWE';
acc123.Description ='Hello Description';
acc123.Phone = '4211234552';
insert acc123 ;
twsc2.setAccount(acc123);


//Contact con = [SELECT Id, Name from Contact where LastName <> NULL limit 1 ] ;

Contact con123 = new Contact();
con123.FirstName = '12hiuhi3';
con123.LastName = 'gyuguy';
con123.Email='pranavlal@nowitbhjbjmatters.com';
insert con123 ;
twsc2.setContact(con123);





Event__c e5 = new Event__c(
          Name = 'Test TSW Event123456',
          Type_of_Event__c = 'Interview' ,
          Event_Description__c ='Great Event',
          Is_the_event_open_to_all__c = 'Free to Public',
          Who_do_you_expect_to_come_to_this_event__c = 'Pranav',
          Organization__c = acc123.Id ,
          Contact__c = con123.Id ,
          Expected_Attendance__c = 433,
          What_are_the_alternate_dates_possible__c = '32123'
          
         );
         
        insert e5;
        twsc2.setEvent(e5) ;

Trip__c t5 = new Trip__c(
         Name = 'Test Trip 12ac1234',
         Main_Event__c = e5.id 
         );
         insert t5;
         twsc2.setTrip(t5);
         
        
PageReference Submit= twsc2.Submit();


}
     
     
     
     static testMethod void validateGetters() {
         TSWPagecontroller twsc = new TSWPagecontroller();
         
         twsc.getTrip();
         twsc.getEvent();
         twsc.getSession();
         twsc.getAccount();
         twsc.getContact();
         twsc.getSessionList();
         
         
         
         twsc.step1();
         twsc.step2();
         //twsc.step3();
         twsc.step4();
         twsc.step5();
         twsc.step6();
         
         twsc.addsession();
         twsc.deletecon();
        
         
     }

 

 

CONTROLLER CODE IS AS FOLLOWS:

 

public class TSWPageController {

    public TSWPageController(ApexPages.StandardController controller) {

    }

    Trip__c trip ;
    Event__c event ;
    Event__c event1 ;
    Session__c session ; 
    Message_Template__c message ;
    Media__c media ;
    Account account ;
    Contact contact ;

public String dcid{get;set;} // commandlink delete property
public boolean billcity{get;set;}
    
public List<SelectOption> myList {get; set;}
    public boolean showSection {get; set;}
//    public boolean showContact {get; set;}
    public String SelectedVal {get; set;}
    
list<Session__c> lstacc1 = new list<Session__c>();
    
    public TSWPageController()
    {
        
        
    }
    public Trip__c getTrip(){
        if(trip== null) trip = new Trip__c();
        return trip;
            
    }
    public void setTrip(Trip__c t) { trip = t; }
    
    
     public Event__c getEvent(){
        if(event==null) event = new Event__c();
        return event;
    
    }
    
    public void setEvent(Event__c e) {event = e; }
    public Session__c getSession(){
        if(session== null) session = new Session__c(
        Date_of_Session__c = event.Event_Start_Date__c
        );
        return session;
    }
    
    public void setSession(Session__c s) {session = s ; }
    public Account getAccount(){
        if(account== null) account = new Account();
        return account;
        
    }    
    public void setAccount(Account a) { account = a; }
    public Contact getContact(){
        if(contact== null) contact = new Contact();
        return contact;
    
    }
    public void setContact(Contact c) { contact = c; }
        
       public PageReference step1() {
          return Page.Introduction;
       }
       public PageReference step2() {
                         
          return Page.TripAndContactInformation;
       }
       public PageReference step3() {
       if(trip.Is_Event_and_Organization_address_same__c == true)
       {
       billcity = false ;
       event.Event_City__c = account.billingcity;
       event.Event_State__c = account.billingstate ;
       event.Event_Country__c = account.billingcountry ;
       event.Venue_Name__c = account.name ;
       event.Event_Zip__c = account.BillingPostalCode;
       event.Event_Address__c = account.billingStreet ;
       
       }
       if(trip.Is_Event_and_Organization_address_same__c == false)
       {
       billcity = true ;
       event.Event_City__c = account.billingcity;
       event.Event_State__c = account.billingstate ;
       event.Event_Country__c = account.billingcountry ;
       }
          return Page.EventInformation;
       }
       public PageReference step4() {
       
      event.Trip__c = trip.Id ;
      event.Organization__c = account.Id ;
      event.Contact__c = contact.Id ;
      event.Event_Status__c = 'Incomplete' ;
      
      upsert event ;
      return Page.AddSessions;
       }
   public List<Session__c> getSessionList()
  {
      if(session <> NULL ){
          
     return [select Name, Start_Time__c,Date_of_Session__c,Length_of_session_in_minutes__c,Type_of_Session__c from Session__c where Event_Name__c =: event.id ];
     
     }
     else
     {return NULL ;}
  }
       public PageReference AddSession() {
        
        Session__c se= new Session__c();
        se.Event_Name__c = event.id ;
        se.Name = session.Name;
        se.Date_of_Session__c = session.Date_of_Session__c ;
        se.Type_of_Session__c = session.Type_of_Session__c ;
        se.Start_Time__c = session.Start_Time__c ;
        se.Room_Building__c = session.Room_Building__c ;
        se.Audience_Size__c = session.Audience_Size__c ;
        se.Length_of_session_in_minutes__c = session.Length_of_session_in_minutes__c ;
        se.How_long_do_you_want_Shane_to_talk__c = session.How_long_do_you_want_Shane_to_talk__c ;
        se.What_do_you_want_Shane_to_talk_about__c = session.What_do_you_want_Shane_to_talk_about__c ;
        insert se;
        return NULL;
       
       }     
   public pagereference deleteCon() {
        lstacc1 =[Select Id,Name from Session__c where id=:dcid];
        delete lstacc1;
        return Page.AddSessions; 
    }
          
         
       public PageReference step5() {
          return Page.Confirmation;
       }
       
       public PageReference step6() {
          return Page.ThankYou;
       }
       
       
       public PageReference submit() {
      account.Phone = contact.Phone ;
      insert account;
      contact.AccountId = account.id;
      insert contact;
      trip.Name ='abc' ;
      trip.Stage__c='Requested';
      trip.Main_Event__c = event.id ;
      insert trip;

     
      //Not inserting event here but after adding Event Information field
      event.Trip__c = trip.Id ;
      event.Organization__c = account.Id ;
      event.Contact__c = contact.Id ;
      event.Main_Event__c = true ;
      event.Event_Status__c = 'Request Submitted' ;
      upsert event ; 
      
  upsert trip;
 
       return Page.ThankYou ;      
       
   
    
}

Hello,

 

I am trying to create a custom wizard which has VF pages and contains custom objects

 

One of the custom objects is events.

 

The first VF page header looks like:

 

<apex:page
    showHeader="true" sidebar="false"
    controller="TSWPageController"
    id="Page1"
    standardStylesheets="true"
    cache="false" >
<apex:actionsupport reRender="Page1" />

 

I accpet information as:

 

<apex:pageBlockSection columns="1" >          
                              <apex:inputField value="{!Event__c.Name}" required="True"/>                  
                              <apex:inputField value="{!Event__c.Type_of_Event__c}" required="True"/> 

 

When I click save it asks me if I want to create:

Create Apex method 'TSWPageController.getEvent__c'

 

But I understand that the double underscore is reserved in apex for name and namespaces.

 

When I click on "Create Apex method 'TSWPageController.getEvent__c'" I get the VF error: Invalid identifier: getEvent__c

 

How should I work around this?

 

Any help will be really appreciated.

 

Thanks!

 

Pranav

 

 

 

 

Hello,

 

I am getting the above failure message in my test code when I am run the tests.

 

The problem area is the submit() function in the test code. When I call the function from the controller it gives me the failure message.

 

System.DmlException: Insert failed. First exception on row 0 with id 001Z0000002ZmiEIAS; first error: INVALID_FIELD_FOR_INSERT_UPDATE, cannot specify Id in an insert call: [Id]

 

TEST CODE IS AS FOLLOWS:

@isTest
public class TSWPageControllerTest {
static testMethod void validateSubmit() {
TSWPagecontroller twsc2 = new TSWPagecontroller();
Account acc123 = new Account();
acc123.Name = 'POLDWE';
acc123.Description ='Hello Description';
acc123.Phone = '4211234552';
insert acc123 ;
twsc2.setAccount(acc123);


//Contact con = [SELECT Id, Name from Contact where LastName <> NULL limit 1 ] ;

Contact con123 = new Contact();
con123.FirstName = '12hiuhi3';
con123.LastName = 'gyuguy';
con123.Email='pranavlal@nowitbhjbjmatters.com';
insert con123 ;
twsc2.setContact(con123);





Event__c e5 = new Event__c(
          Name = 'Test TSW Event123456',
          Type_of_Event__c = 'Interview' ,
          Event_Description__c ='Great Event',
          Is_the_event_open_to_all__c = 'Free to Public',
          Who_do_you_expect_to_come_to_this_event__c = 'Pranav',
          Organization__c = acc123.Id ,
          Contact__c = con123.Id ,
          Expected_Attendance__c = 433,
          What_are_the_alternate_dates_possible__c = '32123'
          
         );
         
        insert e5;
        twsc2.setEvent(e5) ;

Trip__c t5 = new Trip__c(
         Name = 'Test Trip 12ac1234',
         Main_Event__c = e5.id 
         );
         insert t5;
         twsc2.setTrip(t5);
         
        
PageReference Submit= twsc2.Submit();


}
     
     
     
     static testMethod void validateGetters() {
         TSWPagecontroller twsc = new TSWPagecontroller();
         
         twsc.getTrip();
         twsc.getEvent();
         twsc.getSession();
         twsc.getAccount();
         twsc.getContact();
         twsc.getSessionList();
         
         
         
         twsc.step1();
         twsc.step2();
         //twsc.step3();
         twsc.step4();
         twsc.step5();
         twsc.step6();
         
         twsc.addsession();
         twsc.deletecon();
        
         
     }

 

 

CONTROLLER CODE IS AS FOLLOWS:

 

public class TSWPageController {

    public TSWPageController(ApexPages.StandardController controller) {

    }

    Trip__c trip ;
    Event__c event ;
    Event__c event1 ;
    Session__c session ; 
    Message_Template__c message ;
    Media__c media ;
    Account account ;
    Contact contact ;

public String dcid{get;set;} // commandlink delete property
public boolean billcity{get;set;}
    
public List<SelectOption> myList {get; set;}
    public boolean showSection {get; set;}
//    public boolean showContact {get; set;}
    public String SelectedVal {get; set;}
    
list<Session__c> lstacc1 = new list<Session__c>();
    
    public TSWPageController()
    {
        
        
    }
    public Trip__c getTrip(){
        if(trip== null) trip = new Trip__c();
        return trip;
            
    }
    public void setTrip(Trip__c t) { trip = t; }
    
    
     public Event__c getEvent(){
        if(event==null) event = new Event__c();
        return event;
    
    }
    
    public void setEvent(Event__c e) {event = e; }
    public Session__c getSession(){
        if(session== null) session = new Session__c(
        Date_of_Session__c = event.Event_Start_Date__c
        );
        return session;
    }
    
    public void setSession(Session__c s) {session = s ; }
    public Account getAccount(){
        if(account== null) account = new Account();
        return account;
        
    }    
    public void setAccount(Account a) { account = a; }
    public Contact getContact(){
        if(contact== null) contact = new Contact();
        return contact;
    
    }
    public void setContact(Contact c) { contact = c; }
        
       public PageReference step1() {
          return Page.Introduction;
       }
       public PageReference step2() {
                         
          return Page.TripAndContactInformation;
       }
       public PageReference step3() {
       if(trip.Is_Event_and_Organization_address_same__c == true)
       {
       billcity = false ;
       event.Event_City__c = account.billingcity;
       event.Event_State__c = account.billingstate ;
       event.Event_Country__c = account.billingcountry ;
       event.Venue_Name__c = account.name ;
       event.Event_Zip__c = account.BillingPostalCode;
       event.Event_Address__c = account.billingStreet ;
       
       }
       if(trip.Is_Event_and_Organization_address_same__c == false)
       {
       billcity = true ;
       event.Event_City__c = account.billingcity;
       event.Event_State__c = account.billingstate ;
       event.Event_Country__c = account.billingcountry ;
       }
          return Page.EventInformation;
       }
       public PageReference step4() {
       
      event.Trip__c = trip.Id ;
      event.Organization__c = account.Id ;
      event.Contact__c = contact.Id ;
      event.Event_Status__c = 'Incomplete' ;
      
      upsert event ;
      return Page.AddSessions;
       }
   public List<Session__c> getSessionList()
  {
      if(session <> NULL ){
          
     return [select Name, Start_Time__c,Date_of_Session__c,Length_of_session_in_minutes__c,Type_of_Session__c from Session__c where Event_Name__c =: event.id ];
     
     }
     else
     {return NULL ;}
  }
       public PageReference AddSession() {
        
        Session__c se= new Session__c();
        se.Event_Name__c = event.id ;
        se.Name = session.Name;
        se.Date_of_Session__c = session.Date_of_Session__c ;
        se.Type_of_Session__c = session.Type_of_Session__c ;
        se.Start_Time__c = session.Start_Time__c ;
        se.Room_Building__c = session.Room_Building__c ;
        se.Audience_Size__c = session.Audience_Size__c ;
        se.Length_of_session_in_minutes__c = session.Length_of_session_in_minutes__c ;
        se.How_long_do_you_want_Shane_to_talk__c = session.How_long_do_you_want_Shane_to_talk__c ;
        se.What_do_you_want_Shane_to_talk_about__c = session.What_do_you_want_Shane_to_talk_about__c ;
        insert se;
        return NULL;
       
       }     
   public pagereference deleteCon() {
        lstacc1 =[Select Id,Name from Session__c where id=:dcid];
        delete lstacc1;
        return Page.AddSessions; 
    }
          
         
       public PageReference step5() {
          return Page.Confirmation;
       }
       
       public PageReference step6() {
          return Page.ThankYou;
       }
       
       
       public PageReference submit() {
      account.Phone = contact.Phone ;
      insert account;
      contact.AccountId = account.id;
      insert contact;
      trip.Name ='abc' ;
      trip.Stage__c='Requested';
      trip.Main_Event__c = event.id ;
      insert trip;

     
      //Not inserting event here but after adding Event Information field
      event.Trip__c = trip.Id ;
      event.Organization__c = account.Id ;
      event.Contact__c = contact.Id ;
      event.Main_Event__c = true ;
      event.Event_Status__c = 'Request Submitted' ;
      upsert event ; 
      
  upsert trip;
 
       return Page.ThankYou ;      
       
   
    
}

Hello,

 

I am trying to create a custom wizard which has VF pages and contains custom objects

 

One of the custom objects is events.

 

The first VF page header looks like:

 

<apex:page
    showHeader="true" sidebar="false"
    controller="TSWPageController"
    id="Page1"
    standardStylesheets="true"
    cache="false" >
<apex:actionsupport reRender="Page1" />

 

I accpet information as:

 

<apex:pageBlockSection columns="1" >          
                              <apex:inputField value="{!Event__c.Name}" required="True"/>                  
                              <apex:inputField value="{!Event__c.Type_of_Event__c}" required="True"/> 

 

When I click save it asks me if I want to create:

Create Apex method 'TSWPageController.getEvent__c'

 

But I understand that the double underscore is reserved in apex for name and namespaces.

 

When I click on "Create Apex method 'TSWPageController.getEvent__c'" I get the VF error: Invalid identifier: getEvent__c

 

How should I work around this?

 

Any help will be really appreciated.

 

Thanks!

 

Pranav

 

 

 

 

Good morning,

I'm developing a Visualforce page to be part of a managed package using the 'WFM' prefix/namespace. This package includes a custom object called 'Round' that I want to use within a Visualforce page. For this purpose, I included the following code in the Page:

 <apex:inputField id="roundName" value="{!WFM__Round__c.Name}"/>

I also included the following code in the Controller:

   public WFM__Round__c getWFM__Round__c() {
      if(round == null) round = new WFM__Round__c();
      return round;
   }

This generates the following error:

ErrorError: Compile Error: Invalid identifier: getWFM__Round__c at line 11 column 25

Any idea?

Many thanks in advance for your help.

-Ismael
  • September 22, 2008
  • Like
  • 0