You need to sign in to do that
Don't have an account?
Baz Denson
I am using the Apex for Xero package from Ben Edwards on GitHub and I am trying to populate a Xero contact record with a Xero Address (which is a nested list) and I'm getting FATAL_ERROR System.NullPointerException: Attempt to de-reference a null object.
Looking at other questions on this subject it seems to relate to not initialising things, but I believe I am initialising everything.
Does anyone have any pointers for me?
Thanks
Barry
Apex to Xero
I am using the Apex for Xero package from Ben Edwards on GitHub and I am trying to populate a Xero contact record with a Xero Address (which is a nested list) and I'm getting FATAL_ERROR System.NullPointerException: Attempt to de-reference a null object.
Looking at other questions on this subject it seems to relate to not initialising things, but I believe I am initialising everything.
Does anyone have any pointers for me?
Thanks
Barry
global class SFtoXero { /* XeroContact Structure * <Contacts> <Contact> <ContactID>bd2270c3-8706-4c11-9cfb-000b551c3f51</ContactID> <ContactStatus>ACTIVE</ContactStatus> <Name>ABC Limited</Name> <FirstName>Andrea</FirstName> <LastName>Dutchess</LastName> <EmailAddress>a.dutchess@abclimited.com</EmailAddress> <SkypeUserName>skype.dutchess@abclimited.com</SkypeUserName> <BankAccountDetails>45465844</BankAccountDetails> <TaxNumber>415465456454</TaxNumber> <AccountsReceivableTaxType>INPUT2</AccountsReceivableTaxType> <AccountsPayableTaxType>OUTPUT2</AccountsPayableTaxType> <Addresses> <Address> <AddressType>POBOX</AddressType> <AddressLine1>P O Box 123</AddressLine1> <City>Wellington</City> <PostalCode>6011</PostalCode> <AttentionTo>Andrea</AttentionTo> </Address> <Address> <AddressType>STREET</AddressType> </Address> </Addresses> <Phones> <Phone> <PhoneType>DEFAULT</PhoneType> <PhoneNumber>1111111</PhoneNumber> <PhoneAreaCode>04</PhoneAreaCode> <PhoneCountryCode>64</PhoneCountryCode> </Phone> <Phone> <PhoneType>FAX</PhoneType> </Phone> <Phone> <PhoneType>MOBILE</PhoneType> </Phone> <Phone> <PhoneType>DDI</PhoneType> </Phone> </Phones> <UpdatedDateUTC>2009-05-14T01:44:26.747</UpdatedDateUTC> <IsSupplier>false</IsSupplier> <IsCustomer>true</IsCustomer> <DefaultCurrency>NZD</DefaultCurrency> </Contact> </Contacts> */ global class contactRecord { @invocableVariable global string PracticeName; @invocableVariable global string PartnerFirstName; @invocableVariable global string PartnerLastName; @invocableVariable global string EmailAddress; @invocableVariable global string AddressLine1; @invocableVariable global string City; @invocableVariable global string PostalCode; @invocableVariable global string AccountID; } @InvocableMethod(label='Create a Contact In Xero' description='Creates a Xero Contact Record') global static void createContact(List<contactRecord> XeroContacts) { for(contactRecord c: XeroContacts) { calloutMethod(c.PracticeName, c.PartnerFirstName, c.PartnerLastName, c.emailAddress, c.city, c.AccountID); } } @future(callout=true) public static void calloutmethod( string practiceName, string partnerFirstname, string partnerLastname, string emailAddress, string City, String AccountID){ // Create a Contact // XeroAddress addr = new XeroAddress(); addr.AddressType ='x'; addr.AddressLine1 = 'x'; addr.AddressLine2 ='x'; addr.AddressLine3 = 'x'; addr.AddressLine4 = 'x'; addr.City = City; addr.Region = 'x'; addr.PostalCode = 'x'; addr.Country = 'x'; addr.AttentionTo = 'x'; XeroContact newContact = new XeroContact(); newContact.Name = practiceName; newContact.FirstName = partnerFirstname; newContact.LastName = partnerLastname; newContact.EmailAddress = emailAddress; newContact.Addresses.add(addr); // Send Contact to Xero try { XeroContact createdContact=XeroAccountingApi.createContact(XeroXmlUtility.serialize(newContact, 'Contact')); system.debug('Created Contact ID: '+createdContact.ContactID); Xero_contact__c XeroContactinSF = new Xero_Contact__c(); XeroContactinSF.Xero_Contact_ID__c = createdContact.ContactID; XeroContactinSF.Name = createdContact.Name; XeroContactinSF.Account__c = AccountID; insert XeroContactinSF; } catch (Exception ex){ system.debug(ex); } } }
Baz Denson
I should have said, the error relates to line 108.