• john2
  • NEWBIE
  • 25 Points
  • Member since 2010

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

Hi Friends, 

i need to display a message "create child record" on top of the detail page after user save the record.

 

please help me out its urgent....

  • April 16, 2012
  • Like
  • 0

Hi everyone,

can anyone helpme how to add custom link to vf page.

 

here is the scenario,

i am ovveriding the "NEW" Button in Acocunts. when we click the new button, vf page has to popup and we enter the fields and we will save that record. when we enter the billing address in the native page in the address information we have a link there saying that "Copy BillingAddress to Shipping Address".

 

i want to add that link to my vf page and and when i click that link shipping address will automatically update with the billing address.

 

can anyone helpme out how to write code for that in VF Page and Controller.

 

thanks in advance, 

  • February 10, 2011
  • Like
  • 0

I am writing a test class for an Update trigger.  I can save with no error messages, but when I run the test I get an error message and its covering 60% only.

 

here is the error: Class.TestupdatePrimaryAddress.testClass: line 11, column 10 External entry point 


Here is the test class.

 

 

@isTest
private class TestupdatePrimaryAddress
{
    static testMethod void testClass()
    {   
        account ac = new account();
        ac.Name = '12534585';
        ac.Is_Primary_Address__c=TRUE;
        ac.Is_Primary_Physical_Address__c=TRUE;
        ac.Is_Primary_Mailing_Address__c=TRUE;
         Insert ac;
        
        Test.startTest();
        
        Contact ct = ContactInsert();
        ct.Primary_Address__c=ac.id;
        ct.Primary_Physical_Address__c=ac.id;
         ct.Primary_Mailing_Address__c=ac.id; 
        update ct;
        
        Test.stopTest();
      }
     public static Contact ContactInsert()
    {
        //create an Contact
        Contact ct = new Contact();
        ct.LastName = 'test';
        ct.Phone = '1234567890';
        ct.MobilePhone = '5105489586';
        ct.Email= 'alpha@chello.be';
        insert ct;
        return ct;
    }
  }
And here is the Trigger i wrote for this test class is
trigger UpdatePrimaryAddress on Account (after insert, after update) {
    List <String> ContactIds= new List<String>();
     For(Account ac : trigger.new)
     {
       ContactIds.add(ac.Contact__c);
     }
     List<Contact>Contacts = [Select Id, Name, Primary_Address__c, Primary_Mailing_Address__c, Primary_Physical_Address__c From Contact Where id IN:ContactIds];
     Map<String,Contact>ContactMap = New Map<String,Contact>(); 
     For(Contact ct : Contacts)
     {
       ContactMap.Put(ct.id, ct);
     }
     List<Contact> ConUpdates = New List<Contact>();
     For(Account ac : Trigger.new)
     {
       system.debug('Entered for loop');
        if(ac.Is_Primary_Address__c==TRUE && ac.Is_Primary_Physical_Address__c==TRUE
                        && ac.Is_Primary_Mailing_address__c==TRUE)
        {
         Contact con = ContactMap.get(ac.Contact__c);
                
                system.debug(con.Id);
                con.Primary_Address__c=ac.id;
                con.Primary_Physical_Address__c=ac.id;
                con.Primary_Mailing_Address__c=ac.id;
                ConUpdates.add(con);
         }
       else if(ac.Is_Primary_Address__c==TRUE && ac.Is_Primary_Physical_Address__c==TRUE)
        {
         Contact con = ContactMap.get(ac.Contact__c);
                
                system.debug(con.Id);
                con.Primary_Address__c=ac.id;
                con.Primary_Physical_Address__c=ac.id;
                ConUpdates.add(con);
         }
       else if(ac.Is_Primary_Physical_Address__c==TRUE && ac.Is_Primary_Mailing_Address__c==TRUE)                        
        {
         Contact con = ContactMap.get(ac.Contact__c);
                
                system.debug(con.Id);
                con.Primary_Physical_Address__c=ac.id;
                con.Primary_Mailing_Address__c=ac.id;
                ConUpdates.add(con);
         }
       else if(ac.Is_Primary_Address__c==TRUE && ac.Is_Primary_Mailing_Address__c==TRUE)
         {
           Contact con = ContactMap.get(ac.Contact__c);
                 
               system.debug(con.Id);
               con.Primary_Address__c=ac.id;
               con.Primary_Mailing_Address__c=ac.id;
               ConUpdates.add(con);
         }
     else if(ac.Is_Primary_Address__c==TRUE)
        {
         Contact con = ContactMap.get(ac.Contact__c);
                
                system.debug(con.Id);
                con.Primary_Address__c=ac.id;
                ConUpdates.add(con);
         }
     else if(ac.Is_Primary_Physical_Address__c==TRUE)
        {
         Contact con = ContactMap.get(ac.Contact__c);
                
                system.debug(con.Id);
                con.Primary_Physical_Address__c=ac.id;
                ConUpdates.add(con);
         }
        else if(ac.Is_Primary_Mailing_Address__c==TRUE)
        {
         Contact con = ContactMap.get(ac.Contact__c);
                
                system.debug(con.Id);
                con.Primary_Mailing_Address__c=ac.id;
                ConUpdates.add(con);
         }
      }
     
   update ConUpdates; 
   }
Thanks in Advance.

 

  • February 02, 2011
  • Like
  • 0

 

Hi,

i am a beginner i managed to create the below trigger to update the primary address after address update. .  

 

can any one help me writing a test class for it.

 

thanks in advance for your help.


trigger updatePrimaryAddress on Address__c (after insert, after update) {
    List <String> ContactIds= new List<String>();
     For(Address__c ad : trigger.new)
     {
       ContactIds.add(ad.Contact__c);
     }
     List<contact>contacts = [Select Id, Name, Primary_address__c From contact Where id IN:contactIds];
     Map<String,contact>contactMap = New Map<String,contact>(); 
     For(contact c : contacts)
     {
       contactMap.Put(c.id, c);
     }
     List<contact> ctUpdates = New List<contact>();
     For(address__c ad : Trigger.new)
     {
       system.debug('Entered for loop');
        if(ad.Is_Primary_address__c==TRUE)
        {
         contact ct = contactMap.get(ad.contact__c);
                
                system.debug(ct.Id);
                ct.Primary_address__c=ct.id;
                ctUpdates.add(ct);
        }else
        {
        contact ct = contactMap.get(ad.contact__c);
                
                system.debug(ct.Id);
                ct.Primary_address__c=null;
                ctUpdates.add(ct);
         }
     }
   update ctUpdates;    
}

 

  • January 28, 2011
  • Like
  • 0

 

Hi ,

   Iam getting this error, iam not sure how to avoid this...Any Help plz.....

 

System.LimitException: Too many SOQL queries: 21".

 

here is the thing i need to do is update primary unit field in account when  is primary unit=true from units object.

trigger UpdatePrimaryUnit on Unit__c (after insert, after update) {
    List <Account> acct= new List<Account>();
     for(Unit__c ut : trigger.new){
        system.debug('Entered for loop');
        if(ut.Is_Primary_Unit__c==TRUE)
        {
            Account acc = [Select Name, Primary_Unit__c From Account Where Id=:ut.Account__c];
    
                system.debug(acc.Id);
                acc.Primary_Unit__c=ut.id;
                acct.add(acc);
           
        }
    }
    update acct;    
}

 

  • January 11, 2011
  • Like
  • 0

while i am getting the response from web serivces

 

IO Exception: Read timed out
 

An unexpected error has occurred. Your development organization has been notified.

 

can somebody help me in this??

 

thank you

  • August 18, 2010
  • Like
  • 0

I am writing a test class for an Update trigger.  I can save with no error messages, but when I run the test I get an error message and its covering 60% only.

 

here is the error: Class.TestupdatePrimaryAddress.testClass: line 11, column 10 External entry point 


Here is the test class.

 

 

@isTest
private class TestupdatePrimaryAddress
{
    static testMethod void testClass()
    {   
        account ac = new account();
        ac.Name = '12534585';
        ac.Is_Primary_Address__c=TRUE;
        ac.Is_Primary_Physical_Address__c=TRUE;
        ac.Is_Primary_Mailing_Address__c=TRUE;
         Insert ac;
        
        Test.startTest();
        
        Contact ct = ContactInsert();
        ct.Primary_Address__c=ac.id;
        ct.Primary_Physical_Address__c=ac.id;
         ct.Primary_Mailing_Address__c=ac.id; 
        update ct;
        
        Test.stopTest();
      }
     public static Contact ContactInsert()
    {
        //create an Contact
        Contact ct = new Contact();
        ct.LastName = 'test';
        ct.Phone = '1234567890';
        ct.MobilePhone = '5105489586';
        ct.Email= 'alpha@chello.be';
        insert ct;
        return ct;
    }
  }
And here is the Trigger i wrote for this test class is
trigger UpdatePrimaryAddress on Account (after insert, after update) {
    List <String> ContactIds= new List<String>();
     For(Account ac : trigger.new)
     {
       ContactIds.add(ac.Contact__c);
     }
     List<Contact>Contacts = [Select Id, Name, Primary_Address__c, Primary_Mailing_Address__c, Primary_Physical_Address__c From Contact Where id IN:ContactIds];
     Map<String,Contact>ContactMap = New Map<String,Contact>(); 
     For(Contact ct : Contacts)
     {
       ContactMap.Put(ct.id, ct);
     }
     List<Contact> ConUpdates = New List<Contact>();
     For(Account ac : Trigger.new)
     {
       system.debug('Entered for loop');
        if(ac.Is_Primary_Address__c==TRUE && ac.Is_Primary_Physical_Address__c==TRUE
                        && ac.Is_Primary_Mailing_address__c==TRUE)
        {
         Contact con = ContactMap.get(ac.Contact__c);
                
                system.debug(con.Id);
                con.Primary_Address__c=ac.id;
                con.Primary_Physical_Address__c=ac.id;
                con.Primary_Mailing_Address__c=ac.id;
                ConUpdates.add(con);
         }
       else if(ac.Is_Primary_Address__c==TRUE && ac.Is_Primary_Physical_Address__c==TRUE)
        {
         Contact con = ContactMap.get(ac.Contact__c);
                
                system.debug(con.Id);
                con.Primary_Address__c=ac.id;
                con.Primary_Physical_Address__c=ac.id;
                ConUpdates.add(con);
         }
       else if(ac.Is_Primary_Physical_Address__c==TRUE && ac.Is_Primary_Mailing_Address__c==TRUE)                        
        {
         Contact con = ContactMap.get(ac.Contact__c);
                
                system.debug(con.Id);
                con.Primary_Physical_Address__c=ac.id;
                con.Primary_Mailing_Address__c=ac.id;
                ConUpdates.add(con);
         }
       else if(ac.Is_Primary_Address__c==TRUE && ac.Is_Primary_Mailing_Address__c==TRUE)
         {
           Contact con = ContactMap.get(ac.Contact__c);
                 
               system.debug(con.Id);
               con.Primary_Address__c=ac.id;
               con.Primary_Mailing_Address__c=ac.id;
               ConUpdates.add(con);
         }
     else if(ac.Is_Primary_Address__c==TRUE)
        {
         Contact con = ContactMap.get(ac.Contact__c);
                
                system.debug(con.Id);
                con.Primary_Address__c=ac.id;
                ConUpdates.add(con);
         }
     else if(ac.Is_Primary_Physical_Address__c==TRUE)
        {
         Contact con = ContactMap.get(ac.Contact__c);
                
                system.debug(con.Id);
                con.Primary_Physical_Address__c=ac.id;
                ConUpdates.add(con);
         }
        else if(ac.Is_Primary_Mailing_Address__c==TRUE)
        {
         Contact con = ContactMap.get(ac.Contact__c);
                
                system.debug(con.Id);
                con.Primary_Mailing_Address__c=ac.id;
                ConUpdates.add(con);
         }
      }
     
   update ConUpdates; 
   }
Thanks in Advance.

 

  • February 02, 2011
  • Like
  • 0

 

Hi,

i am a beginner i managed to create the below trigger to update the primary address after address update. .  

 

can any one help me writing a test class for it.

 

thanks in advance for your help.


trigger updatePrimaryAddress on Address__c (after insert, after update) {
    List <String> ContactIds= new List<String>();
     For(Address__c ad : trigger.new)
     {
       ContactIds.add(ad.Contact__c);
     }
     List<contact>contacts = [Select Id, Name, Primary_address__c From contact Where id IN:contactIds];
     Map<String,contact>contactMap = New Map<String,contact>(); 
     For(contact c : contacts)
     {
       contactMap.Put(c.id, c);
     }
     List<contact> ctUpdates = New List<contact>();
     For(address__c ad : Trigger.new)
     {
       system.debug('Entered for loop');
        if(ad.Is_Primary_address__c==TRUE)
        {
         contact ct = contactMap.get(ad.contact__c);
                
                system.debug(ct.Id);
                ct.Primary_address__c=ct.id;
                ctUpdates.add(ct);
        }else
        {
        contact ct = contactMap.get(ad.contact__c);
                
                system.debug(ct.Id);
                ct.Primary_address__c=null;
                ctUpdates.add(ct);
         }
     }
   update ctUpdates;    
}

 

  • January 28, 2011
  • Like
  • 0

 

Hi ,

   Iam getting this error, iam not sure how to avoid this...Any Help plz.....

 

System.LimitException: Too many SOQL queries: 21".

 

here is the thing i need to do is update primary unit field in account when  is primary unit=true from units object.

trigger UpdatePrimaryUnit on Unit__c (after insert, after update) {
    List <Account> acct= new List<Account>();
     for(Unit__c ut : trigger.new){
        system.debug('Entered for loop');
        if(ut.Is_Primary_Unit__c==TRUE)
        {
            Account acc = [Select Name, Primary_Unit__c From Account Where Id=:ut.Account__c];
    
                system.debug(acc.Id);
                acc.Primary_Unit__c=ut.id;
                acct.add(acc);
           
        }
    }
    update acct;    
}

 

  • January 11, 2011
  • Like
  • 0

Hi,

 

currently i am working on web serivces.

i inserted the generated wsdl into class. it is saved successfully. this is soap file that i have in the web serivces..

 

public class TaxwareServiceSoap {
        public String endpoint_x = 'http://www.webservicex.net:9400/webservices/TaxwareService/TaxwareService.asmx';
        public Map<String,String> inputHttpHeaders_x;
        public Map<String,String> outputHttpHeaders_x;
        public String clientCertName_x;
        public String clientCert_x;
        public String clientCertPasswd_x;
        public Integer timeout_x;
        private String[] ns_map_type_info = new String[]{'http://tempuri.org/TaxwareService/TaxwareService', 'tempuriOrgTaxwareserviceTaxwareservic'};
        public String OpenFiles() {
            tempuriOrgTaxwareserviceTaxwareservic.OpenFiles_element request_x = new tempuriOrgTaxwareserviceTaxwareservic.OpenFiles_element();
            tempuriOrgTaxwareserviceTaxwareservic.OpenFilesResponse_element response_x;
            Map<String, tempuriOrgTaxwareserviceTaxwareservic.OpenFilesResponse_element> response_map_x = new Map<String, tempuriOrgTaxwareserviceTaxwareservic.OpenFilesResponse_element>();
            response_map_x.put('response_x', response_x);
            WebServiceCallout.invoke(
              this,
              request_x,
              response_map_x,
              new String[]{endpoint_x,
              'http://tempuri.org/TaxwareService/TaxwareService/OpenFiles',
              'http://tempuri.org/TaxwareService/TaxwareService',
              'OpenFiles',
              'http://tempuri.org/TaxwareService/TaxwareService',
              'OpenFilesResponse',
              'tempuriOrgTaxwareserviceTaxwareservic.OpenFilesResponse_element'}
            );
            response_x = response_map_x.get('response_x');
            return response_x.OpenFilesResult;

        }
        public String CloseFiles() {
            tempuriOrgTaxwareserviceTaxwareservic.CloseFiles_element request_x = new tempuriOrgTaxwareserviceTaxwareservic.CloseFiles_element();
            tempuriOrgTaxwareserviceTaxwareservic.CloseFilesResponse_element response_x;
            Map<String, tempuriOrgTaxwareserviceTaxwareservic.CloseFilesResponse_element> response_map_x = new Map<String, tempuriOrgTaxwareserviceTaxwareservic.CloseFilesResponse_element>();
            response_map_x.put('response_x', response_x);
            WebServiceCallout.invoke(
              this,
              request_x,
              response_map_x,
              new String[]{endpoint_x,
              'http://tempuri.org/TaxwareService/TaxwareService/CloseFiles',
              'http://tempuri.org/TaxwareService/TaxwareService',
              'CloseFiles',
              'http://tempuri.org/TaxwareService/TaxwareService',
              'CloseFilesResponse',
              'tempuriOrgTaxwareserviceTaxwareservic.CloseFilesResponse_element'}
            );
            response_x = response_map_x.get('response_x');
            return response_x.CloseFilesResult;
        }

this is soap file i have.

i wrote a class and visualforce page to get response for openfile and closefile 

 

the class is like this...

 

public class openfiledemo{

Account acc;
tempuriOrgTaxwareserviceTaxwareservic.TaxwareServiceSoap stub = 
        new tempuriOrgTaxwareserviceTaxwareservic.TaxwareServiceSoap();

String response;

public openfiledemo(ApexPages.StandardController stdController){
    this.acc = (Account)stdController.getRecord();
}    



public String getresponse(){
system.debug('output>>>>>>>>>>>>>>>>'+stub.OpenFiles());
return stub.OpenFiles();                                                            
}
    
/*
tempuriOrgTaxwareserviceTaxwareservic.OpenFilesResponse_element response= 
        new tempuriOrgTaxwareserviceTaxwareservic.OpenFilesResponse_element();
            
public tempuriOrgTaxwareserviceTaxwareservic.OpenFilesResponse_element 
                                                            getresponse(){
response = stub.OpenFiles();
return response;                                                            
}

*/   
    
}

and i created a custom button in the visualforce page to call the response,

and the visualforce page is 

 

<apex:page standardController="Account" extensions="openfiledemo">
<apex:form >
    <apex:commandButton action="getresponse" value="Openfile"/>
</apex:form>
</apex:page>

and i check the apex debug log details, it says successful.

debug details are
StatusSuccessApplicationBrowser
Request TypeApplicationOperation/apex/smk__openfile
Duration (ms)77Log Size (bytes)1,774
Log
19.0 APEX_CODE,DEBUG;APEX_PROFILING,INFO;CALLOUT,INFO;DB,INFO;VALIDATION,INFO;WORKFLOW,INFO
22:28:41.488|EXECUTION_STARTED
22:28:41.488|CODE_UNIT_STARTED|[EXTERNAL]|066A0000000NWYU|VF: /apex/smk__openfile
22:28:41.488|CODE_UNIT_STARTED|[EXTERNAL]|01pA0000000TIG8|openfiledemo <init>
22:28:41.488|METHOD_ENTRY|[3,8]|01pA0000000THZH|tempuriOrgTaxwareserviceTaxwareservic.tempuriOrgTaxwareserviceTaxwareservic()
22:28:41.489|METHOD_EXIT|[3,8]|tempuriOrgTaxwareserviceTaxwareservic
22:28:41.489|CONSTRUCTOR_ENTRY|[5,9]|01pA0000000THZH|new: tempuriOrgTaxwareserviceTaxwareservic.TaxwareServiceSoap
22:28:41.489|CONSTRUCTOR_EXIT|[5,9]|new: tempuriOrgTaxwareserviceTaxwareservic.TaxwareServiceSoap
22:28:41.489|METHOD_ENTRY|[10,25]|ApexPages.StandardController.getRecord()
22:28:41.505|METHOD_EXIT|[10,25]|ApexPages.StandardController.getRecord()
22:28:41.505|CODE_UNIT_FINISHED|openfiledemo <init>
22:28:41.560|CUMULATIVE_LIMIT_USAGE
22:28:41.560|LIMIT_USAGE_FOR_NS|smk|
  Number of SOQL queries: 0 out of 100
  Number of query rows: 0 out of 10000
  Number of SOSL queries: 0 out of 20
  Number of DML statements: 0 out of 100
  Number of DML rows: 0 out of 10000
  Number of script statements: 12 out of 200000
  Maximum heap size: 0 out of 3000000
  Number of callouts: 0 out of 10
  Number of Email Invocations: 0 out of 10
  Number of fields describes: 0 out of 10
  Number of record type describes: 0 out of 10
  Number of child relationships describes: 0 out of 10
  Number of picklist describes: 0 out of 10
  Number of future calls: 0 out of 10
  Number of find similar calls: 0 out of 10
  Number of System.runAs() invocations: 0 out of 20

22:28:41.560|CUMULATIVE_LIMIT_USAGE_END

22:28:41.560|CODE_UNIT_FINISHED|VF: /apex/smk__openfile
22:28:41.560|EXECUTION_FINISHED

i tried all these things but i am not getting the openfile getresponse from the webservices.

the error will be like this.... Illegal view ID getresponse. The ID must begin with /
can anybody help me out with the solutions.its urgent
thank you
  • August 18, 2010
  • Like
  • 0

Does anyone know if a large bold red text can display at the top of an Account record based on critieria like "Overdue Account" or "Past Due" or "Need to buy Contract"?

 

Desn't have to be fancy coding, could be simple field checkbox so that if checked, large bold red text will display for any user that deals with that account?

 

Would be very useful for us!

Thanks!

  • June 02, 2010
  • Like
  • 0