ZoomInfo Forums

Development Questions

RSS Feed

access street from Company Search

    • Dman100
    • Topic created 4 months ago

    The output parameters for the company search show the street address, but when I test in salesforce, I get an error "attempt to de-reference a null object"

    Here is the code I'm using:

    global class ZoomInfoController
    {
    public ZoomInfoController()
    {
    }

    @future (callout=true)
    public static void ZoomInfoUpdate(Id leadID)
    {
    Lead newLead = new Lead();

    try
    {
    newLead = [select l.hubspot__IP_Zip_Code__c, l.hubspot__IP_Region__c, l.hubspot__IP_Location__c, l.hubspot__IP_ISP__c, l.hubspot__IP_Domain__c, l.hubspot__IP_Country__c, l.hubspot__IP_City__c, l.hubspot__IP_Address__c, l.hubspot__Found_Site_Via__c, l.hubspot__First_Visit__c, l.hubspot__First_Conversion_Date__c, l.hubspot__Conversion_Events__c, l.hubspot__Conversion_Event__c, l.hubspot__Average_Page_Views__c, l.ZOOM__ZI_Person__c, l.ZOOM__ZI_Person2__c, l.ZOOM__ZI_ImportedDate__c, l.ZOOM__ZI_Company__c, l.ZOOM__ZI_Company2__c, l.Working_with_Phone_System_Reseller__c, l.Widget_URL__c, l.Widget_Partner_ID__c, l.Website, l.WIdget_Rep_ID__c, l.Voice_Service_Type__c, l.Voice_Name_of_Provider__c, l.Voice_Months_left_on_contract__c, l.Voice_Current_Spend__c, l.Voice_Current_LD_Spend__c, l.Voice_Comments__c, l.Voice_Capture_Date__c, l.VoiceServicesDetails__c, l.VoIP_Access_Future_CB_Date__c, l.VAR_Name__c, l.Type_of_Internet_Service__c, l.Type_of_Data_Service__c, l.Total_of_employees_at_this_location__c, l.Total_of_employees__c, l.Total_T3_lines__c, l.Total_T1_lines__c, l.Total_Data_Lines__c, l.Title, l.Timeframe_for_Change_Voice_months__c, l.TimeframeDays__c, l.TM__c, l.SystemModstamp, l.Street, l.Status, l.State, l.SiteSection__c, l.Service_Tyoe__c, l.Salutation, l.SIC_Code__c, l.SFGA__Web_Source__c, l.SFGA__Correlation_Data__c, l.SFGA__CorrelationID__c, l.Round_Robin_ID__c, l.Request_Local_VAR_Information__c, l.Rep_Region__c, l.Referrer__c, l.RecordTypeId, l.Reasons__c, l.Rating, l.Purchasing_New_Phone_System__c, l.Projected_Seat_Trunk_Lines__c, l.ProductInterest__c, l.PostalCode, l.Phone, l.Partner_ZIP__c, l.Partner_Comments__c, l.PartnerName__c, l.PageViewsBeforeLead__c, l.OwnerId, l.Owned_By_Marketing__c, l.Owned_By_Channel__c, l.Other__c, l.Original_BW_URL__c, l.Number_of_Locations__c, l.NumberOfEmployees, l.Not_Applicable_Describe_Reason__c, l.New_Offices_Opening__c, l.Need_IP_PBX__c, l.NeedInterofficeConnectivity__c, l.Name_of_Internet_Provider__c, l.Name_of_Data_Provider__c, l.Name, l.Motivation__c, l.MobilePhone, l.Max_Data_Line_Speed__c, l.MasterRecordId, l.Marketing_Lead__c, l.LinkedIn_ID__c, l.Lead_s_Title__c, l.Lead_Source_To_Account__c, l.Lead_Source_Details__c, l.Lead_Sequence_ID__c, l.Lead_Sent_to_VAR__c, l.Lead_Role__c, l.Lead_Created_Date_Calc__c, l.LeadSource, l.LastName, l.LastModifiedDate, l.LastModifiedById, l.LastActivityDate, l.IsUnreadByOwner, l.IsDeleted, l.IsConverted, l.InterofficeConnectivityDetails__c, l.Internet_Access_Service_Type__c, l.Internet_Access_Not_Applicable__c, l.Internet_Access_Name_of_Provider__c, l.Internet_Access_Months_left_on_contract__c, l.Internet_Access_Future_CB_Date__c, l.Internet_Access_Current_Spend__c, l.Internet_Access_Comments__c, l.Internet_Access_Capture_Date__c, l.Install_Timeframe__c, l.Inquiry_for_Service__c, l.Industry_Comments__c, l.Industry, l.Id, l.How_you_find_out_about_us__c, l.HasOptedOutOfEmail, l.Future_Voice_Plans__c, l.Future_Call_Back__c, l.FirstName, l.Fax, l.External_Reference_ID__c, l.ExternalRepPhone__c, l.ExternalRepName__c, l.ExternalRepID__c, l.ExternalRepEmail__c, l.Email_Bounce_Back__c, l.EmailBouncedReason, l.EmailBouncedDate, l.Email, l.Description, l.Department__c, l.Data_Service_Type__c, l.Data_Name_of_Provider__c, l.Data_Months_Left_On_Contract__c, l.Data_Current_Spend__c, l.Data_Comments__c, l.Data_Capture_Date__c, l.Current_Spending__c, l.CurrentTelecomSolution__c, l.CreatedDate, l.CreatedById, l.Country, l.ConvertedOpportunityId, l.ConvertedDate, l.ConvertedContactId, l.ConvertedAccountId, l.Company, l.Comments_on_Industry__c, l.City, l.Authority__c, l.Annual_Revenue__c, l.AnnualRevenue From Lead l where l.Id = :leadID];

    Http h = new Http();
    HttpRequest req = new HttpRequest();
    req.setEndpoint('http://api.zoominfo.com/PartnerAPI/XmlOutput.aspx?query_type=company_search_query&pc=b24r8tu6jr3r7p6d8eeh9pa2&companyName=' + newLead.Company);
    req.setMethod('GET');

    // Send the request, and return a response
    HttpResponse res = h.send(req);
    String xml = res.getBody();
    ZoomInfoCompany zoom = new ZoomInfoCompany(xml);

    if(zoom.isEmpty == false)
    {
    newLead.Partner_Comments__c = 'Got ZoomInfo data!';
    if (newLead.ZOOM__ZI_Company__c == null)
    {
    newLead.ZOOM__ZI_Company__c = zoom.CompanyID;
    }
    if (newLead.Street == null)
    {
    newLead.Street = zoom.street;
    }
    if (newLead.City == null)
    {
    newLead.City = zoom.city;
    }
    if (newLead.State == null)
    {
    newLead.State = zoom.state;
    }
    if (newLead.PostalCode == null)
    {
    newLead.PostalCode = zoom.postalCode;
    }
    if (newLead.Country == null)
    {
    newLead.Country = zoom.country;
    }
    if (newLead.Website == null)
    {
    newLead.Website = zoom.website;
    }
    }
    else
    {
    newLead.Partner_Comments__c = 'ZoomInfo called. More than 1 or 0 records returned for this company.';
    }

    update newLead;
    }
    catch(Exception e)
    {
    newLead.Partner_Comments__c = e.GetMessage();
    update newLead;
    }
    }

    public class ZoomInfoCompany
    {
    private string id;
    private String name;
    private String web;
    private String tick;
    private String strt;
    private String cty;
    private String st;
    private String ctry;
    private String postCode;
    private String res;
    private Boolean isEmpt = true;

    public String CompanyID {get {return id;} set {id = value;}}
    public String companyName {get {return name;} set {name = value;}}
    public String website {get {return web;} set {web = value;}}
    public String ticker{get {return tick;} set {tick = value;}}
    public String street{get {return strt;} set {strt = value;}}
    public String city {get {return cty;} set {cty = value;}}
    public String state {get {return st;} set {st = value;}}
    public String country {get {return ctry;} set {ctry = value;}}
    public String postalCode {get {return postCode;} set {postCode = value;}}
    private String results;
    public Boolean isEmpty {get {return isEmpt;} set {isEmpt = value;}}


    public ZoomInfoCompany(String stringXML)
    {
    if(stringXML != '')
    {
    //use XML Dom object to assign vals
    XMLDom zoomXML = new XMLDom(stringXML);

    String results = ((XMLDom.Element)zoomXML.getElementByTagName('TotalResults')).nodeValue;

    if(results == '1')
    {
    isEmpt = false;

    //data node
    XMLDom.Element compDataXML = (XMLDom.Element)zoomXML.getElementByTagName('CompanyRecord');
    web = ((XMLDom.Element)compDataXML.getElementByTagName('Website')).nodeValue;
    tick = ((XMLDom.Element)compDataXML.getElementByTagName('CompanyTicker')).nodeValue;
    name= ((XMLDom.Element)compDataXML.getElementByTagName('CompanyName')).nodeValue;
    id = ((XMLDom.Element)compDataXML.getElementByTagName('CompanyID')).nodeValue;

    //address node
    XMLDom.Element addrDataXML = (XMLDom.Element)zoomXML.getElementByTagName('CompanyAddress');
    strt = ((XMLDom.Element)addrDataXML.getElementByTagName('Street')).nodeValue;
    cty = ((XMLDom.Element)addrDataXML.getElementByTagName('City')).nodeValue;
    st = ((XMLDom.Element)addrDataXML.getElementByTagName('State')).nodeValue;
    ctry = ((XMLDom.Element)addrDataXML.getElementByTagName('CountryCode')).nodeValue;
    }
    else if (results == '0')
    {
    isEmpt = true;
    }
    else
    {
    isEmpt = true;
    }
    }
    }
    }
    }

    The error occurs on this line:

    strt = ((XMLDom.Element)addrDataXML.getElementByTagName('Street')).nodeValue;

    Thanks for any help.

  1. ZoomInfo Admin3 months ago

    Unfortunately we would not be able to help with this integration into Salesforce. We can only provide the data and as you mentioned the detail you need is available in the output.

    We also already do have an integration available with Salesforce -

    http://sites.force.com/appexchange/listingDetail?listingId=a0330000005A9KMAA0

    Thank you