• Abhijit
  • NEWBIE
  • 0 Points
  • Member since 2009

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

Hello,

 

I need help.

 

I have custom object called Service Access with 2 Record Type Name 1. LOA  2. Trail . This custom object has lookup to opportunity.

 

I have to create 2 custom buttom on related list of service access (which i already created) one will navigate to LOA record type and another to Trail Record Type.

 

How i can navigate to appropriate Record Type, bcaz for time being i used following hardcoded url while creating Trail Custom buttom in which i have hardcodef id i.e

 

" /a0e/e?retURL=%2Fa0e%2Fo&RecordType=006S0000002b4r0". 

 

Can someone assit me how i can get LOA id or Trail id instead of hardcoding.

 

Thanks,

Abhijit

  • September 30, 2009
  • Like
  • 0

Hi,

 

I am new to apex coding i want to know how i shd write test class for the following code so that it will give max coverage. 

 

 

public class ExtensionOpenActivities{
   
    ApexPages.StandardController stdController;
    public final List<Task> tasks {get; set;}
    public final List<Event> events {get; set;}
    private final Opportunity currentOpportunity;
   
    public String someString {get; set;}       
    public ExtensionOpenActivities(ApexPages.StandardController controller ) {
      
        this.stdController = controller;
        Opportunity currentOpportunity =  (Opportunity)stdController.getRecord();
        this.tasks = new List<Task>();
        this.events = new List<Event>();
                  
             
       
       List<Member_Value_Plan__c> mvpList = [Select id from Member_Value_Plan__c mvp WHERE mvp.Opportunity__r.id = :currentOpportunity.id ];
               
       for(Member_Value_Plan__c mvpObj: mvpList)
        {
           
            List<Task> mvpTasks = [SELECT Id, Subject, ActivityDate, Description, Status, Priority, Type, OwnerId, Owner.Name, CreatedById, CreatedBy.Name FROM Task WHERE WhatID =:mvpObj.id ];
            if(!mvpTasks.isEmpty())
            {
                tasks.addAll(mvpTasks);
            }    
           
            List<Event> mvpEvents = [SELECT Id, EndDateTime, OwnerId, Subject FROM Event WHERE WhatID =:mvpObj.id ];
            if(!mvpEvents.isEmpty())
            {
                events.addAll(mvpEvents);
            }
           
        }
       
       
      }
}

  • September 22, 2009
  • Like
  • 0

Hi,

 

Scenario : I have custom object called SFDC_Project__c which has look up to cases through Case__c field.

When i create case and through same detail page through related list if i click New Project, i want to copy value of Trigger_Value field  from cases to project Cases_Trigger_Value__c after clicking save.

 

I have written trigger on project:

 

trigger SetPrimaryContact on SFDC_Project__c (before insert) 
{

for (SFDC_Project__c o : Trigger.new)
{
List<Case> contactRole = new List<Case>();
contactRole = [select ID, Trigger_Value__c from Case where Id = :o.Case__r.id limit 1];
o.Cases_Trigger_Value__c = contactRole[0].Trigger_Value__c;

insert o;

}
}

  Once i save i get error :

 Error: Invalid Data. Review all error messages below to correct your data.
Apex trigger SetPrimaryContact caused an unexpected exception, contact your administrator: SetPrimaryContact: execution of BeforeInsert caused by: System.ListException: List index out of bounds: 0: Trigger.SetPrimaryContact: line 8, column 47

 

Any help will be appriciated .

 

Thanks & Regards,

Abhijit

Message Edited by Abhijit on 09-21-2009 12:34 PM
  • September 21, 2009
  • Like
  • 0

Hi,

 

Scenario : I have custom object called SFDC_Project__c which has look up to cases through Case__c field.

When i create case and through same detail page through related list if i click New Project, i want to copy value of Trigger_Value field  from cases to project Cases_Trigger_Value__c after clicking save.

 

I have written trigger on project:

 

trigger SetPrimaryContact on SFDC_Project__c (before insert) 
{

for (SFDC_Project__c o : Trigger.new)
{
List<Case> contactRole = new List<Case>();
contactRole = [select ID, Trigger_Value__c from Case where Id = :o.Case__r.id limit 1];
o.Cases_Trigger_Value__c = contactRole[0].Trigger_Value__c;

insert o;

}
}

  Once i save i get error :

 Error: Invalid Data. Review all error messages below to correct your data.
Apex trigger SetPrimaryContact caused an unexpected exception, contact your administrator: SetPrimaryContact: execution of BeforeInsert caused by: System.ListException: List index out of bounds: 0: Trigger.SetPrimaryContact: line 8, column 47

 

Any help will be appriciated .

 

Thanks & Regards,

Abhijit

Message Edited by Abhijit on 09-21-2009 12:34 PM
  • September 21, 2009
  • Like
  • 0