• Nong
  • NEWBIE
  • 5 Points
  • Member since 2010

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

Dear All,

 

I have 2 record types of Account object  Record Type A and B.

 

I just create one visualforce page and would like to override it for Account detail page for record type 'A'.

 

I found  if we change setting by follow the steps below.

This setting is to override on every record types.

 

Setup>Customize>Accounts>Button and Links> Select  'View' > Select my VF page.

 

 

Could you please advise how we can we set to override only Account record type 'A'

 

 

Thank you very much in advance for your advise.

 

Regards

Anong

  • April 04, 2011
  • Like
  • 0

Dear All,

Could you please advise me for the solution as i have field product picklist in Opportunity object and Contract object.
User can create Contract under the Opportunity.

Once user create new Contract. On New Contract page,  i would like to preselect  Contract 's product with the same value of  Opportunity 's selected product .

How can i do this by customizing? or do i need to work on the Apex code?

Thank you very much in advance for your advise.

Best Regards
Anong

  • February 09, 2011
  • Like
  • 0

Dear All,

 

Could you please advise as i created one trigger under event and build testing class in below coding.
I got successful result on Sandbox run testing but i got the error below on production deployment when i clicked

Validate button .

 

Could you please advise what's the problem of my coding.

 

Failure Message: "System.AssertException: Assertion Failed: Expected: null, Actual: 2011-02-15 00:00:00", Failure Stack Trace: "Class.testAccountTravelManagementEvent_Trigger.AccountEventTest: line 31, column 16 External entry point"

 

 

My trigger coding is :

 

trigger AccountTravel_Management_Event on Event(before insert, before update,after insert,after update,after delete) {                
Event evt;  
String evtId='';  
   
    if(Trigger.isInsert || Trigger.isUpdate )  
    {
    evt= Trigger.New[0];
    evtId= evt.whatid;
    }
    else
    evtId=Trigger.old[0].whatid;
      
     
    Integer ivisit=0;
    DateTime dtVisit;
    
    if(evtId != null && evtId.substring(0,3)== '001')
    {       
       //get Account object that link to this Task
       Account acc = [select Rating,Next_Visit_Date__c,Owner_Country__c From Account where id=:evtId]; 
       if(acc.Owner_Country__c<> null)
       {
       if(acc.Owner_Country__c.toLowerCase()=='thailand')
       {
         //==================== set Task Budget ======================  
         String strRating  = acc.Rating.toUpperCase();
            //set Task default Budget via Account Rating
            if (strRating == 'PLATINUM' || strRating == 'GOLD') {
                ivisit=1;
            } else  if (strRating == 'SILVER') {
                ivisit=15;   
            } else  if (strRating == 'BRONZE') {
                ivisit=1;                          
            } else  if (strRating == 'INACTIVE') {
                ivisit=1;
            }
           
//==================== set Next Visti Date ======================
            Event[] evtVisitmax;
            Try{
//===================get latest 'xxxxxxxxx Face to Face' task==========
evtVisitmax= [Select ActivityDateTime  From Event where 
whatid=:evtId and  what.type = 'Account' and ActivityDateTime <> null and subject  like '%Face to Face'  and isDeleted = false  order By ActivityDateTime DESC limit 1];    
                
if(evtVisitmax.size()>0 && ivisit>0)
{
if(ivisit==1)//number of month                
                    dtVisit=evtVisitmax[0].ActivityDateTime.addMonths(ivisit);                
else//number of days           
                    dtVisit=evtVisitmax[0].ActivityDateTime.addDays(ivisit);
                    
System.debug('dtVisit='+dtVisit);
//convert datetime to date 
acc.Next_Visit_Date__c  = date.newinstance(dtVisit.year(), dtVisit.month(), dtVisit.day());                
} 
else{
acc.Next_Visit_Date__c=null ;                
    } 
update acc;                 
            }
            catch(System.QueryException e){
            trigger.new[0].addError(' Can not select latest Start Date of all Tasks'); 
            Return;
            }
        }}//if Thailand                        
    }//if not null and 001   
        
}

 

 

My test class is

 

 

@isTest
private class testAccountTravelManagementEvent_Trigger{
static testMethod void AccountEventTest() 
{     
test.startTest();  
// =========add Account=======================================           
                               
DateTime dtn_before4=system.now().addDays(-4);
DateTime dtn=system.now();
DateTime dtn_after1=system.now().addDays(1);   
DateTime dtn_after2=system.now().addDays(2);
Date dn_after1= date.newinstance(dtn_after1.year(), dtn_after1.month(),dtn_after1.day());
                  
                
Account a1 = new Account(Name = 'Test Account ' + 'Platinum',Rating='Platinum',Owner_Country__c='Thailand');
                 insert a1;
                    
Event e1 = new Event (Subject= 'Account Management Appointment - Face to Face' ,whatid=a1.Id,ActivityDateTime =dtn_after1,EndDateTime=dtn_after2);
                 insert e1; 
                    
Event e2 = new Event (Subject= 'Account Management Appointment - Face to Face' ,whatid=a1.Id,ActivityDateTime =dtn_before4,EndDateTime=dtn);
                 insert e2;
                
               
List<Account> insertedAccounts = [SELECT Id,Rating,Next_Visit_Date__c,Owner_Country__c FROM Account  WHERE Id=:a1.Id ];                       

System.debug('1test added record account='+insertedAccounts.size()); 
               System.debug('date1='+insertedAccounts[0].Next_Visit_Date__c); 
               System.debug('date2='+dn_after1.addMonths(1)); 
               
               System.debug(insertedAccounts[0].Next_Visit_Date__c==dn_after1.addMonths(1));
               System.assertEquals(insertedAccounts[0].Next_Visit_Date__c,dn_after1.addMonths(1));
               
              test.stopTest();
      }
}

 

Could you please advise how can i solve the problem , thank you very much in advance for your help.

 

Best Regards

Anong

 

  • January 14, 2011
  • Like
  • 0

Dear All,

 

I have the problem on SOQL to select past Event from below command but it does not compare the time , i tried system.now() but it did not work.

 

Could you please advise .

 

Select ActivityDateTime  From Event where whatid=:tsk.whatid and  
            what.type = 'Account' and ActivityDateTime <> null and    ActivityDateTime >=LAST_N_DAYS:0  

 

Thank you very much in advance for your help.

 

Best Regards

Anong         

  • January 04, 2011
  • Like
  • 1

Dear All,

 

Could you please help me to give example Apex source code to get latest Due Date from all Tasks under each Account that will be implemented on Account Trigger.

 

Thank you very much in advance.

 

Best Regards

Anong

 

  • December 29, 2011
  • Like
  • 0

Dear All,

 

Could you please help me to give some example APEX code to get value of Account custom field from Task trigger.

 

As i would like to set default value on Task custom field depending on selected Rating of Account object that this task is under.

 

Thank you very much in advance for your help.

 

Best Regards

Anong

  • December 29, 2011
  • Like
  • 0

Dear All,

 

The requirement i got is to alert message if user change status of Opportunity to 'Operational' and  no contract created under that Opportunit.

 

As user need to create at least one Contract before changing status Opportunity to 'Operational'

 

Could you please help me to provide some example source code to count total of created Contracts under Opportunity and how i can show validation message on the screen from APEX code.

 

Looking forward to your response and thank you very much in advance for you help.

 

Best Regards

Anong

  • December 29, 2011
  • Like
  • 0

Dear All,

 

I am just the beginner on the APEX and I have the problem as I don't know the APEX code in Trigger to capture if user has changed field Stage in Opportunities or not .

 

Could you please advise  and thank you very much in advance for you help.

 

Regards

Anong

 

 

  • December 08, 2010
  • Like
  • 0

Dear All,

 

I have the problem on SOQL to select past Event from below command but it does not compare the time , i tried system.now() but it did not work.

 

Could you please advise .

 

Select ActivityDateTime  From Event where whatid=:tsk.whatid and  
            what.type = 'Account' and ActivityDateTime <> null and    ActivityDateTime >=LAST_N_DAYS:0  

 

Thank you very much in advance for your help.

 

Best Regards

Anong         

  • January 04, 2011
  • Like
  • 1

Dear All,

 

I have 2 record types of Account object  Record Type A and B.

 

I just create one visualforce page and would like to override it for Account detail page for record type 'A'.

 

I found  if we change setting by follow the steps below.

This setting is to override on every record types.

 

Setup>Customize>Accounts>Button and Links> Select  'View' > Select my VF page.

 

 

Could you please advise how we can we set to override only Account record type 'A'

 

 

Thank you very much in advance for your advise.

 

Regards

Anong

  • April 04, 2011
  • Like
  • 0

Dear All,

Could you please advise me for the solution as i have field product picklist in Opportunity object and Contract object.
User can create Contract under the Opportunity.

Once user create new Contract. On New Contract page,  i would like to preselect  Contract 's product with the same value of  Opportunity 's selected product .

How can i do this by customizing? or do i need to work on the Apex code?

Thank you very much in advance for your advise.

Best Regards
Anong

  • February 09, 2011
  • Like
  • 0

Dear All,

 

Could you please advise as i created one trigger under event and build testing class in below coding.
I got successful result on Sandbox run testing but i got the error below on production deployment when i clicked

Validate button .

 

Could you please advise what's the problem of my coding.

 

Failure Message: "System.AssertException: Assertion Failed: Expected: null, Actual: 2011-02-15 00:00:00", Failure Stack Trace: "Class.testAccountTravelManagementEvent_Trigger.AccountEventTest: line 31, column 16 External entry point"

 

 

My trigger coding is :

 

trigger AccountTravel_Management_Event on Event(before insert, before update,after insert,after update,after delete) {                
Event evt;  
String evtId='';  
   
    if(Trigger.isInsert || Trigger.isUpdate )  
    {
    evt= Trigger.New[0];
    evtId= evt.whatid;
    }
    else
    evtId=Trigger.old[0].whatid;
      
     
    Integer ivisit=0;
    DateTime dtVisit;
    
    if(evtId != null && evtId.substring(0,3)== '001')
    {       
       //get Account object that link to this Task
       Account acc = [select Rating,Next_Visit_Date__c,Owner_Country__c From Account where id=:evtId]; 
       if(acc.Owner_Country__c<> null)
       {
       if(acc.Owner_Country__c.toLowerCase()=='thailand')
       {
         //==================== set Task Budget ======================  
         String strRating  = acc.Rating.toUpperCase();
            //set Task default Budget via Account Rating
            if (strRating == 'PLATINUM' || strRating == 'GOLD') {
                ivisit=1;
            } else  if (strRating == 'SILVER') {
                ivisit=15;   
            } else  if (strRating == 'BRONZE') {
                ivisit=1;                          
            } else  if (strRating == 'INACTIVE') {
                ivisit=1;
            }
           
//==================== set Next Visti Date ======================
            Event[] evtVisitmax;
            Try{
//===================get latest 'xxxxxxxxx Face to Face' task==========
evtVisitmax= [Select ActivityDateTime  From Event where 
whatid=:evtId and  what.type = 'Account' and ActivityDateTime <> null and subject  like '%Face to Face'  and isDeleted = false  order By ActivityDateTime DESC limit 1];    
                
if(evtVisitmax.size()>0 && ivisit>0)
{
if(ivisit==1)//number of month                
                    dtVisit=evtVisitmax[0].ActivityDateTime.addMonths(ivisit);                
else//number of days           
                    dtVisit=evtVisitmax[0].ActivityDateTime.addDays(ivisit);
                    
System.debug('dtVisit='+dtVisit);
//convert datetime to date 
acc.Next_Visit_Date__c  = date.newinstance(dtVisit.year(), dtVisit.month(), dtVisit.day());                
} 
else{
acc.Next_Visit_Date__c=null ;                
    } 
update acc;                 
            }
            catch(System.QueryException e){
            trigger.new[0].addError(' Can not select latest Start Date of all Tasks'); 
            Return;
            }
        }}//if Thailand                        
    }//if not null and 001   
        
}

 

 

My test class is

 

 

@isTest
private class testAccountTravelManagementEvent_Trigger{
static testMethod void AccountEventTest() 
{     
test.startTest();  
// =========add Account=======================================           
                               
DateTime dtn_before4=system.now().addDays(-4);
DateTime dtn=system.now();
DateTime dtn_after1=system.now().addDays(1);   
DateTime dtn_after2=system.now().addDays(2);
Date dn_after1= date.newinstance(dtn_after1.year(), dtn_after1.month(),dtn_after1.day());
                  
                
Account a1 = new Account(Name = 'Test Account ' + 'Platinum',Rating='Platinum',Owner_Country__c='Thailand');
                 insert a1;
                    
Event e1 = new Event (Subject= 'Account Management Appointment - Face to Face' ,whatid=a1.Id,ActivityDateTime =dtn_after1,EndDateTime=dtn_after2);
                 insert e1; 
                    
Event e2 = new Event (Subject= 'Account Management Appointment - Face to Face' ,whatid=a1.Id,ActivityDateTime =dtn_before4,EndDateTime=dtn);
                 insert e2;
                
               
List<Account> insertedAccounts = [SELECT Id,Rating,Next_Visit_Date__c,Owner_Country__c FROM Account  WHERE Id=:a1.Id ];                       

System.debug('1test added record account='+insertedAccounts.size()); 
               System.debug('date1='+insertedAccounts[0].Next_Visit_Date__c); 
               System.debug('date2='+dn_after1.addMonths(1)); 
               
               System.debug(insertedAccounts[0].Next_Visit_Date__c==dn_after1.addMonths(1));
               System.assertEquals(insertedAccounts[0].Next_Visit_Date__c,dn_after1.addMonths(1));
               
              test.stopTest();
      }
}

 

Could you please advise how can i solve the problem , thank you very much in advance for your help.

 

Best Regards

Anong

 

  • January 14, 2011
  • Like
  • 0

Dear All,

 

I have the problem on SOQL to select past Event from below command but it does not compare the time , i tried system.now() but it did not work.

 

Could you please advise .

 

Select ActivityDateTime  From Event where whatid=:tsk.whatid and  
            what.type = 'Account' and ActivityDateTime <> null and    ActivityDateTime >=LAST_N_DAYS:0  

 

Thank you very much in advance for your help.

 

Best Regards

Anong         

  • January 04, 2011
  • Like
  • 1

Dear All,

 

Could you please help me to give example Apex source code to get latest Due Date from all Tasks under each Account that will be implemented on Account Trigger.

 

Thank you very much in advance.

 

Best Regards

Anong

 

  • December 29, 2011
  • Like
  • 0

Dear All,

 

Could you please help me to give some example APEX code to get value of Account custom field from Task trigger.

 

As i would like to set default value on Task custom field depending on selected Rating of Account object that this task is under.

 

Thank you very much in advance for your help.

 

Best Regards

Anong

  • December 29, 2011
  • Like
  • 0

Dear All,

 

The requirement i got is to alert message if user change status of Opportunity to 'Operational' and  no contract created under that Opportunit.

 

As user need to create at least one Contract before changing status Opportunity to 'Operational'

 

Could you please help me to provide some example source code to count total of created Contracts under Opportunity and how i can show validation message on the screen from APEX code.

 

Looking forward to your response and thank you very much in advance for you help.

 

Best Regards

Anong

  • December 29, 2011
  • Like
  • 0

Dear All,

 

I am just the beginner on the APEX and I have the problem as I don't know the APEX code in Trigger to capture if user has changed field Stage in Opportunities or not .

 

Could you please advise  and thank you very much in advance for you help.

 

Regards

Anong

 

 

  • December 08, 2010
  • Like
  • 0