function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
jadenjaden 

Person Accounts - Web Service call

we have a method calling an external webservice passing account and contact information. The call was working and then the user turned on Person Accounts and it is no longer working.

 

Any suggestions, greatly appreciated.

Best Answer chosen by Admin (Salesforce Developers) 
jadenjaden

I was away at the time an unable to see them.

 

I checked today and no account ID's where being passed to the class with the web service call.  It turns out that there was a filter in the filter i the trigger stopping the accounts that had been mass loaded which for now where the only ones there.  This was to prevent a flood of API calls for the Web Service during the load.

 

I removed the filter and it is once again working .

Thanks for your time; it is appreciated.

All Answers

dkadordkador

What error are you getting?

jadenjaden

I am not getting an error but no data is now being to the web service and it was.

 

Here is the code:

public class ABSCalloutClass  {

    public static void CallABSWS(Set<Id> idsn){
        list <Account> acctRecs;
        string AccttoUpdateID;
        string ConFirstName;
        string ConLastName;
        string ConEmail;
        string AcctOwner;
        string calltype;
        
        //JJB Test Account is '001M0000005lGhI'
        
         //Creating a List from a SOQL query using idsn
          acctRecs  = [SELECT acc.Id, acc.ownerid FROM Account acc WHERE acc.ID in :Idsn];
            
        if (acctRecs.size() == 0)
            return;  
            
        list<id> owner_ids = new List<id>();
        For(Account a: acctRecs)
        {
            Owner_ids.add(a.OwnerID);
        } 
        Map<id,User> owners = new Map<id,User>([SELECT ID, Name from User WHERE id in :owner_ids]);
         
        list <AccountContactRole> Contacts = 
            [SELECT id, contactId, role, contact.ID, contact.AccountID, contact.FirstName, contact.LastName, contact.Email
             from AccountContactRole  
             Where contact.Accountid in :idsn and contact.Primary_Contact__c = :true and (role = 'Billing' or role = 'Accounting' or role = 'Primary')]; 
        
        //iterate thru the ids  
        for (Account Acct: acctRecs) {  
            AccttoUpdateID = Acct.Id;
            If(owners.containskey(Acct.Ownerid))
                AcctOwner=owners.get(Acct.Ownerid).Name;
                
            for (AccountContactRole con: Contacts) { 
                if (con.contact.AccountID == AccttoUpdateID) {
                    ConFirstName = Con.contact.Firstname;
                    ConLastName = Con.contact.Lastname;
                    ConEmail = Con.contact.Email;
                }
            }
            //If(trigger.isUpdate)
            If(trigger.isInsert)
            	calltype = 'insert';
            	
            CallUpdateInvokeWebService(AccttoUpdateID, ConFirstName, ConLastName, ConEmail, AcctOwner, calltype); 
        }
    }  
    @future(callout=true)     
    public static void CallUpdateInvokeWebService(String AccttoUpdateID, String ConFirstName, String ConLastName, String ConEmail, string AcctOwner, string calltype) {
        Account AccttoUpdate;
        
         // Need to add other fields once resolved.
        AccttoUpdate = [SELECT acc.Id, acc.Name, acc.AccountNumber, acc.EDR_Password__c, acc.Industry, acc.Phone, acc.Fax,
                        acc.Ownerid, acc.ShippingStreet,acc.Shippingcity, acc.ShippingState, acc.ShippingCountry, acc.ShippingPostalCode,
                        acc.BillingStreet,acc.BillingCity, acc.BillingState, acc.BillingCountry, acc.BillingPostalCode
                        FROM Account acc  
                        WHERE acc.ID = :AccttoUpdateID];
    
            //Create Instance of service call 
            wsEdrnetComEnterpriseservicesAbsdata.APIExistingCustomer edrCustomer = new
            wsEdrnetComEnterpriseservicesAbsdata.APIExistingCustomer();
            
            wsEdrnetComEnterpriseservicesAbsdata.APINewCustomer edrNewCustomer = new
            wsEdrnetComEnterpriseservicesAbsdata.APINewCustomer();
            
            wsEdrnetComEnterpriseservicesAbsdata.APIResponse edrAPIResponse = new
            wsEdrnetComEnterpriseservicesAbsdata.APIResponse();
            
             //Setup to Split SF Billing Street into 2 fields
            List<string> billing_address_parts = new List<String>();
            if(AccttoUpdate.BillingStreet != null)
            	billing_Address_parts=AccttoUpdate.BillingStreet.split('\n');

             //Setup to Split SF Shipping Street into 2 fields
            List<string> Shipping_address_parts = new List<String>();
            if(AccttoUpdate.ShippingStreet != null)
            	Shipping_Address_parts=AccttoUpdate.ShippingStreet.split('\n');

            edrNewCustomer.CompanyName = AccttoUpdate.Name;  
            edrNewCustomer.ContactFirstName=ConFirstName;
            edrNewCustomer.ContactLastName = ConLastName;
            If(billing_address_parts.size()>=1)
              edrNewCustomer.BillingAddress1=billing_address_parts[0];
            edrNewCustomer.BillingCity = AccttoUpdate.BillingCity;
            edrNewCustomer.BillingState = AccttoUpdate.BillingState;
            edrNewCustomer.BillingZipCode = AccttoUpdate.BillingPostalCode;
            edrNewCustomer.BillingCountry = AccttoUpdate.BillingCountry;

            If(shipping_address_parts.size()>=1)
              edrNewCustomer.ShippingAddress1=shipping_address_parts[0];
            edrNewCustomer.ShippingCity = AccttoUpdate.shippingCity;
            edrNewCustomer.ShippingState = AccttoUpdate.shippingState;
            edrNewCustomer.ShippingZipCode = AccttoUpdate.shippingPostalCode;
            edrNewCustomer.ShippingCountry = AccttoUpdate.shippingCountry;

            edrNewCustomer.Phone = AccttoUpdate.Phone;
            edrNewCustomer.Industry = AccttoUpdate.Industry;
            
            edrCustomer.AccountNumber = AccttoUpdate.AccountNumber;
            edrCustomer.Password=AccttoUpdate.EDR_Password__c; 
            edrCustomer.Email = ConEmail;
            If(billing_address_parts.size()>=2)
              edrCustomer.BillingAddress2=billing_address_parts[1];

            If(Shipping_address_parts.size()>=2)
              edrCustomer.ShippingAddress2=Shipping_address_parts[1];

            edrCustomer.Fax = AccttoUpdate.Fax;
            edrCustomer.AEName=AcctOwner;

            //If(address_parts.size()>=3)
            //Address3=address_parts[2];
        
             wsEdrnetComEnterpriseservicesAbsdata.SalesForceServiceSoap edrNet = 
             new wsEdrnetComEnterpriseservicesAbsdata.SalesForceServiceSoap();

			 if(calltype == 'insert')
			 {
             	wsEdrnetComEnterpriseservicesAbsdata.APIAddNewAccountResult result = edrNet.APIAddNewAccount(edrNewCustomer);
                system.debug('Result of call: the return code is ' + result.code + ' and the message is ' + result.message );
			 }
			 else
			 {
             	wsEdrnetComEnterpriseservicesAbsdata.APIUpdateAccountResult result = edrNet.APIUpdateAccount(edrCustomer);
                system.debug('Result of call: the return code is ' + result.code + ' and the message is ' + result.message );
			 }	
			 
 			//Can we notify user in a call 	
            // if(result.Successful != true )
            //    system.debug('Update Not successful: the return code is ' + result.Code + ' and the message is ' + result.message );
             //system.debug('Result of call: the return code is ' + result.code + ' and the message is ' + result.message );
             
    }   
}

 Thank you for any assistance

dkadordkador

What do the debug logs look like?

jadenjaden

I was away at the time an unable to see them.

 

I checked today and no account ID's where being passed to the class with the web service call.  It turns out that there was a filter in the filter i the trigger stopping the accounts that had been mass loaded which for now where the only ones there.  This was to prevent a flood of API calls for the Web Service during the load.

 

I removed the filter and it is once again working .

Thanks for your time; it is appreciated.

This was selected as the best answer