• Suresh(Suri)
  • NEWBIE
  • 40 Points
  • Member since 2011

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 13
    Questions
  • 22
    Replies
Hi Experts,
I need test class for the trigger given below:

trigger Casetrigger on Case (after insert) {

 list<Account> accList = new list<Account>();

 for(case c: Trigger.new){
      if(c.account!= null)
       accList.add(c.account);
     }
     
    //query email address from account object.
     
   Map<id,String> insideSalesEmailMap = new Map<Id, String>();
     for(Account acc: [select id,thermage_tlr__Rep_2__r.email from Account where id IN :accList]){
            insideSalesEmailMap.put(acc.id, acc.thermage_tlr__Rep_2__r.email);
        }  
        
        // preparing for Email send out. 
        
         List<Messaging.SingleEmailMessage> sme = new List<Messaging.SingleEmailMessage>();
     for(case c: Trigger.new){
      Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
      //email.setTemplateId('00X500000013avG');
      email.setToAddresses(new List<String>{insideSalesEmailMap.get(c.accountId)});
      email.setPlaintextbody('Test');
      email.setSaveAsActivity(false);
      sme.add(email);
     }
     
      //send Email
      
     if(sme != null && sme.size() > 0){
      Messaging.sendEmail(sme);
  }
     
}

Please help.
Hi All,

As per my requirement i want to display accounts with dublicate records.
for ex: am displaying 2 account records in vf page need to display 3 dublicate records for every record with expandable/collapsable like excel rows.

Account1strec              email   phone
Account1strecdub1   email   phone
Account1strecdub2   email   phone
Account1strecdub3   email   phone

Account2ndrec             email   phone
Account2ndrecdub1   email   phone
Account2
ndrecdub2   email   phone
Account2
ndrecdub3   email   phone

Dublicare records need to Expandable/collapsable like excel sheet

Is there any way to achive this can you plz help...Thanks in advance
Hi All,

Is there any other way to retrieve grandparent id using grand child object in apex. Here am using sObject in this 3 different objects will recive based on object i want to identify like(sObjectType == Obj1__c.sObjectType)  and pass the grand parent id into map like(GP GPid = GPMap.get((Id)sObj.get('GPids'));)

Thanks & Regards,
Suresh

Hi Team,
 
Does anyone have any knowledge or experience working on Salesforce Agile Accelerator?

If knows can you please suggest below questions

-Integration with cases. When a user submits a case, how we can we get this data into SAA?
-Best practices to use SAA -
-Can it reference Change Sets?
-How can it hold a list of changes to implement for ex one requirement done many changes in sandbox how to list out/check any process to hold all changes like excel sheet?

Thanks in Advance

Hi All,

Am getting an error while retrieving components from sandbox/production like this

User-added image
Can you lease any one help?

Thanks in advance
Need help for Code coverage to json parser in locationcallouts apex class
Hi,

Need to help for code coverage i got 66% but json part not coveing in my controller please look into my code
================Apex Class====================
public class LocationCallouts {

     @future (callout=true)  // future method needed to run callouts from Triggers
      static public void getLocation(id accountId){
        // gather account info
        Account a = [SELECT BillingCity,BillingCountry,BillingPostalCode,BillingState,BillingStreet FROM Account WHERE id =: accountId];
 
        // create an address string
        String address = '';
        if (a.BillingStreet != null)
            address += a.BillingStreet +', ';
        if (a.BillingCity != null)
            address += a.BillingCity +', ';
        if (a.BillingState != null)
            address += a.BillingState +' ';
        if (a.BillingPostalCode != null)
            address += a.BillingPostalCode +', ';
        if (a.BillingCountry != null)
            address += a.BillingCountry;
 
        address = EncodingUtil.urlEncode(address, 'UTF-8');
        
        General_Settings__c ge= General_Settings__c.getValues('API Key');
        General_Settings__c eurl= General_Settings__c.getValues('Geocoding URL');        
        System.debug('##########'+eurl);
        System.debug('@@@@@@@@@@'+ge);
        String geocodingKey = ge.Value__c;
        String endpointurl= eurl.Value__c;
 
        // build callout
        Http h = new Http();
        HttpRequest req = new HttpRequest();
      //req.setEndpoint('http://maps.googleapis.com/maps/api/geocode/json?address='+address+'&sensor=false');
        req.setEndpoint(endpointurl+'?address='+ address + '&key=' + geocodingKey + '&sensor=false');
        req.setMethod('GET');
        req.setTimeout(60000);
 
        try{
            // callout
            HttpResponse res = h.send(req);
             System.debug('&&&&&'+res.getBody());
             System.debug('#####');
            // parse coordinates from response
            JSONParser parser = JSON.createParser(res.getBody());
            double lat = null;
            double lon = null;
            while (parser.nextToken() != null) {
                if ((parser.getCurrentToken() == JSONToken.FIELD_NAME) &&
                    (parser.getText() == 'location')){
                       parser.nextToken(); // object start
                       while (parser.nextToken() != JSONToken.END_OBJECT){
                           String txt = parser.getText();
                           parser.nextToken();
                           if (txt == 'lat')
                               lat = parser.getDoubleValue();
                           else if (txt == 'lng')
                               lon = parser.getDoubleValue();
                       }
 
                }
            }
 
            // update coordinates if we get back
            if (lat != null){
                a.GeoLocations__Latitude__s = lat;
                a.Location_Latitude__c = lat;
                a.GeoLocations__Longitude__s = lon;
                a.Location_Longitude__c = lon;
                Lat= lat;
                Lon= lon;
                update a;
            }
 
        } catch (Exception e) {
        }
    }
}
===================ApexTest Class===================
@IsTest(SeeAllData=False)
public class Test_LocationCallouts {
    static testMethod void validateLocationCallouts() {
   
    General_Settings__c setting1 = new  General_Settings__c();
    setting1.Name = 'Geocoding URL';
    setting1.Value__c = 'https://maps.googleapis.com/maps/api/geocode/json';
    insert setting1;
    General_Settings__c setting2 = new  General_Settings__c();
    setting2.Name = 'API Key';
    setting2.Value__c = 'AIzaSyBdTDHIFZgg1lG_p9fCg5QYcWWKrWe6K_E';
    insert setting2;
   
    Account a = new Account(Name='Testsup', BillingCountry='USA',BillingState='New Jersey',BillingCity='Cliff Wood',
                            BillingPostalCode='07010',BillingStreet='cliff wood');
    insert a;

        LocationCallouts.getLocation(a.id);
        Test.startTest();
        Test.setMock(HttpCalloutMock.class, new MockHttpResponseGenerator());
        Test.stopTest();
        HttpResponse res = CalloutClass.getInfoFromExternalService(); 
    }
}

================Dummy callout class===========
@isTest
global class MockHttpResponseGenerator implements HttpCalloutMock {
    global HTTPResponse respond(HTTPRequest req) {
        // Create a fake response.
        // Set response values, and
        // return response.
        system.debug('Mock ApiListMtgListMeetingsResult');
       
        //System.assertEquals('http://api.salesforce.com/foo/bar', req.getEndpoint());
        System.assertEquals('GET', req.getMethod());

 
       HttpResponse res = new HttpResponse();
       res.setHeader('Content-Type', 'text/xml;charset=UTF-8');
       //req.setEndpoint('http://maps.googleapis.com/maps/api/geocode/json?address='+address+'&sensor=false');
       res.setBody('{"name":"testrec","billingcountry":"United States","BillingState":"New Jersey","BillingCity":"California","BillingPostalcode":"07010","lat":37.386,"lon":-122.084}');
       res.setStatusCode(200);
       return res; 
       
    }
}
===============Coverage Status===============


Can any one help?
User-added image
Hi,

Need to help for code coverage i got 66% but json part not coveing in my controller please look into my code
================Apex Class====================
public class LocationCallouts {

     @future (callout=true)  // future method needed to run callouts from Triggers
      static public void getLocation(id accountId){
        // gather account info
        Account a = [SELECT BillingCity,BillingCountry,BillingPostalCode,BillingState,BillingStreet FROM Account WHERE id =: accountId];
 
        // create an address string
        String address = '';
        if (a.BillingStreet != null)
            address += a.BillingStreet +', ';
        if (a.BillingCity != null)
            address += a.BillingCity +', ';
        if (a.BillingState != null)
            address += a.BillingState +' ';
        if (a.BillingPostalCode != null)
            address += a.BillingPostalCode +', ';
        if (a.BillingCountry != null)
            address += a.BillingCountry;
 
        address = EncodingUtil.urlEncode(address, 'UTF-8');
        
        General_Settings__c ge= General_Settings__c.getValues('API Key');
        General_Settings__c eurl= General_Settings__c.getValues('Geocoding URL');        
        System.debug('##########'+eurl);
        System.debug('@@@@@@@@@@'+ge);
        String geocodingKey = ge.Value__c;
        String endpointurl= eurl.Value__c;
 
        // build callout
        Http h = new Http();
        HttpRequest req = new HttpRequest();
      //req.setEndpoint('http://maps.googleapis.com/maps/api/geocode/json?address='+address+'&sensor=false');
        req.setEndpoint(endpointurl+'?address='+ address + '&key=' + geocodingKey + '&sensor=false');
        req.setMethod('GET');
        req.setTimeout(60000);
 
        try{
            // callout
            HttpResponse res = h.send(req);
             System.debug('&&&&&'+res.getBody());
             System.debug('#####');
            // parse coordinates from response
            JSONParser parser = JSON.createParser(res.getBody());
            double lat = null;
            double lon = null;
            while (parser.nextToken() != null) {
                if ((parser.getCurrentToken() == JSONToken.FIELD_NAME) &&
                    (parser.getText() == 'location')){
                       parser.nextToken(); // object start
                       while (parser.nextToken() != JSONToken.END_OBJECT){
                           String txt = parser.getText();
                           parser.nextToken();
                           if (txt == 'lat')
                               lat = parser.getDoubleValue();
                           else if (txt == 'lng')
                               lon = parser.getDoubleValue();
                       }
 
                }
            }
 
            // update coordinates if we get back
            if (lat != null){
                a.GeoLocations__Latitude__s = lat;
                a.Location_Latitude__c = lat;
                a.GeoLocations__Longitude__s = lon;
                a.Location_Longitude__c = lon;
                Lat= lat;
                Lon= lon;
                update a;
            }
 
        } catch (Exception e) {
        }
    }
}
===================ApexTest Class===================
@IsTest(SeeAllData=False)
public class Test_LocationCallouts {
    static testMethod void validateLocationCallouts() {
   
    General_Settings__c setting1 = new  General_Settings__c();
    setting1.Name = 'Geocoding URL';
    setting1.Value__c = 'https://maps.googleapis.com/maps/api/geocode/json';
    insert setting1;
    General_Settings__c setting2 = new  General_Settings__c();
    setting2.Name = 'API Key';
    setting2.Value__c = 'AIzaSyBdTDHIFZgg1lG_p9fCg5QYcWWKrWe6K_E';
    insert setting2;
   
    Account a = new Account(Name='Testsup', BillingCountry='USA',BillingState='New Jersey',BillingCity='Cliff Wood',
                            BillingPostalCode='07010',BillingStreet='cliff wood');
    insert a;

        LocationCallouts.getLocation(a.id);
        Test.startTest();
        Test.setMock(HttpCalloutMock.class, new MockHttpResponseGenerator());
        Test.stopTest();
        HttpResponse res = CalloutClass.getInfoFromExternalService(); 
    }
}
===============Coverage Status===============
User-added imageUser-added imageUser-added image

Any one help?
Hi,
Am displaying all record acountnumbers with picklist in vf page.
My requirement is when a user come into this page and select any accountnumber.
So i need to store that value and display same account number for next time login.
Can any one suggest how to do this using Cookies?
Thanks.
Hi,
I created a custom login page and attached to community and created custom error mesasge for wrong username & password.But the problem here when i login with invalid or empty credentials both the community default error message and my custom error message is displaying in the login page. 
Can any one help in this error it will be very helpful to me, i want to display the custom error message without the default error message.

Thanks in Advance.
Hi,
I have 2 html input checkboxes in vf page i want to validate in commad button action is checked or not based on i want to display error message in page but whe i select check boxes after clicking on submit button am getting null in controller and page refreshing and all checkboxes are unchecked.
this is my page code
<input type="checkbox" id="Checkbox" value="{!Test1}" />
<input type="checkbox" id="Checkbox1" value="{!Test2}" />

<apex:commandButton value="submit" action="{!submitaction}"/>

class code
public Boolean Test1{get;set;}
    public Boolean Test2{get;set;}

public PageReference submitaction()
{  
    system.debug('value'+Test1)
    system.debug('value'+Test2)

Any one can help???
Hi any one help to cover myflow!=null. how to pass in test class.

Thanks in advance.

==============Class==============
public Flow.Interview.Case_Flow myFlow {get; set;}

public List<KnowledgeArticleVersion> getArticles()
      {   
           List<KnowledgeArticleVersion> articles;
           articles=new List<KnowledgeArticleVersion>();
           System.debug('****'+status+'****'+lang);
           articleQuery='SELECT Title, Summary, knowledgeArticleID FROM KnowledgeArticleVersion WHERE PublishStatus=:status AND Language = :lang';
           System.debug('******Flow'+myFlow);
          
           if(myFlow!=null)
           {   
            
             String entitle=(String) myFlow.getVariableValue('varPlease_select_customer_s_Product_Details');
            
             System.debug('**EntitleMent'+entitle);               
             if(entitle!=null)
               articleQuery+=' AND title LIKE \'%'+entitle+'%\'';
            
             String laptopIdentity =(String) myFlow.getVariableValue('varWith_regard_to_the_laptop_identify');
             System.debug('****Issues'+laptopIdentity);
             if(laptopIdentity!=null)
                  articleQuery+=' AND SUMMARY LIKE  \'%'+laptopIdentity +'%\'';
                             
            }        
            articles=Database.query(articleQuery);
            return articles;
                      
        }
Hi,

Any one help to write test class for webservice class

Thank you



HI

,

Write a simple app that READS the value of a Field and copies the value of that field into another custom field.

But while copying the data from ONE field to another Field, I need you to use this format.

Input Field data will be in LOWER CASE 

Output Field data will be in the "First Character Uppercase and rest in Lower case"

Examples"

input field = average
output field should be Average

input Field = simple
output field should be Simple

 

 

Thank you in Advance.

Hi All

 

Please see following code.

public class samp 
{
public list<contact> clist=new list<contact>();
public list<Account> alist=new list<Account>();
public samp()
{
for(contact c:[select department,Languages__c, id,name from contact])
{
clist.add(c);
}
for(account a:[select id from account])
{
alist.add(a);
}
}

public list<contact> getcontactlist()
{
return clist;
} 




}

 I am getting following error .please solve my problem,



 

 


 
Error: samp Compile Error: Loop variable must be an SObject or list of Account at line 11 column 13

 

 

thank you in advance

Hi All,

As per my requirement i want to display accounts with dublicate records.
for ex: am displaying 2 account records in vf page need to display 3 dublicate records for every record with expandable/collapsable like excel rows.

Account1strec              email   phone
Account1strecdub1   email   phone
Account1strecdub2   email   phone
Account1strecdub3   email   phone

Account2ndrec             email   phone
Account2ndrecdub1   email   phone
Account2
ndrecdub2   email   phone
Account2
ndrecdub3   email   phone

Dublicare records need to Expandable/collapsable like excel sheet

Is there any way to achive this can you plz help...Thanks in advance
public class DuplicateLeads {
    public List<Lead> leadsList {set;get;}
    public List<String> emailList {set;get;}
    public Integer count=0;
    public DuplicateLeads(){
        leadsList=[select email,name from lead];
    }
    public void BasedOnEmail(){
        List<aggregateResult> results=[select count(id)cou,email from lead group by email];
        for(AggregateResult ar:results){
            count=(Integer)ar.get('cou');
            System.debug(count);
            if(count>2){
                emailList.add((String)ar.get('email'));//values are not added to the list
                System.debug(emailList);
            }
        }
    } 
}
Hi Experts,
I need test class for the trigger given below:

trigger Casetrigger on Case (after insert) {

 list<Account> accList = new list<Account>();

 for(case c: Trigger.new){
      if(c.account!= null)
       accList.add(c.account);
     }
     
    //query email address from account object.
     
   Map<id,String> insideSalesEmailMap = new Map<Id, String>();
     for(Account acc: [select id,thermage_tlr__Rep_2__r.email from Account where id IN :accList]){
            insideSalesEmailMap.put(acc.id, acc.thermage_tlr__Rep_2__r.email);
        }  
        
        // preparing for Email send out. 
        
         List<Messaging.SingleEmailMessage> sme = new List<Messaging.SingleEmailMessage>();
     for(case c: Trigger.new){
      Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
      //email.setTemplateId('00X500000013avG');
      email.setToAddresses(new List<String>{insideSalesEmailMap.get(c.accountId)});
      email.setPlaintextbody('Test');
      email.setSaveAsActivity(false);
      sme.add(email);
     }
     
      //send Email
      
     if(sme != null && sme.size() > 0){
      Messaging.sendEmail(sme);
  }
     
}

Please help.
Hi All,

Is there any other way to retrieve grandparent id using grand child object in apex. Here am using sObject in this 3 different objects will recive based on object i want to identify like(sObjectType == Obj1__c.sObjectType)  and pass the grand parent id into map like(GP GPid = GPMap.get((Id)sObj.get('GPids'));)

Thanks & Regards,
Suresh
Hi,
I have a text field " Endos Count" which is a counter field. But the format of the count i need is, 001,002,003 etc. Now i am getting as 1,2 3. Can anyone suggest plz, how to get this type of format.
I just wrote the below formula, but its not working,
TEXT(VALUE(Endorsement_Count__c)+001)
I have a trigger and a test class and am in need of getting about 11 more lines covered and I'm in desperate need of help to get this.  Any help would be greatly appreciated.  I've listed the lines that aren't covered in the test below that I need help, as well as the trigger and test class.

Line 44-51

{ // Create the email attachment 
Messaging.EmailFileAttachment efa = new Messaging.EmailFileAttachment();
efa.setFileName(att.Name);
efa.setBody(att.body);
efa.setContentType(att.ContentType);
efa.setInline(false);
efaList.add(efa);
 }

Line 66-71
{   
    String teamMemId = ctm.MemberId;
    teamMemId = teamMemId.substring(0, teamMemId.length()-3);  
    String userEmailId = [select Id, Email from User where Id = :teamMemId].Email;   
    toEmails.add(userEmailId);
}    

Apex Trigger:
trigger  NewCaseEmail on Case (after insert,after update) {

for(Case t : trigger.new){
// Criteria for record type
 Id RecTypeId =  [Select Id, Name from RecordType where name = 'Test Record Type' limit 1].Id;

    if (t.Status == 'New' && t.Field_1__c  == 0 && t.RecordTypeId == RecTypeId ){
// New Email
    Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
// Setting the from to the OrgWideEmailAddress for Shared Inbox
    OrgWideEmailAddress[] owea = [select Id from OrgWideEmailAddress where Address = 'testemail@email.com'];    //Looking for ID for Email Address
    if ( owea.size() > 0 ) {
       email.setOrgWideEmailAddressId(owea.get(0).Id);    //Setting email from address to the ID of the Inbox
    } 

      Case cse = [SELECT id,  Case.owner.Name, Case.owner.Email,  Status, CaseNumber, Field_2__c , Field_2__c from Case WHERE Id = :t.Id];                    


        // create email content
        String CaseId = cse.id; 
        
        CaseId = CaseId.substring(0,CaseId.length()-3);
        
        String subject = 'Test Subject: ' + Cse.Field_2__c + '- Case #: ' + Cse.CaseNumber; 
        email.setSubject(subject);


		String line1 = 'Line 1. ' + '\n\n';
        String line2 = 'Line 2: ' +  cse.owner.Name + '\n';
        String line3 = 'Line 3: '+ Cse. Field_1__c  + '\n'; 
        String line4 = 'Line 4: '+ Cse.Field_2__c + '\n'; 
        
        
        
        String body = line1 + line2 + line3 + line4;
        email.setPlainTextBody(body);
        
       
        //Put your record id in ParentId
List<Attachment> attList = [SELECT id, Name, body, ContentType FROM Attachment WHERE ParentId = : CaseId];
// List of attachments handler
Messaging.EmailFileAttachment[] efaList = new List<Messaging.EmailFileAttachment>();
for(Attachment att : attList)
{ // Create the email attachment 
Messaging.EmailFileAttachment efa = new Messaging.EmailFileAttachment();
efa.setFileName(att.Name);
efa.setBody(att.body);
efa.setContentType(att.ContentType);
efa.setInline(false);
efaList.add(efa);
 }
// Attach files to email instance
email.setFileAttachments(efaList);

email.setPlainTextBody(body);

Id caseTeamRoleId= [SELECT Id FROM CaseTeamRole WHERE Name = 'Test Role' LIMIT 1].id;

List<CaseTeamMember> catmlst = [select Id, MemberId from CaseTeamMember where TeamRoleId = :caseTeamRoleId and ParentId = :t.Id];

String [] toEmails = new List<String>();

toEmails.add(cse.owner.Email);

for(CaseTeamMember ctm : catmlst)
{   
    String teamMemId = ctm.MemberId;
    teamMemId = teamMemId.substring(0, teamMemId.length()-3);  
    String userEmailId = [select Id, Email from User where Id = :teamMemId].Email;   
    toEmails.add(userEmailId);
}    


   
        email.setToAddresses(toEmails);
        if(email != null){
            Messaging.sendEmail(new Messaging.singleEmailMessage[] {email});
                           
          }
          
    
}
}

}

Test Class:
@isTest(seeAllData=true)
private class TestNewCaseEmailTrigger  {

    
    public static Case newCse;
    
   
    static void init(){
    
    newCse = new Case();

    newCse.Status = 'New';
    newCse.Field_1__c  = 0;
    newCse.RecordTypeID = [select ID from RecordType where Name = 'Test Record Type' and sObjectType = 'Case'].ID;

    }

    static testMethod void testNewCase() {
    init();
    Test.startTest();
    insert newCse;    
        
    Case cse = [select Id, Field_1__c from Case where Id = :newCse.id];
    cse.Field_1__c  = 1;
    update cse;
        
    Attachment attach=new Attachment(); 
    attach.Name='Test Attachment'; 
    Blob bodyBlob=Blob.valueOf('Test Attachment Body'); 
    attach.body=bodyBlob; attach.parentId=newCse.Id;
    insert attach;
        
        Id userId = [SELECT Id FROM User WHERE IsActive = true AND Profile.Name = 'System Administrator' LIMIT 1].id;
  
   
        Id caseTeamRoleId= [SELECT Id FROM CaseTeamRole WHERE Name = 'Test Role' LIMIT 1].id;
        List<CaseTeamMember> catmList=new List<CaseTeamMember>();
        
        CaseTeamMember tm=new CaseTeamMember();
        tm.ParentId=newCse.Id;
        tm.MemberId=userId;
        tm.TeamRoleId =caseTeamRoleId;
        catmList.add(tm);
        
        upsert catmList;
        
        
    Case cse2 = [select Id, Field_1__c  from Case where Id = :newCse.id];
    cse2.Field_1__c  = 0;
    update cse2;
                
    Test.stopTest();
    }
   

}

 
hi please any how to write a test method ?

// trigger on the case object and count the sum of the related case of the particual Account.
trigger coundSumofCase on Case (after insert,after update) {
    set<id> setid=new set<id>();
    if(trigger.isInsert){   
    for(case c:trigger.new){
        setid.add(c.accountid);
    }
    list<Account> listAccount=[select id,sum_of_case__c from account where id in:setid];
    list<case> listCont=[select id from case where accountid in:setid];
        for(account a:listAccount){
            a.sum_of_case__c=listCont.size();
        }
        update listAccount;
}
    if(trigger.isUpdate){
        for(case c:trigger.new){
            setid.add(c.accountid);
        }
        list<account> listAccount=[select id,sum_of_case__c from account where id in:setid];
        list<case> listcont=[select id from case where accountid in:setid];
        for(account a:listAccount){
            a.sum_of_case__c=listcont.size();
        }
        insert listAccount;
    }
}
Hi,
I'm trying to pass a value of a field OutputField to a variable of controller, but I can't.
I'm using outputField because I'm using inline editing tag.
What happens is:
When I edit the value, the record is not updated.

So I must get the new value that I'm inserting in this field (OutputField) and send to a variable on Controller,So I can make an update by this way.

Can someone help me?

Best Regards
Rafael
 
public class MultiAdd1
{
    
    //will hold the account records to be saved
    public List<Account>lstAcct  = new List<Account>();
    
    //list of the inner class
    public List<innerClass> lstInner 
    {get;set;}
    
    //will indicate the row to be deleted
    public String selectedRowIndex
    {get;set;}  
    
    //no. of rows added/records in the inner class list
    public Integer count = 1;
    //{get;set;}
    
    
    ////save the records by adding the elements in the inner class list to lstAcct,return to the same page
    public PageReference Save()
    {
        PageReference pr = new PageReference('/apex/MultiAdd');
        
        for(Integer j = 0;j<lstInner.size();j++)
        {
            lstAcct.add(lstInner[j].acct);
        } 
        insert lstAcct;
        pr.setRedirect(True);
        return pr;
    }
        
    //add one more row
    public void Add()
    {   
        count = count+1;
        addMore();      
    }
    
    /*Begin addMore*/
    public void addMore()
    {
        //call to the iner class constructor
        innerClass objInnerClass = new innerClass(count);
        
        //add the record to the inner class list
        lstInner.add(objInnerClass);    
        system.debug('lstInner---->'+lstInner);            
    }/* end addMore*/
    
    /* begin delete */
    public void Del()
    {
        system.debug('selected row index---->'+selectedRowIndex);
        lstInner.remove(Integer.valueOf(selectedRowIndex)-1);
        count = count - 1;
        
    }/*End del*/
    
    
    
    /*Constructor*/
    public MultiAdd1(ApexPages.StandardController ctlr)
    {
    
        lstInner = new List<innerClass>();
        addMore();
        selectedRowIndex = '0';
        
    }/*End Constructor*/
        


    /*Inner Class*/
    public class innerClass
    {       
        /*recCount acts as a index for a row. This will be helpful to identify the row to be deleted */
        public String recCount
        {get;set;}
        
        
        public Account acct 
        {get;set;}
        
        /*Inner Class Constructor*/
        public innerClass(Integer intCount)
        {
            recCount = String.valueOf(intCount);        
            
            /*create a new account*/
            acct = new Account();
            
        }/*End Inner class Constructor*/    
    }/*End inner Class*/
}/*End Class*/
Hi All,

I am getting all the records of associated deals as expected, but as the nuimber of record in database are large, so it is dispalying in different pages. 
Now the issue is Table header valures "talent Name" & "Service Type" is coming only on First page(because we didnot apply any repeat functionlity over the header) not on all pages, on all other pages, there is first row blank....Is there ay way to repeat the header values only after the page break..


Thanks in Advance for the help..
<apex:outputpanel rendered="{!(dealRequest.ad.size > 0)}" >
             <div class="slds-m-bottom--x-large">
                <h3 class="slds-p-around--x-small slds-theme--info slds-text-heading--medium"><strong>Associated Deals</strong></h3>
                
                <table class="slds-box slds-table slds-table--bordered slds-table--col-bordered slds-no-row-hover colBordered">
                  
                  <thead>
                  <tr class="slds-text-title--caps slds-theme--shade">
                      <th scope="col">
                      
                        <div class="slds-truncate">Talent Name</div>
                        
                      </th>
                      <th colspan="2" scope="col">
                        <div class="slds-truncate">Service Type</div>
                      </th>
                    </tr>
                    </thead>
                    
                  <tbody>
                    <apex:repeat value="{!dealRequest.ad}" var="assDeals">
                      <tr>
                      <td>
                        <div class="slds-truncate">{!assDeals.Talent_Name__r.Name}</div>
                      </td>
                      <td>
                        <div class="slds-truncate">{!assDeals.Service_Type__c}</div>
                      </td>
                    </tr>
                    </apex:repeat>
                  </tbody>
                </table>
             </div>
            </apex:outputpanel>

 
Hi,

I want to add a Visualforce section to an account page that is 5 rows high and 4 columns wide and all it needs to do is pull in the 20 fields needed.

          Field Name                      Field Name                                                        Field Name                     Field Name
          Field Name                      Field Name                                                        Field Name                     Field Name
          Field Name                      Field Name                                                        Field Name                     Field Name
          Field Name                      Field Name                                                        Field Name                     Field Name
          Field Name                      Field Name                                                        Field Name                     Field Name

Can you help write this for me? I feel it should be really easy, but I am really struggling to understand it all.

Thanks

Matt
Need help for Code coverage to json parser in locationcallouts apex class
Hi,

Need to help for code coverage i got 66% but json part not coveing in my controller please look into my code
================Apex Class====================
public class LocationCallouts {

     @future (callout=true)  // future method needed to run callouts from Triggers
      static public void getLocation(id accountId){
        // gather account info
        Account a = [SELECT BillingCity,BillingCountry,BillingPostalCode,BillingState,BillingStreet FROM Account WHERE id =: accountId];
 
        // create an address string
        String address = '';
        if (a.BillingStreet != null)
            address += a.BillingStreet +', ';
        if (a.BillingCity != null)
            address += a.BillingCity +', ';
        if (a.BillingState != null)
            address += a.BillingState +' ';
        if (a.BillingPostalCode != null)
            address += a.BillingPostalCode +', ';
        if (a.BillingCountry != null)
            address += a.BillingCountry;
 
        address = EncodingUtil.urlEncode(address, 'UTF-8');
        
        General_Settings__c ge= General_Settings__c.getValues('API Key');
        General_Settings__c eurl= General_Settings__c.getValues('Geocoding URL');        
        System.debug('##########'+eurl);
        System.debug('@@@@@@@@@@'+ge);
        String geocodingKey = ge.Value__c;
        String endpointurl= eurl.Value__c;
 
        // build callout
        Http h = new Http();
        HttpRequest req = new HttpRequest();
      //req.setEndpoint('http://maps.googleapis.com/maps/api/geocode/json?address='+address+'&sensor=false');
        req.setEndpoint(endpointurl+'?address='+ address + '&key=' + geocodingKey + '&sensor=false');
        req.setMethod('GET');
        req.setTimeout(60000);
 
        try{
            // callout
            HttpResponse res = h.send(req);
             System.debug('&&&&&'+res.getBody());
             System.debug('#####');
            // parse coordinates from response
            JSONParser parser = JSON.createParser(res.getBody());
            double lat = null;
            double lon = null;
            while (parser.nextToken() != null) {
                if ((parser.getCurrentToken() == JSONToken.FIELD_NAME) &&
                    (parser.getText() == 'location')){
                       parser.nextToken(); // object start
                       while (parser.nextToken() != JSONToken.END_OBJECT){
                           String txt = parser.getText();
                           parser.nextToken();
                           if (txt == 'lat')
                               lat = parser.getDoubleValue();
                           else if (txt == 'lng')
                               lon = parser.getDoubleValue();
                       }
 
                }
            }
 
            // update coordinates if we get back
            if (lat != null){
                a.GeoLocations__Latitude__s = lat;
                a.Location_Latitude__c = lat;
                a.GeoLocations__Longitude__s = lon;
                a.Location_Longitude__c = lon;
                Lat= lat;
                Lon= lon;
                update a;
            }
 
        } catch (Exception e) {
        }
    }
}
===================ApexTest Class===================
@IsTest(SeeAllData=False)
public class Test_LocationCallouts {
    static testMethod void validateLocationCallouts() {
   
    General_Settings__c setting1 = new  General_Settings__c();
    setting1.Name = 'Geocoding URL';
    setting1.Value__c = 'https://maps.googleapis.com/maps/api/geocode/json';
    insert setting1;
    General_Settings__c setting2 = new  General_Settings__c();
    setting2.Name = 'API Key';
    setting2.Value__c = 'AIzaSyBdTDHIFZgg1lG_p9fCg5QYcWWKrWe6K_E';
    insert setting2;
   
    Account a = new Account(Name='Testsup', BillingCountry='USA',BillingState='New Jersey',BillingCity='Cliff Wood',
                            BillingPostalCode='07010',BillingStreet='cliff wood');
    insert a;

        LocationCallouts.getLocation(a.id);
        Test.startTest();
        Test.setMock(HttpCalloutMock.class, new MockHttpResponseGenerator());
        Test.stopTest();
        HttpResponse res = CalloutClass.getInfoFromExternalService(); 
    }
}

================Dummy callout class===========
@isTest
global class MockHttpResponseGenerator implements HttpCalloutMock {
    global HTTPResponse respond(HTTPRequest req) {
        // Create a fake response.
        // Set response values, and
        // return response.
        system.debug('Mock ApiListMtgListMeetingsResult');
       
        //System.assertEquals('http://api.salesforce.com/foo/bar', req.getEndpoint());
        System.assertEquals('GET', req.getMethod());

 
       HttpResponse res = new HttpResponse();
       res.setHeader('Content-Type', 'text/xml;charset=UTF-8');
       //req.setEndpoint('http://maps.googleapis.com/maps/api/geocode/json?address='+address+'&sensor=false');
       res.setBody('{"name":"testrec","billingcountry":"United States","BillingState":"New Jersey","BillingCity":"California","BillingPostalcode":"07010","lat":37.386,"lon":-122.084}');
       res.setStatusCode(200);
       return res; 
       
    }
}
===============Coverage Status===============


Can any one help?
User-added image
Hi,

Need to help for code coverage i got 66% but json part not coveing in my controller please look into my code
================Apex Class====================
public class LocationCallouts {

     @future (callout=true)  // future method needed to run callouts from Triggers
      static public void getLocation(id accountId){
        // gather account info
        Account a = [SELECT BillingCity,BillingCountry,BillingPostalCode,BillingState,BillingStreet FROM Account WHERE id =: accountId];
 
        // create an address string
        String address = '';
        if (a.BillingStreet != null)
            address += a.BillingStreet +', ';
        if (a.BillingCity != null)
            address += a.BillingCity +', ';
        if (a.BillingState != null)
            address += a.BillingState +' ';
        if (a.BillingPostalCode != null)
            address += a.BillingPostalCode +', ';
        if (a.BillingCountry != null)
            address += a.BillingCountry;
 
        address = EncodingUtil.urlEncode(address, 'UTF-8');
        
        General_Settings__c ge= General_Settings__c.getValues('API Key');
        General_Settings__c eurl= General_Settings__c.getValues('Geocoding URL');        
        System.debug('##########'+eurl);
        System.debug('@@@@@@@@@@'+ge);
        String geocodingKey = ge.Value__c;
        String endpointurl= eurl.Value__c;
 
        // build callout
        Http h = new Http();
        HttpRequest req = new HttpRequest();
      //req.setEndpoint('http://maps.googleapis.com/maps/api/geocode/json?address='+address+'&sensor=false');
        req.setEndpoint(endpointurl+'?address='+ address + '&key=' + geocodingKey + '&sensor=false');
        req.setMethod('GET');
        req.setTimeout(60000);
 
        try{
            // callout
            HttpResponse res = h.send(req);
             System.debug('&&&&&'+res.getBody());
             System.debug('#####');
            // parse coordinates from response
            JSONParser parser = JSON.createParser(res.getBody());
            double lat = null;
            double lon = null;
            while (parser.nextToken() != null) {
                if ((parser.getCurrentToken() == JSONToken.FIELD_NAME) &&
                    (parser.getText() == 'location')){
                       parser.nextToken(); // object start
                       while (parser.nextToken() != JSONToken.END_OBJECT){
                           String txt = parser.getText();
                           parser.nextToken();
                           if (txt == 'lat')
                               lat = parser.getDoubleValue();
                           else if (txt == 'lng')
                               lon = parser.getDoubleValue();
                       }
 
                }
            }
 
            // update coordinates if we get back
            if (lat != null){
                a.GeoLocations__Latitude__s = lat;
                a.Location_Latitude__c = lat;
                a.GeoLocations__Longitude__s = lon;
                a.Location_Longitude__c = lon;
                Lat= lat;
                Lon= lon;
                update a;
            }
 
        } catch (Exception e) {
        }
    }
}
===================ApexTest Class===================
@IsTest(SeeAllData=False)
public class Test_LocationCallouts {
    static testMethod void validateLocationCallouts() {
   
    General_Settings__c setting1 = new  General_Settings__c();
    setting1.Name = 'Geocoding URL';
    setting1.Value__c = 'https://maps.googleapis.com/maps/api/geocode/json';
    insert setting1;
    General_Settings__c setting2 = new  General_Settings__c();
    setting2.Name = 'API Key';
    setting2.Value__c = 'AIzaSyBdTDHIFZgg1lG_p9fCg5QYcWWKrWe6K_E';
    insert setting2;
   
    Account a = new Account(Name='Testsup', BillingCountry='USA',BillingState='New Jersey',BillingCity='Cliff Wood',
                            BillingPostalCode='07010',BillingStreet='cliff wood');
    insert a;

        LocationCallouts.getLocation(a.id);
        Test.startTest();
        Test.setMock(HttpCalloutMock.class, new MockHttpResponseGenerator());
        Test.stopTest();
        HttpResponse res = CalloutClass.getInfoFromExternalService(); 
    }
}
===============Coverage Status===============
User-added imageUser-added imageUser-added image

Any one help?
I have created a class which helps to automatically update a geolocation field. I have also given the test class but the code coverage is only 72%. below is the code and test class. The lines of code which is in bold are not covered by the test class. Can anyone help with writing test class.

public class AccountGeocodeAddress{
// static variable to determine if geocoding has already occurred
private static Boolean geocodingCalled = false;
// wrapper method to prevent calling future methods from an existing future context
public static void DoAddressGeocode(id
accountId) {
  if
(geocodingCalled || System.isFuture()) {
    System.debug(LoggingLevel.WARN, '***Address Geocoding Future Method Already Called - Aborting...');
    return;
  }
  // if not being called from future context, geocode the address
  geocodingCalled = true;
  geocodeAddress(accountId);
}
// we need a future method to call Google Geocoding API from Salesforce
@future (callout=true)
static private void geocodeAddress(id accountId)

  // Key for Google Maps Geocoding API
  String geocodingKey = 'AIzaSyAYPyw3l--jV92bEfgq20vfAggygvqiIPg';
  // get the passed in address
  Account geoAccount = [SELECT BillingStreet, BillingCity, BillingState, BillingCountry, BillingPostalCode FROM Account WHERE id = :accountId];
    
  //check that we have enough information to geocode the address
  if((geoAccount.BillingStreet == null) || (geoAccount.BillingCity == null)) {
    System.debug(LoggingLevel.WARN, 'Insufficient Data to Geocode Address');
    return;
  }
  //create a string for the address to pass to Google Geocoding API
  String geoAddress = '';
  if(geoAccount.BillingStreet != null)
    geoAddress += geoAccount.BillingStreet + ', ';
  if(geoAccount.BillingCity != null)
    geoAddress += geoAccount.BillingCity + ', ';
  if(geoAccount.BillingState != null)
    geoAddress += geoAccount.BillingState + ', ';
  if(geoAccount.BillingCountry != null)
    geoAddress += geoAccount.BillingCountry + ', ';
  if(geoAccount.BillingPostalCode != null)
    geoAddress += geoAccount.BillingPostalCode;
  
  //encode the string so we can pass it as part of URL
  geoAddress = EncodingUtil.urlEncode(geoAddress, 'UTF-8');
  //build and make the callout to the Geocoding API
  Http http = new Http();
  HttpRequest request = new HttpRequest();
  request.setEndpoint('https://maps.googleapis.com/maps/api/geocode/json?address=' + geoAddress + '&key=' + geocodingKey + '&sensor=false');
  request.setMethod('GET');
  request.setTimeout(60000);
  try {
    //make the http callout
    HttpResponse response = http.send(request);
    //parse JSON to extract co-ordinates
    JSONParser responseParser = JSON.createParser(response.getBody());
    //initialize co-ordinates
    double latitude = null;
    double longitude = null;
    while(responseParser.nextToken() != null) {
      if((responseParser.getCurrentToken() == JSONToken.FIELD_NAME) && (responseParser.getText() == 'location')) {
        responseParser.nextToken();
        while(responseParser.nextToken() != JSONToken.END_OBJECT) {
         
        String locationText = responseParser.getText();
         
        responseParser.nextToken();
         
        if (locationText == 'lat')
           
        latitude = responseParser.getDoubleValue();
         
        else if (locationText == 'lng')
           
        longitude = responseParser.getDoubleValue();
        }
      }
    }
    //update co-ordinates on address if we get them back
    if(latitude != null) {
      geoAccount.Location__Latitude__s = latitude;
      geoAccount.Location__Longitude__s = longitude;
      update geoAccount;
    }

  } catch
(Exception e) {
    System.debug(LoggingLevel.ERROR, 'Error Geocoding Address - ' + e.getMessage());
  }
}
}

Test Class

@IsTest 
public class KioskGeocodeAddressTest {
    Static testMethod void testkioskGeocodeAdress(){
        FuseBox_Kiosk_Address__c kiosk = new FuseBox_Kiosk_Address__c(Name = 'Test');
        kiosk.Street_Name__c = '4500 Truxel rd';
        kiosk.Address_Line_2__c = 'Apt 1015';
        kiosk.City__c = 'Sacramento';
        Kiosk.State__c = 'California';
        Kiosk.Zip_Code__c = '95833';
        kiosk.Country__c = 'United States';
        insert kiosk;
        test.startTest();
        string status;
        HttpRequest request = new HttpRequest();
        StaticResourceCalloutMock mock = new StaticResourceCalloutMock();
        mock.setStaticResource('GoogleMapsAPI');
        mock.setStatusCode(200);
        mock.setHeader('Content-Type', 'application/json');
        mock.respond(request);
        HttpResponse response = new HttpResponse();
        JSONParser responseParser = JSON.createParser(response.getBody());
        String Loc = responseParser.getText();
        double latitude = 33.33333;
        double longitude;
        // Set the mock callout mode
        Test.setMock(HttpCalloutMock.class, mock);
                 
        // Call the method that performs the callout
        kioskGeocodeAddress.DoAddressGeocode(kiosk.Id);
        system.assertNotEquals(latitude,kiosk.Location__Latitude__s);
    }
}