• George Laird 12
  • NEWBIE
  • 40 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 8
    Questions
  • 8
    Replies
Hello All,

I'm completely stuck here.  I wrote a trigger to fire after update on the object "Individual Link Level Detail" which is part of the Marketing Cloud Connector.  Basically, whenever someone clicks on a link, i need to update a score on a custom object that's related to the Contact that clicked the link.  That all works fine, but the problem is the way Marketing Cloud updates those objects using the bulk api.  

When I click on one link, the trigger fires, calls my apex class, and works great.  The score increases.  
When I click on mulitiple links, they get put into a bulk api call from MC, and then nothing really works correctly. 

The problem also is that the dubug logs seems to say the update is happening, although the values don't change.  OR they change for one link, but not the next other ones.  I have no idea what's going on here.   Here is my trigger and my code:

For example:  I'll open the email and click on two links.  SiteVisit and WhitepaperDownload.   My trigger runs and calls the apex class twice, once for each link update.  It will only update one of the two records though.  If I open the email and just click on ONE link, it'll work every time. 



TRIGGER:

trigger ClicksTrigger on et4ae5__IndividualLink__c (after insert, after update) {
   
    if(Trigger.isInsert){ 
        for (et4ae5__IndividualLink__c click : Trigger.new){
        
        GivePointsForClicks.givePoints(click.Id);
    
           }
    } 
    
    else if(Trigger.isUpdate){
        
        for (et4ae5__IndividualLink__c click : Trigger.new){
            
            //Get the old value of the number of clicks
            et4ae5__IndividualLink__c il = Trigger.oldMap.get(click.Id);
            double oldValue = il.et4ae5__NumberOfTotalClicks__c;
            system.debug('The old value for clicks was: '+oldValue);
            //Get the new value of the number of clicks
            double newValue = click.et4ae5__NumberOfTotalClicks__c;
            system.debug('The new value for clicks is: '+newValue);
            //Subtrack old value from new value to get the delta value
            double deltaValue = newValue - oldValue;
            system.debug('The delta value is: '+deltaValue);
            
            if(deltaValue > 0){
                
                
                CountClicks.giveClicks(click.id,deltaValue);    
                
            }
            

            
        }
        
    }
    
}


APEX CLASS: 

public class CountClicks {
    
    @future
    public static void giveClicks(id linkID,double deltaValue){
     
        //Get the ContactId from the related Email Result record (who did the clicking).
        List<et4ae5__IndividualLink__c> ContactList = [SELECT et4ae5__Individual_Email_Result__r.et4ae5__Contact__r.id 
                                                       FROM et4ae5__IndividualLink__c 
                                                       WHERE et4ae5__IndividualLink__c.id =: linkID];
        Id ContactID = ContactList.get(0).et4ae5__Individual_Email_Result__r.et4ae5__Contact__r.id;
        system.debug('The Contact Id: '+ContactId);
         
        //Get the most recent scoring record from that Contact
        List<Scoring__c> scoringRecords = [SELECT id,name,
                                          Scoring__c.Whitepaper_Download_Click_CountCES1__c,Scoring__c.Site_Visit_Click_CountCES1__c,Scoring__c.Blog_Visit_Click_CountCES1__c,Scoring__c.Resource_Center_Visit_Click_CountCES1__c,Scoring__c.Video_Watched_Click_CountCES1__c,
                                          Scoring__c.Whitepaper_Download_Click_CountCES2__c,Scoring__c.Site_Visit_Click_CountCES2__c,Scoring__c.Blog_Visit_Click_CountCES2__c,Scoring__c.Resource_Center_Visit_Click_CountCES2__c,Scoring__c.Video_Watched_Click_CountCES2__c,
                                          Scoring__c.Whitepaper_Download_Click_CountCES3__c,Scoring__c.Site_Visit_Click_CountCES3__c,Scoring__c.Blog_Visit_Click_CountCES3__c,Scoring__c.Resource_Center_Visit_Click_CountCES3__c,Scoring__c.Video_Watched_Click_CountCES3__c,
                                          Scoring__c.Whitepaper_Download_Click_CountCES4__c,Scoring__c.Site_Visit_Click_CountCES4__c,Scoring__c.Blog_Visit_Click_CountCES4__c,Scoring__c.Resource_Center_Visit_Click_CountCES4__c,Scoring__c.Video_Watched_Click_CountCES4__c
                                          FROM  Scoring__c 
                                          WHERE RelatedContact__c  =: ContactId 
                                          ORDER BY createdDate 
                                          DESC limit 1];
        Scoring__c scoringRecord = scoringRecords[0];
        system.debug('The Scoring Record: '+scoringRecord);
        system.debug('The Scoring Record Name: '+scoringRecord.Name);
        
        //Get the name of the Link clicked
        List<et4ae5__IndividualLink__c> LinkList = [SELECT name FROM et4ae5__IndividualLink__c WHERE et4ae5__IndividualLink__c.id =: linkID];
        string linkName = LinkList.get(0).Name;
        system.debug('The linked clicked was: '+linkName);
        
        //Give points to the appropriate CES category and link.
        if(linkName.contains('CES1')){
            
            if(linkName.contains('Whitepaper')){
                            
                //Add delta value to scoring record click count
                double currentValue = scoringRecord.Whitepaper_Download_Click_CountCES1__c;
                scoringRecord.Whitepaper_Download_Click_CountCES1__c = currentValue+deltaValue;
                update scoringRecord;
            }
            li
            else if(linkName.contains('Website')){
                
                //Add delta value to scoring record click count
                double currentValue = scoringRecord.Site_Visit_Click_CountCES1__c;
                scoringRecord.Site_Visit_Click_CountCES1__c = currentValue+deltaValue;
                update scoringRecord;
          
            }
            
            else if(linkName.contains('Blog')){
             
                //Add delta value to scoring record click count
                double currentValue = scoringRecord.Blog_Visit_Click_CountCES1__c;
                scoringRecord.Blog_Visit_Click_CountCES1__c = currentValue+deltaValue;
                update scoringRecord;
                 
            }
            
             else if(linkName.contains('ResourceCenter')){
                
                //Add delta value to scoring record click count
                double currentValue = scoringRecord.Resource_Center_Visit_Click_CountCES1__c;
                scoringRecord.Resource_Center_Visit_Click_CountCES1__c = currentValue+deltaValue;
                update scoringRecord;
  
            }
            
            else if(linkName.contains('Video')){
                
                //Add delta value to scoring record click count
                double currentValue = scoringRecord.Video_Watched_Click_CountCES1__c;
                scoringRecord.Video_Watched_Click_CountCES1__c = currentValue+deltaValue;
                update scoringRecord;
               
            }            
        }
        
        else if(linkName.contains('CES2')){
            
            if(linkName.contains('Whitepaper')){
                
                //Add delta value to scoring record click count
                double currentValue = scoringRecord.Whitepaper_Download_Click_CountCES2__c;
                scoringRecord.Whitepaper_Download_Click_CountCES2__c = currentValue+deltaValue;
                update scoringRecord;
                              
            }
            
            else if(linkName.contains('Website')){
                
                //Add delta value to scoring record click count
                double currentValue = scoringRecord.Site_Visit_Click_CountCES2__c;
                scoringRecord.Site_Visit_Click_CountCES2__c = currentValue+deltaValue;
                update scoringRecord;
  
            }
            
            else if(linkName.contains('Blog')){
                
                //Add delta value to scoring record click count
                double currentValue = scoringRecord.Blog_Visit_Click_CountCES2__c;
                scoringRecord.Blog_Visit_Click_CountCES2__c = currentValue+deltaValue;
                update scoringRecord;
  
            }
            
             else if(linkName.contains('ResourceCenter')){
                
                //Add delta value to scoring record click count
                double currentValue = scoringRecord.Resource_Center_Visit_Click_CountCES2__c;
                scoringRecord.Resource_Center_Visit_Click_CountCES2__c = currentValue+deltaValue;
                update scoringRecord;
  
            }
            
            else if(linkName.contains('Video')){
                
                //Add delta value to scoring record click count
                double currentValue = scoringRecord.Video_Watched_Click_CountCES2__c;
                scoringRecord.Video_Watched_Click_CountCES2__c = currentValue+deltaValue;
                update scoringRecord;
  
            }            
        }
        
        else if(linkName.contains('CES3')){
            
            if(linkName.contains('Whitepaper')){
                
                //Add delta value to scoring record click count
                double currentValue = scoringRecord.Whitepaper_Download_Click_CountCES3__c;
                scoringRecord.Whitepaper_Download_Click_CountCES3__c = currentValue+deltaValue;
                update scoringRecord;
            }
            
            else if(linkName.contains('Website')){
                
               //Add delta value to scoring record click count
                double currentValue = scoringRecord.Site_Visit_Click_CountCES3__c;
                scoringRecord.Site_Visit_Click_CountCES3__c = currentValue+deltaValue;
                update scoringRecord;
  
            }
            
            else if(linkName.contains('Blog')){
                
                //Add delta value to scoring record click count
                double currentValue = scoringRecord.Blog_Visit_Click_CountCES3__c;
                scoringRecord.Blog_Visit_Click_CountCES3__c = currentValue+deltaValue;
                update scoringRecord;
  
            }
            
             else if(linkName.contains('ResourceCenter')){
                
                //Add delta value to scoring record click count
                double currentValue = scoringRecord.Resource_Center_Visit_Click_CountCES3__c;
                scoringRecord.Resource_Center_Visit_Click_CountCES3__c = currentValue+deltaValue;
                update scoringRecord;
  
            }
            
            else if(linkName.contains('Video')){
                
                //Add delta value to scoring record click count
                double currentValue = scoringRecord.Video_Watched_Click_CountCES3__c;
                scoringRecord.Video_Watched_Click_CountCES3__c = currentValue+deltaValue;
                update scoringRecord;
  
            }            
        }
        
        else if(linkName.contains('CES4')){
            
            if(linkName.contains('Whitepaper')){
                
                //Add delta value to scoring record click count
                double currentValue = scoringRecord.Whitepaper_Download_Click_CountCES4__c;
                scoringRecord.Whitepaper_Download_Click_CountCES4__c = currentValue+deltaValue;
                update scoringRecord;
                
            }
            
            else if(linkName.contains('Website')){
                
                //Add delta value to scoring record click count
                double currentValue = scoringRecord.Site_Visit_Click_CountCES4__c;
                scoringRecord.Site_Visit_Click_CountCES4__c = currentValue+deltaValue;
                update scoringRecord;
  
            }
            
            else if(linkName.contains('Blog')){
                
                //Add delta value to scoring record click count
                double currentValue = scoringRecord.Blog_Visit_Click_CountCES4__c;
                scoringRecord.Blog_Visit_Click_CountCES4__c = currentValue+deltaValue;
                update scoringRecord;
  
            }
            
            else if(linkName.contains('ResourceCenter')){
                
                //Add delta value to scoring record click count
                double currentValue = scoringRecord.Resource_Center_Visit_Click_CountCES4__c;
                scoringRecord.Resource_Center_Visit_Click_CountCES4__c = currentValue+deltaValue;
                update scoringRecord;
  
            }
            
            else if(linkName.contains('Video')){
                
                //Add delta value to scoring record click count
                double currentValue = scoringRecord.Video_Watched_Click_CountCES4__c;
                scoringRecord.Video_Watched_Click_CountCES4__c = currentValue+deltaValue;
                update scoringRecord;
  
            }            
        }        
    }
}

 
Hello.  I'm very new to apex and programming in general.  I have to deploy this class tonight or tomorrow.  My apex works perfectly but I'm stuck and can't get code coverage for some reason.  Here are the facts:

1. I am using a visualforce page called from a button on the Account page.  

2. In my class I"m getting the Id of the Account from the VF page that the button was pressed from. 

3. Code works great however, when I call the method callCarriers() from the test class, it doesn't have the ID from the button pressed on the Account page of course.  That's the problem.  I tried all sorts of pageref stuff to try and pass the Account ID of the newly created account in the test class but it wont' work. 

4.  I'm BRAND new to coding so my code is very sloppy.  Also I have a lot of things in there that probably don't need to be there, but I'm just trying everything.   Please someone help!


VISUALFORCE PAGE

<apex:page standardController="Account" extensions="CallCarriersForAddyChange"> <apex:form > <apex:commandButton value="Warning: You are about to send an email to carriers! Click here if you are totally sure you want to do this." onclick="javascript&colon;window.alert('Do you want to proceed?');" action="{!callCarriers}"/> <br/> <apex:commandButton value="Ooops, get me out of here!" action="{!forceClose}"/> <apex:inputHidden value="{!Account.OwnerId}"/> </apex:form> </apex:page>



APEX CLASS:

public class CallCarriersForAddyChange {
    //Apex properties or variables

    public Id Id { get; set; }
    public Account act { get; set; }

    //constructor to get the Account record
    public CallCarriersForAddyChange(ApexPages.StandardController controller) {
    act =  (Account) controller.getRecord();
    Id = act.Id;
    System.debug('The Account record: ' + act);
    
    }

    //Method that can is called from the Visual Force page action attribute

    public PageReference callCarriers() {
        
        System.debug('Account Id: ' + Id);
        //build your code logic here
        
        string email;
        List<VRNA__Policy__c> carriers = [SELECT         VRNA__Issuing_Carrier__r.VRNA__Email__c, 
                                          VRNA__First_Named_Insured__c,
                                          VRNA__Policy_Number__c,
                                          VRNA__Issuing_Carrier__r.Name, 
                                          VRNA__Account__r.BillingStreet,
                                          VRNA__Account__r.BillingCity,
                                          VRNA__Account__r.BillingState,
                                          VRNA__Account__r.BillingPostalCode
                                          FROM VRNA__Policy__c 
                                          WHERE VRNA__Account__c =: Id AND RecordTypeID = '012f4000000giyZ'];
     
  List<string> emails = new List<string>();
        system.debug('Carriers: '+carriers);
        
            for(VRNA__Policy__c a : carriers){
            email = a.VRNA__Issuing_Carrier__r.VRNA__Email__c;
               emails.add(email);  
            system.debug('Email List' +emails);
    
        }
        
        for(VRNA__Policy__c p : carriers){
           
          @TestVisible Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
            // Strings to hold the email addresses to which you are sending the email.
            String[] toAddresses = new String[] {p.VRNA__Issuing_Carrier__r.VRNA__Email__c};
            // Assign the addresses for the To and CC lists to the mail object.
            mail.setToAddresses(toAddresses);    
            // Specify the address used when the recipients reply to the email.
            mail.setReplyTo('service@amventure.com');
            // Specify the name used as the display name.
            mail.setSenderDisplayName('Amventure Customer Service');
            // Specify the subject line for your email address.
            mail.setSubject('Policy Mailing Address Change');
            // Set the object Id for merging fields into the template
            //mail.setTargetObjectId(p.Id);
            // The email template ID used for the email
            //mail.setTemplateId('00XM0000000N7NU');
            // Specify the text content of the email.
            mail.setHtmlBody('To Whom It May Concern:<p>' + 'A change to a policy mailing address been requested effective today.<p>' + 'Name Insured: '+p.VRNA__First_Named_Insured__c + '<br/>Policy Number: '+p.VRNA__Policy_Number__c + '<br/>Carrier Name: '+p.VRNA__Issuing_Carrier__r.Name + '<p><b>New Address</b>' +'<br/>Street: '+p.VRNA__Account__r.BillingStreet +'<br/>City: '+p.VRNA__Account__r.BillingCity +'<br/>State: '+p.VRNA__Account__r.BillingState + '<br/>Zip: '+p.VRNA__Account__r.BillingPostalCode);
            // Send the email you have created.
            Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
          
        }

        PageReference pageRef = new PageReference('/'+Id);
        pageRef.setRedirect(true);
        return pageRef; //Returns to the case page
    }
    
     public PageReference forceClose(){
     PageReference page  = page.ForceClose; 
     return page;
     }

TEST CLASS:

@istest(SeeAllData=true)

public class CallCarriersForAddyChangeTest {

    public static testmethod void CallCarriersForAddyChangeTest(){
        
        //create an account
        Account a = new Account(
        Name = 'Test Account',
        BillingStreet='123 main',
        BillingState='Ohio',
        BillingPostalCode='12345',
        RecordTypeId = '012f4000000giww',    
        VRNA__Issuing_Carrier__c = true,
        VRNA__Billing_Company__c = true);
        insert a;
        system.debug('Test Account Id: '+a.Id);
        
        VRNA__Policy__c p = new VRNA__Policy__c(
        Completed_Post_Sale_Checklist__c = 'true',
        VRNA__First_Named_Insured__c = 'tom tomerson',    
        VRNA__Policy_Type__c = 'Crime',
        VRNA__Status__c = 'Written (Sold)',
        VRNA__Account__c = a.Id,
        VRNA__Policy_Number__c = '111111',
        VRNA__Effective_Date__c = Date.today(),
        VRNA__Agency__c = 'AmVenture Insurance Agency, Inc',
        VRNA__Branch__c = 'AmVenture Insurance Agency, Inc',
        VRNA__Department__c = 'Commercial',
        VRNA__Issuing_Carrier__c = a.Id,
        VRNA__Billing_Company__c = a.Id,
        VRNA__Date_First_Written__c = Date.today(),
        VRNA__Policy_Issuing_State_picklist__c = 'OH',
        VRNA__Package_Type__c = 'Monoline',
        VRNA__Primary_Producer__c = '005f4000000yGSY',   
        RecordTypeId = '012f4000000giyZ');
        insert p;
        
        test.startTest(); 
        
        ApexPages.StandardController sc = new ApexPages.StandardController(a);
        CallCarriersForAddyChange c = new CallCarriersForAddyChange(new ApexPages.StandardController (new Account()));
        PageReference pageRef = Page.ExecuteCallCarriersForAddyChange;
        Test.setCurrentPage(pageRef);
        ApexPages.currentPage().getParameters().put('Idx', a.Id);
        c.callCarriers();
        c.forceClose();
        test.stopTest(); 

    }
}

 
I'm braindead today and can't figure out the simplest of things.  

I have a custom object called VRNA__Policy__c.  
This object has a lookup relationship to ACCOUNT that's called VRNA__Issuing_Carrier__c.
I need to get the email address from the ACCOUNT lookup (VRNA__Issuing_Carrier__c) that's on the Policy record. 

This basic query works fine, but doesn't get the email address:
[SELECT VRNA__Issuing_Carrier__c FROM VRNA__Policy__c WHERE VRNA__Account__c =: Id AND RecordTypeID = '012f4000000giyZ']

I've tried:
[SELECT VRNA__Issuing_Carrier__c.email__c FROM VRNA__Policy__c WHERE VRNA__Account__c =: Id AND RecordTypeID = '012f4000000giyZ']

Shouldn't that work?  I'm getting an error that it doesn't understand the relationship.   
Hello.  I'm quite new to callouts.  This is my first callout that is XML repsonse and not JSON.  My callout is working fine, and I'm getting a very long resonse in the debug log.  I need to popualte two custom fields on the Lead called "Bedrooms" and "Bathrooms."  These are decimal fields.   I can see the very long XML response in the debug log but I can't figure out how to get it in APEX and popualte the lead field.  Here is my apex class, which works , but I'm not sure what to add to get the bedrooms and bathrooms decimals and put them into the fields on the lead.  I'll post the apex class and the sample resonse from the debug log. 


global class ZillowCallout{
 
  @future (callout=true) 
   public static void getFields(Id lid) {
       
   string zwsid = 'X1-ZWz188ya5jca2z_4hjdy';
    
     Lead l=[select id,Name,Street,City,State,PostalCode from Lead where id=:lid];
     string addy = l.Street;
     string citystatezip = l.City + ',' + l.State + ',' + l.PostalCode;  

     
     //Construct HTTP request and response
     //Http request method, Header, and Endpoint
     HttpRequest req = new HttpRequest();
     req.setEndpoint('http://www.zillow.com/webservice/GetDeepSearchResults.htm?zws-id=' + zwsid + '&address=' + addy + '&citystatezip=' + citystatezip);  
     req.setMethod('GET');  
     req.setHeader('Content-Type','application/json');
     req.setHeader('Authorization', 'BASIC' + 'X1-ZWz188ya5jca2z_4hjdy'); 
    
       
     //Http response method 
     Http http = new Http();
     HTTPResponse res = http.send(req);
     System.debug(res.getStatusCode());
     string responseJSON = res.getBody();
     System.debug(responseJSON);
     Dom.Document doc = res.getBodyDocument();
     Dom.XMLNode address = doc.getRootElement();
       
  
  
       
       if(res.getStatusCode() < 300) {  
      // ResponseModel r = (ResponseModel)JSON.deserialize(responseJSON, ResponseModel.class);   
         ResponseModel r = new ResponseModel(); 
           
            
            //l.responseAcceptedBody__c = 'Time: ' +system.now() +' - ' +responseJSON; 
            l.Bathrooms__c = r.Bathrooms;
            l.Bedrooms__c = r.Bedrooms;   
   
            update l;   
            
                   
       }
       
       else {
     
        //l.responseErrorBody__c = 'Time: ' +system.now() +' - ' +responseJSON;    
  
          update l;   
       }
       

   }
    

  
  //This inner class is to handle the mapping in reference to the response.
    private class ResponseModel{
        
        public Decimal Bathrooms;
        public Decimal Bedrooms;
        
        
    }
        
        
}





Here is a sample response from debug log:

09:23:56:190 USER_DEBUG [36]|DEBUG|<?xml version="1.0" encoding="utf-8"?><SearchResults:searchresults xsi:schemaLocation="http://www.zillow.com/static/xsd/SearchResults.xsd https://www.zillowstatic.com/vstatic/18f7df5/static/xsd/SearchResults.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SearchResults="http://www.zillow.com/static/xsd/SearchResults.xsd"><request><address>5536Foxrun</address><citystatezip>Cincinnati,OH,45239</citystatezip></request><message><text>Request successfully processed</text><code>0</code></message><response><results><result><zpid>34264904</zpid><links><homedetails>https://www.zillow.com/homedetails/5536-Foxrun-Ct-Cincinnati-OH-45239/34264904_zpid/</homedetails><graphsanddata>http://www.zillow.com/homedetails/5536-Foxrun-Ct-Cincinnati-OH-45239/34264904_zpid/#charts-and-data</graphsanddata><mapthishome>http://www.zillow.com/homes/34264904_zpid/</mapthishome><comparables>http://www.zillow.com/homes/comps/34264904_zpid/</comparables></links><address><street>5536 Foxrun Ct</street><zipcode>45239</zipcode><city>CINCINNATI</city><state>OH</state><latitude>39.192961</latitude><longitude>-84.57547</longitude></address><FIPScounty>39061</FIPScounty><useCode>SingleFamily</useCode><taxAssessmentYear>2017</taxAssessmentYear><taxAssessment>151220.0</taxAssessment><yearBuilt>1966</yearBuilt><lotSizeSqFt>12458</lotSizeSqFt><finishedSqFt>2912</finishedSqFt><bathrooms>3.0</bathrooms><bedrooms>4</bedrooms><totalRooms>9</totalRooms><zestimate><amount currency="USD">188146</amount><last-updated>11/18/2018</last-updated><oneWeekChange deprecated="true"></oneWeekChange><valueChange duration="30" currency="USD">1541</valueChange><valuationRange><low currency="USD">178739</low><high currency="USD">197553</high></valuationRange><percentile>0</percentile></zestimate><localRealEstate><region name="Mt. Airy" id="274620" type="neighborhood"><zindexValue>119,400</zindexValue><links><overview>http://www.zillow.com/local-info/OH-Cincinnati/Mt.-Airy/r_274620/</overview><forSaleByOwner>http://www.zillow.com/mt.-airy-cincinnati-oh/fsbo/</forSaleByOwner><forSale>http://www.zillow.com/mt.-airy-cincinnati-oh/</forSale></links></region></localRealEstate></result><result><zpid>110070415</zpid><links><homedetails>https://www.zillow.com/homedetails/5536-Foxrun-Ct-Cincinnati-OH-45239/110070415_zpid/</homedetails><graphsanddata>http://www.zillow.com/homedetails/5536-Foxrun-Ct-Cincinnati-OH-45239/110070415_zpid/#charts-and-data</graphsanddata><mapthishome>http://www.zillow.com/homes/110070415_zpid/</mapthishome><comparables>http://www.zillow.com/homes/comps/110070415_zpid/</comparables></links><address><street>5536 Foxrun Ct</street><zipcode>45239</zipcode><city>CINCINNATI</city><state>OH</state><latitude>39.192961</latitude><longitude>-84.57547</longitude></address><FIPScounty>39061</FIPScounty><useCode>SingleFamily</useCode><taxAssessmentYear>2017</taxAssessmentYear><yearBuilt>1965</yearBuilt><lotSizeSqFt>48918</lotSizeSqFt><finishedSqFt>2908</finishedSqFt><bathrooms>4.0</bathrooms><bedrooms>4</bedrooms><totalRooms>13</totalRooms><zestimate><amount currency="USD">240166</amount><last-updated>11/18/2018</last-updated><oneWeekChange deprecated="true"></oneWeekChange><valueChange duration="30" currency="USD">-997</valueChange><valuationRange><low currency="USD">194534</low><high currency="USD">293003</high></valuationRange><percentile>0</percentile></zestimate><localRealEstate><region name="Mt. Airy" id="274620" type="neighborhood"><zindexValue>119,400</zindexValue><links><overview>http://www.zillow.com/local-info/OH-Cincinnati/Mt.-Airy/r_274620/</overview><forSaleByOwner>http://www.zillow.com/mt.-airy-cincinnati-oh/fsbo/</forSaleByOwner><forSale>http://www.zillow.com/mt.-airy-cincinnati-oh/</forSale></links></region></localRealEstate></result></results></response></SearchResults:searchresults><!-- H:027  T:88ms  S:2041  R:Sat Nov 24 09:23:57 PST 2018  B:5.0.57261.8-hotfix_2018-11-13.68abad3~hotfix-for-2018-11-13.bfcf05d -->



 
I'm trying to display a google street view of the Address located on Account and/or custom address on Oppty.  I've found lots of visualforce mock up that displays a map, but none for street view.  I've tried inserting javascript snippits into the visualforce page to call street view, but I must be doing it wrong.  Does anyone have this already?  Can anyone help me understand what I need to do or take a crack at it?   Thanks soooooo much!
Hello All!!  I need some guidence with a trigger or class.  I'm new to developing in general so I was hoping that some of the fantastic experts here could help me out.  Here's the deal:

I have a custom object called 'SIC Codes' that has a code as the Name and 4 fields that are simply a 'yes' or 'no' text field.  So a record would look like this:

Name: 1234
Description__c = 'doctors'
WC__c = yes
BOP__c no
GA__c = yes
GL__c = no

Now, on the Lead record I have a description text field that will match a SIC CODE record's description.  So a lead may will have a description field that will say 'doctors'.    The lead also has 4 text fields that match the fields above on the custom object's record.   

What I am trying to do is say "If a lead comes in with a description that matches a description on the custom object, copy the values of the 4 custom fields to the lead record with those same custom fields.  The result would be that the lead's field values for WC__c, BOP__c, ect... will match the 'yes' or 'no' from the record on the custom object that matches that description.  

Now, i have a lead handler where I will put this trigger and call a class that will do all the work.  I'm kind of overwhelmed and don't know how to get started.  Any adivce or guidence would be increcible!  

Thanks so much!

 
Hello Everyone!  I think I'm going to need some custom coding or something here.  I have an issue with Chatter visibility. 

Our OWD on Accounts is Public Read/Write and has to stay that way.  We have several record types.  I'm having an issue with people from the sales floor seeing Chatter posts when they are initiated from an Account record and are related to that record.  I don't want my salesfloor to see them.  The profile for Sales does not have access to those record types, however, they can still see the posts becuase they have access to the Account object.  They have to have access.  

How can I get Sales Profile users to not see Chatter posts that are on Accounts of a certain record type?

Any ideas?

George
Hello!

I've installed the app from Salesforce Labs called "Lead Capture" and when I try to test using the testing tool, i get 102 Server Failure.  I can't find any support and Salesforce themselves won't help out either.  Anyone know what's going on here?
Hello.  I'm very new to apex and programming in general.  I have to deploy this class tonight or tomorrow.  My apex works perfectly but I'm stuck and can't get code coverage for some reason.  Here are the facts:

1. I am using a visualforce page called from a button on the Account page.  

2. In my class I"m getting the Id of the Account from the VF page that the button was pressed from. 

3. Code works great however, when I call the method callCarriers() from the test class, it doesn't have the ID from the button pressed on the Account page of course.  That's the problem.  I tried all sorts of pageref stuff to try and pass the Account ID of the newly created account in the test class but it wont' work. 

4.  I'm BRAND new to coding so my code is very sloppy.  Also I have a lot of things in there that probably don't need to be there, but I'm just trying everything.   Please someone help!


VISUALFORCE PAGE

<apex:page standardController="Account" extensions="CallCarriersForAddyChange"> <apex:form > <apex:commandButton value="Warning: You are about to send an email to carriers! Click here if you are totally sure you want to do this." onclick="javascript&colon;window.alert('Do you want to proceed?');" action="{!callCarriers}"/> <br/> <apex:commandButton value="Ooops, get me out of here!" action="{!forceClose}"/> <apex:inputHidden value="{!Account.OwnerId}"/> </apex:form> </apex:page>



APEX CLASS:

public class CallCarriersForAddyChange {
    //Apex properties or variables

    public Id Id { get; set; }
    public Account act { get; set; }

    //constructor to get the Account record
    public CallCarriersForAddyChange(ApexPages.StandardController controller) {
    act =  (Account) controller.getRecord();
    Id = act.Id;
    System.debug('The Account record: ' + act);
    
    }

    //Method that can is called from the Visual Force page action attribute

    public PageReference callCarriers() {
        
        System.debug('Account Id: ' + Id);
        //build your code logic here
        
        string email;
        List<VRNA__Policy__c> carriers = [SELECT         VRNA__Issuing_Carrier__r.VRNA__Email__c, 
                                          VRNA__First_Named_Insured__c,
                                          VRNA__Policy_Number__c,
                                          VRNA__Issuing_Carrier__r.Name, 
                                          VRNA__Account__r.BillingStreet,
                                          VRNA__Account__r.BillingCity,
                                          VRNA__Account__r.BillingState,
                                          VRNA__Account__r.BillingPostalCode
                                          FROM VRNA__Policy__c 
                                          WHERE VRNA__Account__c =: Id AND RecordTypeID = '012f4000000giyZ'];
     
  List<string> emails = new List<string>();
        system.debug('Carriers: '+carriers);
        
            for(VRNA__Policy__c a : carriers){
            email = a.VRNA__Issuing_Carrier__r.VRNA__Email__c;
               emails.add(email);  
            system.debug('Email List' +emails);
    
        }
        
        for(VRNA__Policy__c p : carriers){
           
          @TestVisible Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
            // Strings to hold the email addresses to which you are sending the email.
            String[] toAddresses = new String[] {p.VRNA__Issuing_Carrier__r.VRNA__Email__c};
            // Assign the addresses for the To and CC lists to the mail object.
            mail.setToAddresses(toAddresses);    
            // Specify the address used when the recipients reply to the email.
            mail.setReplyTo('service@amventure.com');
            // Specify the name used as the display name.
            mail.setSenderDisplayName('Amventure Customer Service');
            // Specify the subject line for your email address.
            mail.setSubject('Policy Mailing Address Change');
            // Set the object Id for merging fields into the template
            //mail.setTargetObjectId(p.Id);
            // The email template ID used for the email
            //mail.setTemplateId('00XM0000000N7NU');
            // Specify the text content of the email.
            mail.setHtmlBody('To Whom It May Concern:<p>' + 'A change to a policy mailing address been requested effective today.<p>' + 'Name Insured: '+p.VRNA__First_Named_Insured__c + '<br/>Policy Number: '+p.VRNA__Policy_Number__c + '<br/>Carrier Name: '+p.VRNA__Issuing_Carrier__r.Name + '<p><b>New Address</b>' +'<br/>Street: '+p.VRNA__Account__r.BillingStreet +'<br/>City: '+p.VRNA__Account__r.BillingCity +'<br/>State: '+p.VRNA__Account__r.BillingState + '<br/>Zip: '+p.VRNA__Account__r.BillingPostalCode);
            // Send the email you have created.
            Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
          
        }

        PageReference pageRef = new PageReference('/'+Id);
        pageRef.setRedirect(true);
        return pageRef; //Returns to the case page
    }
    
     public PageReference forceClose(){
     PageReference page  = page.ForceClose; 
     return page;
     }

TEST CLASS:

@istest(SeeAllData=true)

public class CallCarriersForAddyChangeTest {

    public static testmethod void CallCarriersForAddyChangeTest(){
        
        //create an account
        Account a = new Account(
        Name = 'Test Account',
        BillingStreet='123 main',
        BillingState='Ohio',
        BillingPostalCode='12345',
        RecordTypeId = '012f4000000giww',    
        VRNA__Issuing_Carrier__c = true,
        VRNA__Billing_Company__c = true);
        insert a;
        system.debug('Test Account Id: '+a.Id);
        
        VRNA__Policy__c p = new VRNA__Policy__c(
        Completed_Post_Sale_Checklist__c = 'true',
        VRNA__First_Named_Insured__c = 'tom tomerson',    
        VRNA__Policy_Type__c = 'Crime',
        VRNA__Status__c = 'Written (Sold)',
        VRNA__Account__c = a.Id,
        VRNA__Policy_Number__c = '111111',
        VRNA__Effective_Date__c = Date.today(),
        VRNA__Agency__c = 'AmVenture Insurance Agency, Inc',
        VRNA__Branch__c = 'AmVenture Insurance Agency, Inc',
        VRNA__Department__c = 'Commercial',
        VRNA__Issuing_Carrier__c = a.Id,
        VRNA__Billing_Company__c = a.Id,
        VRNA__Date_First_Written__c = Date.today(),
        VRNA__Policy_Issuing_State_picklist__c = 'OH',
        VRNA__Package_Type__c = 'Monoline',
        VRNA__Primary_Producer__c = '005f4000000yGSY',   
        RecordTypeId = '012f4000000giyZ');
        insert p;
        
        test.startTest(); 
        
        ApexPages.StandardController sc = new ApexPages.StandardController(a);
        CallCarriersForAddyChange c = new CallCarriersForAddyChange(new ApexPages.StandardController (new Account()));
        PageReference pageRef = Page.ExecuteCallCarriersForAddyChange;
        Test.setCurrentPage(pageRef);
        ApexPages.currentPage().getParameters().put('Idx', a.Id);
        c.callCarriers();
        c.forceClose();
        test.stopTest(); 

    }
}

 
I'm braindead today and can't figure out the simplest of things.  

I have a custom object called VRNA__Policy__c.  
This object has a lookup relationship to ACCOUNT that's called VRNA__Issuing_Carrier__c.
I need to get the email address from the ACCOUNT lookup (VRNA__Issuing_Carrier__c) that's on the Policy record. 

This basic query works fine, but doesn't get the email address:
[SELECT VRNA__Issuing_Carrier__c FROM VRNA__Policy__c WHERE VRNA__Account__c =: Id AND RecordTypeID = '012f4000000giyZ']

I've tried:
[SELECT VRNA__Issuing_Carrier__c.email__c FROM VRNA__Policy__c WHERE VRNA__Account__c =: Id AND RecordTypeID = '012f4000000giyZ']

Shouldn't that work?  I'm getting an error that it doesn't understand the relationship.   
Hello.  I'm quite new to callouts.  This is my first callout that is XML repsonse and not JSON.  My callout is working fine, and I'm getting a very long resonse in the debug log.  I need to popualte two custom fields on the Lead called "Bedrooms" and "Bathrooms."  These are decimal fields.   I can see the very long XML response in the debug log but I can't figure out how to get it in APEX and popualte the lead field.  Here is my apex class, which works , but I'm not sure what to add to get the bedrooms and bathrooms decimals and put them into the fields on the lead.  I'll post the apex class and the sample resonse from the debug log. 


global class ZillowCallout{
 
  @future (callout=true) 
   public static void getFields(Id lid) {
       
   string zwsid = 'X1-ZWz188ya5jca2z_4hjdy';
    
     Lead l=[select id,Name,Street,City,State,PostalCode from Lead where id=:lid];
     string addy = l.Street;
     string citystatezip = l.City + ',' + l.State + ',' + l.PostalCode;  

     
     //Construct HTTP request and response
     //Http request method, Header, and Endpoint
     HttpRequest req = new HttpRequest();
     req.setEndpoint('http://www.zillow.com/webservice/GetDeepSearchResults.htm?zws-id=' + zwsid + '&address=' + addy + '&citystatezip=' + citystatezip);  
     req.setMethod('GET');  
     req.setHeader('Content-Type','application/json');
     req.setHeader('Authorization', 'BASIC' + 'X1-ZWz188ya5jca2z_4hjdy'); 
    
       
     //Http response method 
     Http http = new Http();
     HTTPResponse res = http.send(req);
     System.debug(res.getStatusCode());
     string responseJSON = res.getBody();
     System.debug(responseJSON);
     Dom.Document doc = res.getBodyDocument();
     Dom.XMLNode address = doc.getRootElement();
       
  
  
       
       if(res.getStatusCode() < 300) {  
      // ResponseModel r = (ResponseModel)JSON.deserialize(responseJSON, ResponseModel.class);   
         ResponseModel r = new ResponseModel(); 
           
            
            //l.responseAcceptedBody__c = 'Time: ' +system.now() +' - ' +responseJSON; 
            l.Bathrooms__c = r.Bathrooms;
            l.Bedrooms__c = r.Bedrooms;   
   
            update l;   
            
                   
       }
       
       else {
     
        //l.responseErrorBody__c = 'Time: ' +system.now() +' - ' +responseJSON;    
  
          update l;   
       }
       

   }
    

  
  //This inner class is to handle the mapping in reference to the response.
    private class ResponseModel{
        
        public Decimal Bathrooms;
        public Decimal Bedrooms;
        
        
    }
        
        
}





Here is a sample response from debug log:

09:23:56:190 USER_DEBUG [36]|DEBUG|<?xml version="1.0" encoding="utf-8"?><SearchResults:searchresults xsi:schemaLocation="http://www.zillow.com/static/xsd/SearchResults.xsd https://www.zillowstatic.com/vstatic/18f7df5/static/xsd/SearchResults.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SearchResults="http://www.zillow.com/static/xsd/SearchResults.xsd"><request><address>5536Foxrun</address><citystatezip>Cincinnati,OH,45239</citystatezip></request><message><text>Request successfully processed</text><code>0</code></message><response><results><result><zpid>34264904</zpid><links><homedetails>https://www.zillow.com/homedetails/5536-Foxrun-Ct-Cincinnati-OH-45239/34264904_zpid/</homedetails><graphsanddata>http://www.zillow.com/homedetails/5536-Foxrun-Ct-Cincinnati-OH-45239/34264904_zpid/#charts-and-data</graphsanddata><mapthishome>http://www.zillow.com/homes/34264904_zpid/</mapthishome><comparables>http://www.zillow.com/homes/comps/34264904_zpid/</comparables></links><address><street>5536 Foxrun Ct</street><zipcode>45239</zipcode><city>CINCINNATI</city><state>OH</state><latitude>39.192961</latitude><longitude>-84.57547</longitude></address><FIPScounty>39061</FIPScounty><useCode>SingleFamily</useCode><taxAssessmentYear>2017</taxAssessmentYear><taxAssessment>151220.0</taxAssessment><yearBuilt>1966</yearBuilt><lotSizeSqFt>12458</lotSizeSqFt><finishedSqFt>2912</finishedSqFt><bathrooms>3.0</bathrooms><bedrooms>4</bedrooms><totalRooms>9</totalRooms><zestimate><amount currency="USD">188146</amount><last-updated>11/18/2018</last-updated><oneWeekChange deprecated="true"></oneWeekChange><valueChange duration="30" currency="USD">1541</valueChange><valuationRange><low currency="USD">178739</low><high currency="USD">197553</high></valuationRange><percentile>0</percentile></zestimate><localRealEstate><region name="Mt. Airy" id="274620" type="neighborhood"><zindexValue>119,400</zindexValue><links><overview>http://www.zillow.com/local-info/OH-Cincinnati/Mt.-Airy/r_274620/</overview><forSaleByOwner>http://www.zillow.com/mt.-airy-cincinnati-oh/fsbo/</forSaleByOwner><forSale>http://www.zillow.com/mt.-airy-cincinnati-oh/</forSale></links></region></localRealEstate></result><result><zpid>110070415</zpid><links><homedetails>https://www.zillow.com/homedetails/5536-Foxrun-Ct-Cincinnati-OH-45239/110070415_zpid/</homedetails><graphsanddata>http://www.zillow.com/homedetails/5536-Foxrun-Ct-Cincinnati-OH-45239/110070415_zpid/#charts-and-data</graphsanddata><mapthishome>http://www.zillow.com/homes/110070415_zpid/</mapthishome><comparables>http://www.zillow.com/homes/comps/110070415_zpid/</comparables></links><address><street>5536 Foxrun Ct</street><zipcode>45239</zipcode><city>CINCINNATI</city><state>OH</state><latitude>39.192961</latitude><longitude>-84.57547</longitude></address><FIPScounty>39061</FIPScounty><useCode>SingleFamily</useCode><taxAssessmentYear>2017</taxAssessmentYear><yearBuilt>1965</yearBuilt><lotSizeSqFt>48918</lotSizeSqFt><finishedSqFt>2908</finishedSqFt><bathrooms>4.0</bathrooms><bedrooms>4</bedrooms><totalRooms>13</totalRooms><zestimate><amount currency="USD">240166</amount><last-updated>11/18/2018</last-updated><oneWeekChange deprecated="true"></oneWeekChange><valueChange duration="30" currency="USD">-997</valueChange><valuationRange><low currency="USD">194534</low><high currency="USD">293003</high></valuationRange><percentile>0</percentile></zestimate><localRealEstate><region name="Mt. Airy" id="274620" type="neighborhood"><zindexValue>119,400</zindexValue><links><overview>http://www.zillow.com/local-info/OH-Cincinnati/Mt.-Airy/r_274620/</overview><forSaleByOwner>http://www.zillow.com/mt.-airy-cincinnati-oh/fsbo/</forSaleByOwner><forSale>http://www.zillow.com/mt.-airy-cincinnati-oh/</forSale></links></region></localRealEstate></result></results></response></SearchResults:searchresults><!-- H:027  T:88ms  S:2041  R:Sat Nov 24 09:23:57 PST 2018  B:5.0.57261.8-hotfix_2018-11-13.68abad3~hotfix-for-2018-11-13.bfcf05d -->



 
Hello All!!  I need some guidence with a trigger or class.  I'm new to developing in general so I was hoping that some of the fantastic experts here could help me out.  Here's the deal:

I have a custom object called 'SIC Codes' that has a code as the Name and 4 fields that are simply a 'yes' or 'no' text field.  So a record would look like this:

Name: 1234
Description__c = 'doctors'
WC__c = yes
BOP__c no
GA__c = yes
GL__c = no

Now, on the Lead record I have a description text field that will match a SIC CODE record's description.  So a lead may will have a description field that will say 'doctors'.    The lead also has 4 text fields that match the fields above on the custom object's record.   

What I am trying to do is say "If a lead comes in with a description that matches a description on the custom object, copy the values of the 4 custom fields to the lead record with those same custom fields.  The result would be that the lead's field values for WC__c, BOP__c, ect... will match the 'yes' or 'no' from the record on the custom object that matches that description.  

Now, i have a lead handler where I will put this trigger and call a class that will do all the work.  I'm kind of overwhelmed and don't know how to get started.  Any adivce or guidence would be increcible!  

Thanks so much!