• jaden
  • NEWBIE
  • 350 Points
  • Member since 2011

  • Chatter
    Feed
  • 14
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 25
    Questions
  • 46
    Replies

HI, 

 

I have a request from a client and I am looking for ideas.  

 

They want to be able to enter into 5 text fields a Task Source Field (api field name) and a destination Project Field.  Based on these entries, the trigger would get the value of the source field and update the value of the destination field on Project.

 

So the field would be Due_Date__c; BLND_Start_Survey_Time__c 

 

However, if the user picks the wrong fields it could be; Due_Date__c; Status__c which is a date to picklist or if they type it in wrong I might not find it.  

 

Based on this:

I would have to validate that what they have typed\pasted in to the text fields are valid fields on the objects, that’s not too bad. 

Then I would have to do the comparisons to be sure the types are compatible (date to date and not date to picklist).

 

If not valid, kick out with message otherwise; go after values and do updates.

 

Any ideas, seems like a lot of describe code. 

 

Thanks and Happy Thanksgiving.

  • November 27, 2013
  • Like
  • 0

I have a request to parse an incoming email and create a case and possibly the account and contact from the information in the body of the email, that part is fine.  

 

However, the user also requested; 

that my inboundemailhandler should only fire when the the incoming email is from the email to case emailservice.

 

How do I limit that?  Do I test the fromaddress to be the long address (email services address)? 

 

Any suggestions, appreciated!

  • October 29, 2013
  • Like
  • 0

I have a before trigger based on OpportunityLineItem updating OpportunityLineItem.  I have a debug at the bottom of the trigger that displays the line map and it shows my discount field has been changed but the update is not getting applied. Below is the bulk of the trigger and below that is the debug log clip. 

 

 Any help appreciated! 

 

    system.debug('&&** THe OL Map before updates is ' + opplinemap); 
    system.debug('&&** THe acct map is ' + Acctmap); 
    system.debug('&&** THe Prod Map is ' + prodMAP);
 
    for(OpportunityLineItem ol : opplinemap.Values())
    {
        if(Prodmap.Containskey(ol.Pricebookentry.Product2id))
        {
            if(Prodmap.get(ol.Pricebookentry.Product2id).Family == 'SERVICES')
                if(Acctmap.get(ol.Opportunity.Accountid).Services_Discount__c != null)
                    ol.Discount__c =  Acctmap.get(ol.Opportunity.Accountid).Services_Discount__c;
            if(Prodmap.get(ol.Pricebookentry.Product2id).Family == 'SOFTWARE')
                if(Acctmap.get(ol.Opportunity.Accountid).Software_Discount__c != null)
                    ol.Discount__c =  Acctmap.get(ol.Opportunity.Accountid).Software_Discount__c;
            if(Prodmap.get(ol.Pricebookentry.Product2id).Family == 'HARDWARE')
                if(Acctmap.get(ol.Opportunity.Accountid).Hardware_Discount__c != null)
                    ol.Discount__c =  Acctmap.get(ol.Opportunity.Accountid).Hardware_Discount__c;

            //Now Update Opp flags 
            if(Prodmap.get(ol.Pricebookentry.Product2id).Product_Category__c == 'FoIP Software')
                oppmap.get(ol.Opportunityid).FoIP_Questionnaire__c = true;
            if(Prodmap.get(ol.Pricebookentry.Product2id).Product_Category__c == 'FOIP Software')
                oppmap.get(ol.Opportunityid).FoIP_Questionnaire__c = true;            
            if(Prodmap.get(ol.Pricebookentry.Product2id).Product_Category__c == 'Installation')
                oppmap.get(ol.Opportunityid).Installation_Document__c = true;
            if(Prodmap.get(ol.Pricebookentry.Product2id).Product_Category__c == 'Consulting Services')
                oppmap.get(ol.Opportunityid).PSP_Required__c = true;
            if(Prodmap.get(ol.Pricebookentry.Product2id).Product_Category__c == 'Professional Services')
                oppmap.get(ol.Opportunityid).SOW__c = true;
            	
        }    
    }
    
    system.debug('&&** Final OPP LINE MAP ' + opplinemap.Values());
    system.debug('&&** About to do update for these OPP ' + oppmap.Values());

 

11:05:18.806 (3806341000)|USER_DEBUG|[37]|DEBUG|&&** THe OL Map before updates is {006E000000BQVDgIAP=OpportunityLineItem:{OpportunityId=006E000000BQVDgIAP, PricebookEntryId=01uE0000003CcjrIAC, Id=00kE0000009IXEPIA4}}
11:05:18.806 (3806466000)|USER_DEBUG|[38]|DEBUG|&&** THe acct map is {001E000000cMLc8IAG=Account:{Services_Discount__c=10.00, Software_Discount__c=20.00, Hardware_Discount__c=30.00, Id=001E000000cMLc8IAG}}
11:05:18.806 (3806579000)|USER_DEBUG|[39]|DEBUG|&&** THe Prod Map is {01tE0000001MW22IAG=Product2:{Product_Category__c=Installation, Family=SERVICES, Id=01tE0000001MW22IAG}}
11:05:18.808 (3808090000)|USER_DEBUG|[70]|DEBUG|&&** Final OPP LINE MAP (OpportunityLineItem:{OpportunityId=006E000000BQVDgIAP, PricebookEntryId=01uE0000003CcjrIAC, Discount__c=10.00, Id=00kE0000009IXEPIA4})
11:05:18.808 (3808276000)|USER_DEBUG|[71]|DEBUG|&&** About to do update for these OPP (Opportunity:{PSP_Required__c=false, Installation_Document__c=true, Id=006E000000BQVDgIAP, FoIP_Questionnaire__c=false, SOW__c=false})
 
Thank you
  • April 19, 2013
  • Like
  • 0

Hi, 

 

Can you get the salesforce org dynamilcally into a formula field?  If so, can you provide an example or link to documentaiton.

 

Thanks

  • January 12, 2013
  • Like
  • 0

Hi,

I have a trigger against Opp products and when a checkbox I want to copy a field on opportunity to another field on opportunity. 

 

Here is the trigger:

trigger onOppProdUpdateOpp on OpportunityLineItem (after update) {
        
	//Set of ids of opps to use 
	set<Id> opid = new set<Id>(); 
	
	//identify opps needed because winner flag set
    for(OpportunityLineItem op : Trigger.new) 
    {
    	if(op.winner__c = true && op.Winner__c  != trigger.oldMap.get(op.Id).Winner__c)
    		opid.add(op.opportunityid);
    }
    
    if(opid.size() > 0 )
    {
    	//List to hold opps needed and another for those updated 
		list<Opportunity> opplistupd = new list<Opportunity>();
		list<Opportunity> opplistneeded = [select id, Winner_Total__c, amount from Opportunity where id in :opid ];
		 
	  	for(Opportunity opp: opplistneeded)
	  	{
	  		if(opp.Amount != opp.Winner_Total__c)
	  		{
	  			opp.Amount = opp.Winner_Total__c;
				opplistupd.add(opp);
	  		}	
	    } 
	      
	    if(opplistupd.size() > 0 )
	    	update opplistupd;
    } 
}

 

Here is the test class I am doing; which is where the error is coming from:

@isTest (seealldata=true)  
class onOpportunityTest {

	public static testMethod void test_onOpportunityTest () 
	{
        RecordType hnrectypeid = [Select id from RecordType where name = 'XXX Corp'];
				
        Account acct = new Account(name='XXXAcct1');
        insert acct;
        Contact con = new Contact(Firstname='XXXContact1', Lastname='BigLast',AccountID = acct.id, MailingCountry = 'United Kingdom');
        insert con;
          
    	Pricebook2 standardPB = [select id from Pricebook2 where isStandard=true limit 1 ];
    	
		Product2 prod = new Product2(name='prod1', ProductCode = 'PC1');
		insert prod;
		
  		PricebookEntry standardPrice = new PricebookEntry(Pricebook2Id = standardPB.Id, Product2Id = prod.Id, UnitPrice = 10000, UsestandardPrice = false, IsActive = true);
        insert standardPrice;
	 	
		Pricebook2 pb = new Pricebook2(name = 'PB1');
		insert pb;
  
		PricebookEntry pe = new PricebookEntry(PriceBook2id = pb.id, Product2Id = prod.id, unitprice = 10000, UsestandardPrice = true, IsActive = true);
		insert pe;
 	 	 
		Opportunity newOP = new Opportunity(Name = 'Opp', stagename = 'New', AccountId = acct.Id, CloseDate = date.today());
		insert newOp;
		 
		OpportunityLineItem newOL= new OpportunityLineItem(Opportunityid = newOP.Id, Description = 'Oppline Desc', Quantity = 1,
		   	 	ServiceDate = date.today(), UnitPrice = 2.20, PricebookEntryId = pe.Id, Program_Platform__c = 'JBplat', Customer_P_N__c='1234', Tooling_Value__c=10000, Production_Type__c = 'Production');
		insert newOl;
 	  	 
		OpportunityLineItem newOL2 = new OpportunityLineItem(Opportunityid = newOP.Id, Description = 'Oppline Desc', Quantity = 1,
		   	 	ServiceDate = date.today(), UnitPrice = 3.00, PricebookEntryId = pe.Id, Program_Platform__c = 'JBplat', Customer_P_N__c='1234', Tooling_Value__c=10000, Production_Type__c = 'Production');
		insert newOl2;
  
		Quote qte = new Quote(OpportunityId = newOp.id, ContactId=con.id, Name='Quote1', Pricebook2Id=pb.id, SubTotal__c=1.00, RecordTypeId = hnrectypeid.id );
		Insert qte;
		QuoteLineItem qli1 = new QuoteLineItem(QuoteId=qte.id, PricebookEntryId=pe.id, Quantity=2, UnitPrice= 10000);
		Insert qli1;
		
		QuoteLineItem qli2 = new QuoteLineItem(QuoteId=qte.id, PricebookEntryId=pe.id, Quantity=4, UnitPrice= 10000);
      	insert qli2;

		Test.startTest();
 		
	   //must re-query to get updated value        
        newOP = [Select  id, Winner_Total__c, Amount from Opportunity where id = :newOP.id];

        //make sure value us what is expected 
		system.assertEquals(newOP.Amount, 5.20);
 		
		//Update quote  
		qte.SubTotal__c= 2.00;
		update qte;
	 	
		//Update qteline
		qli2.winner__c = true;
		update qli2;
 		
		newOl2.winner__c = true;
		update newol2; 
		   
	   //must re-query to get updated value        
        newOP = [Select  id, Winner_Total__c, Amount from Opportunity where id = :newOP.id];

        //make sure value us what is expected 
        system.debug('** the amount is ' + newop.Amount + ' and the total is ' + newop.Winner_Total__c);
		//system.assertEquals(newOP.Winner_Total__c, newOP.Amount);
	}
}

 The error is happening on the update below and it does not matter which field on the Opp Prod I try to change.

newOl2.winner__c =

true;

 

updatenewol2;   

 

The error is:

Description Resource Path Location Type
System.DmlException: Update failed. First exception on row 0 with id 00ka000000WNGZNAA5; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, onOppProdUpdateOpp: execution of AfterUpdate

caused by: System.FinalException: Record is read-only

Trigger.onOppProdUpdateOpp: line 9, column 1: [] onOpportunityTest.cls /HN Precision/src/classes line 63 Force.com run test failure

 

any help appreciated.

 

 

  • July 31, 2012
  • Like
  • 0

Hi,

 

I have been given a specification and I have seen a lot on the boards that suggest's this may not possible, Any input from those with more experience would be appreciated.

 

The Trigger will

move the values in the following custom fields “Program / Platform”, “Customer P/N”, “Tooling Value” and “Production Type” from the Opportunity Product Line

 

to Quote line item

custom fields “Program / Platform”, “Customer P/N”, “Tooling Value” and “Production Type”.

The Quote Line will be associated

to the Quote that was created from the “New” button action on the Opportunity Related List

“Quote”.

 

Thanks in advance for your input.

  • July 25, 2012
  • Like
  • 0

Hi,

 

I am trying to watch the spring 12 training modules and getting error saying it is not available.

Here is the link:

http://salesforce.adobeconnect.com/spring12forcedotcom/ 

 

Any help appreciated.

  • March 26, 2012
  • Like
  • 0

I am looking for some help; I have a trigger I am working on using an email template.

 

Here is the basic description:

 

If due date is created or changed on a task (along with some other criteria); send  an email using a template where the merge fields are from a custom object  called project.  The project Id’s is the ‘whatid’ on the task record which is the object for my trigger. 

 

The email needs to go to the owner of task (assigned to); the created by and last modified if they are different.  These are from the user table not contacts.

 

I can build an array of email addresses to pass to the Toaddress  from the user table.

 

It looks like in the documentation that you can only use the whatID when you use a Contact for the SetTargetObject. 

 

If I set the targetobject to a user, I get an error saying that the whatid is not available for sending emails to userid’s which is what I need to do.   

 

So what I need help with is:

 

Using a trigger on the task; how can I send an email to a user id pointing at a custom object for the merge fields?

 

    String[] toAddresses = new String[]  {a valid email address would be assigned here};

    Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();

    mail.setSaveAsActivity(false);

    mail.setToAddresses(toAddresses);

    mail.settargetObjectid('005E0000000hErv');  //User id

   

    mail.setWhatId(TaskProjIds.get(currenttask.id));              //points to project

    mail.setTemplateId('00XE0000000cegY');   // Template

    Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });

 

This gives the error that whatid is not allowed when settargetobject is a user.

 

If I set the SetTargetObject to a random contact; the email does send and does merge fields.  However the contact also gets the email which is not what I would want.

 

I have searched the forums and it does seem others have run into this but I do not see a clear resolution .

Any help appreciated,

  • November 20, 2011
  • Like
  • 0

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.

  • October 20, 2011
  • Like
  • 0

I am considering taking the Dev401 class but trying to decide on trip.  Staying at suggested hotels near the venue is usually more expensive then staying a little further out.   However sometimes staying at the suggested hotels allows for networking about the class and working on things at night can be good as well.

 

I am looking for feedback from others who have attended; could you please share your thougts on this. 

 

Thanks for the input

  • September 22, 2011
  • Like
  • 0

I have a trigger that is calling an @future to avoid hitting both SOQL limits and script limits.  It workis fine when you go into the account and make the change manually but not when run for a batch. 

 

Here is the trigger:

 

trigger ZipAcctChangeShare on Account (before update)  {

 	set<id> idso = new set<id>();
 	set<string> zipso = new set<string>();
	For(Account acc :trigger.old)
	{
		//Only send id's for those accounts with zip changes
		//system.debug('the old id trigger.oldMap.get(Acc.Id) is  ' + trigger.oldMap.get(Acc.Id));
		//system.debug('the new id trigger.newMap.get(Acc.Id) is ' + trigger.newMap.get(Acc.Id) + ' the acc.dd is ' + acc.id);
		//If (trigger.newMap.get(Acc.Id).BillingPostalCode != Acc.BillingPostalCode)
		If (trigger.newMap.get(Acc.Id).BillingPostalCode != Acc.BillingPostalCode)
		{ 
			idso.add(Acc.Id);
			zipso.add(Acc.BillingPostalCode);
		}
	}

	//system.debug('the size of idso is ' + idso.size());
	if(idso.size() > 0 && zipso.Size() > 0)
    	ProcessZipChangeOnAcct.ChangeShare(idso,zipso);
}

 

Here is the @future

 

public class ProcessZipChangeOnAcct {
@Future
    public static void ChangeShare(Set<Id> idso, Set<String> zipso) {
 	
 		//Build list of old zip code needed 
	 	list<Account> zipsrecs = [SELECT id, BillingPostalCode from Account WHERE id in :idso]; 
		
		//Get All territory zip records for zip codes from above
		List<Territory_Zip_Code__c> tc = new List<Territory_Zip_Code__c>();
		For(List< Territory_Zip_Code__c> t: [SELECT id, GroupId__c, name FROM Territory_Zip_Code__c WHERE Name in :zipso])
	                Tc.addall(t);
	              
		//List to hold account share to be deleted
		List<AccountShare> tbdACCShList = New List<AccountShare>();
	
		//get list of AccountShares that have an ID matching the Account ID’s in the set
		List<AccountShare> lAS = [Select id, AccountID, UserOrGroupID From AccountShare WHERE AccountID in : idso];
		
		For(Account acc :zipsrecs)
		{
           for (Territory_Zip_Code__c tzc: tc)
           { 
 	       	for (AccountShare Ashare :lAS) 
	        {	
			    if(Ashare.accountid == Acc.id && AShare.UserOrGroupId == tzc.GroupID__c) 
			 	 	tbdACCShList.add(Ashare);

			}   //for (AccountShare Ashare :lAS)
           }    //For Terr_Zip 
	    }  //For Account 
	      
	   	//If we have records to be deleted, delete the records    
	   	//system.debug('the size of the delete list is ' + tbdACCShList.size());       	 
		If(tbdACCShList.size() > 0)
		{
			try
			{
				Delete tbdACCShList;
			}
			catch (Exception e) {
			}
		}
    }
}

 Thank you for any assitance

  • September 15, 2011
  • Like
  • 0

I am trying to call the webservice and getting the following error:

First error: Web service callout failed: WebService returned a SOAP Fault: Server did not recognize the value of HTTP Header SOAPAction: 

 

Here is the apex from the wsdl:

public class wsEdrnetComEnterpriseservicesAbsdata {
    public class APIGetAccount_element {
        private String[] apex_schema_type_info = new String[]{'http://stagews.edrnet.com/enterpriseservices/absdataintegrationservices/salesforceservice','true','false'};
        private String[] field_order_type_info = new String[]{};
    }
    public class APIUpdateAccount_element {
        public wsEdrnetComEnterpriseservicesAbsdata.APIExistingCustomer existingCustomer;
        private String[] existingCustomer_type_info = new String[]{'existingCustomer','http://Stagews.edrnet.com/enterpriseservices/absdataintegrationservices/salesforceservice','APIExistingCustomer','0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://Stagews.edrnet.com/enterpriseservices/absdataintegrationservices/salesforceservice','true','false'};
        private String[] field_order_type_info = new String[]{'existingCustomer'};
    }
    public class APIUpdateAccountResult {
        private String[] apex_schema_type_info = new String[]{'http://Stagews.edrnet.com/enterpriseservices/absdataintegrationservices/salesforceservice','true','false'};
        private String[] field_order_type_info = new String[]{};
    }
    public class APIAddNewAccountResponse_element {
        public wsEdrnetComEnterpriseservicesAbsdata.APIAddNewAccountResult APIAddNewAccountResult;
        private String[] APIAddNewAccountResult_type_info = new String[]{'APIAddNewAccountResult','http://stagews.edrnet.com/enterpriseservices/absdataintegrationservices/salesforceservice','APIAddNewAccountResult','0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://stagews.edrnet.com/enterpriseservices/absdataintegrationservices/salesforceservice','true','false'};
        private String[] field_order_type_info = new String[]{'APIAddNewAccountResult'};
    }
    public class APINewCustomer {
        public String CompanyName;
        public String ContactFirstName;
        public String ContactLastName;
        public String Address1;
        public String City;
        public String State;
        public String ZipCode;
        public String Country;
        public String Phone;
        public String Industry;
        private String[] CompanyName_type_info = new String[]{'CompanyName','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] ContactFirstName_type_info = new String[]{'ContactFirstName','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] ContactLastName_type_info = new String[]{'ContactLastName','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] Address1_type_info = new String[]{'Address1','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] City_type_info = new String[]{'City','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] State_type_info = new String[]{'State','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] ZipCode_type_info = new String[]{'ZipCode','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] Country_type_info = new String[]{'Country','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] Phone_type_info = new String[]{'Phone','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] Industry_type_info = new String[]{'Industry','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://stagews.edrnet.com/enterpriseservices/absdataintegrationservices/salesforceservice','true','false'};
        private String[] field_order_type_info = new String[]{'CompanyName','ContactFirstName','ContactLastName','Address1','City','State','ZipCode','Country','Phone','Industry'};
    }
    public class SalesForceServiceSoap {
        public String endpoint_x = 'http://stagews.edrnet.com/enterpriseservices/absdataintegrationservices/salesforceservice.asmx';
        public Map<String,String> inputHttpHeaders_x;
        public Map<String,String> outputHttpHeaders_x;
        public String clientCertName_x;
        public String clientCert_x;
        public String clientCertPasswd_x;
        public Integer timeout_x;
        private String[] ns_map_type_info = new String[]{'http://stagews.edrnet.com/enterpriseservices/absdataintegrationservices/salesforceservice', 'wsEdrnetComEnterpriseservicesAbsdata'};
        public wsEdrnetComEnterpriseservicesAbsdata.APIUpdateAccountResult APIUpdateAccount(wsEdrnetComEnterpriseservicesAbsdata.APIExistingCustomer existingCustomer) {
            wsEdrnetComEnterpriseservicesAbsdata.APIUpdateAccount_element request_x = new wsEdrnetComEnterpriseservicesAbsdata.APIUpdateAccount_element();
            wsEdrnetComEnterpriseservicesAbsdata.APIUpdateAccountResponse_element response_x;
            request_x.existingCustomer = existingCustomer;
            Map<String, wsEdrnetComEnterpriseservicesAbsdata.APIUpdateAccountResponse_element> response_map_x = new Map<String, wsEdrnetComEnterpriseservicesAbsdata.APIUpdateAccountResponse_element>();
            response_map_x.put('response_x', response_x);
            WebServiceCallout.invoke(
              this,
              request_x,
              response_map_x,
              new String[]{endpoint_x, 
              //For testing the http is http://Stagews.edrnet	
              //For production the http is http://ws.edrnet
              'http://Stagews.edrnet.com/enterpriseservices/absdataintegrationservices/salesforceservice/APIUpdateAccount',
              'http://Stagews.edrnet.com/enterpriseservices/absdataintegrationservices/salesforceservice',
              'APIUpdateAccount',
              'http://Stagews.edrnet.com/enterpriseservices/absdataintegrationservices/salesforceservice',
              'APIUpdateAccountResponse',
              'wsEdrnetComEnterpriseservicesAbsdata.APIUpdateAccountResponse_element'}
            );
            response_x = response_map_x.get('response_x');
            return response_x.APIUpdateAccountResult;
        }
        public wsEdrnetComEnterpriseservicesAbsdata.APIAddNewAccountResult APIAddNewAccount(wsEdrnetComEnterpriseservicesAbsdata.APINewCustomer newCustomer) {
            wsEdrnetComEnterpriseservicesAbsdata.APIAddNewAccount_element request_x = new wsEdrnetComEnterpriseservicesAbsdata.APIAddNewAccount_element();
            wsEdrnetComEnterpriseservicesAbsdata.APIAddNewAccountResponse_element response_x;
            request_x.newCustomer = newCustomer;
            Map<String, wsEdrnetComEnterpriseservicesAbsdata.APIAddNewAccountResponse_element> response_map_x = new Map<String, wsEdrnetComEnterpriseservicesAbsdata.APIAddNewAccountResponse_element>();
            response_map_x.put('response_x', response_x);
            WebServiceCallout.invoke(
              this,
              request_x,
              response_map_x,
              new String[]{endpoint_x,
              'http://stagews.edrnet.com/enterpriseservices/absdataintegrationservices/salesforceservice/APIAddNewAccount',
              'http://stagews.edrnet.com/enterpriseservices/absdataintegrationservices/salesforceservice',
              'APIAddNewAccount',
              'http://stagews.edrnet.com/enterpriseservices/absdataintegrationservices/salesforceservice',
              'APIAddNewAccountResponse',
              'wsEdrnetComEnterpriseservicesAbsdata.APIAddNewAccountResponse_element'}
            );
            response_x = response_map_x.get('response_x');
            return response_x.APIAddNewAccountResult;
        }
        public wsEdrnetComEnterpriseservicesAbsdata.APIGetAccountResult APIGetAccount() {
            wsEdrnetComEnterpriseservicesAbsdata.APIGetAccount_element request_x = new wsEdrnetComEnterpriseservicesAbsdata.APIGetAccount_element();
            wsEdrnetComEnterpriseservicesAbsdata.APIGetAccountResponse_element response_x;
            Map<String, wsEdrnetComEnterpriseservicesAbsdata.APIGetAccountResponse_element> response_map_x = new Map<String, wsEdrnetComEnterpriseservicesAbsdata.APIGetAccountResponse_element>();
            response_map_x.put('response_x', response_x);
            WebServiceCallout.invoke(
              this,
              request_x,
              response_map_x,
              new String[]{endpoint_x,
              'http://stagews.edrnet.com/enterpriseservices/absdataintegrationservices/salesforceservice/APIGetAccount',
              'http://stagews.edrnet.com/enterpriseservices/absdataintegrationservices/salesforceservice',
              'APIGetAccount',
              'http://stagews.edrnet.com/enterpriseservices/absdataintegrationservices/salesforceservice',
              'APIGetAccountResponse',
              'wsEdrnetComEnterpriseservicesAbsdata.APIGetAccountResponse_element'}
            );
            response_x = response_map_x.get('response_x');
            return response_x.APIGetAccountResult;
        }
    }
    public class APIAddNewAccount_element {
        public wsEdrnetComEnterpriseservicesAbsdata.APINewCustomer newCustomer;
        private String[] newCustomer_type_info = new String[]{'newCustomer','http://stagews.edrnet.com/enterpriseservices/absdataintegrationservices/salesforceservice','APINewCustomer','0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://stagews.edrnet.com/enterpriseservices/absdataintegrationservices/salesforceservice','true','false'};
        private String[] field_order_type_info = new String[]{'newCustomer'};
    }
    public class APIAddNewAccountResult {
        private String[] apex_schema_type_info = new String[]{'http://stagews.edrnet.com/enterpriseservices/absdataintegrationservices/salesforceservice','true','false'};
        private String[] field_order_type_info = new String[]{};
    }
    public class APIUpdateAccountResponse_element {
        public wsEdrnetComEnterpriseservicesAbsdata.APIUpdateAccountResult APIUpdateAccountResult;
        private String[] APIUpdateAccountResult_type_info = new String[]{'APIUpdateAccountResult','http://stagews.edrnet.com/enterpriseservices/absdataintegrationservices/salesforceservice','APIUpdateAccountResult','0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://stagews.edrnet.com/enterpriseservices/absdataintegrationservices/salesforceservice','true','false'};
        private String[] field_order_type_info = new String[]{'APIUpdateAccountResult'};
    }
    public class APIExistingCustomer {
        public String AccountNumber;
        public String Password;
        public String Email;
        public String Address2;
        public String Fax;
        public String AEName;
        public String Initials;
        private String[] AccountNumber_type_info = new String[]{'AccountNumber','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] Password_type_info = new String[]{'Password','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] Email_type_info = new String[]{'Email','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] Address2_type_info = new String[]{'Address2','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] Fax_type_info = new String[]{'Fax','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] AEName_type_info = new String[]{'AEName','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] Initials_type_info = new String[]{'Initials','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://stagews.edrnet.com/enterpriseservices/absdataintegrationservices/salesforceservice','true','false'};
        private String[] field_order_type_info = new String[]{'AccountNumber','Password','Email','Address2','Fax','AEName','Initials'};
    }
    public class APIResponse {
        public Boolean Successful;
        public String Message;
        public String Code;
        private String[] Successful_type_info = new String[]{'Successful','http://www.w3.org/2001/XMLSchema','boolean','1','1','false'};
        private String[] Message_type_info = new String[]{'Message','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] Code_type_info = new String[]{'Code','http://stagews.edrnet.com/enterpriseservices/absdataintegrationservices/salesforceservice','ReturnCodes','1','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://stagews.edrnet.com/enterpriseservices/absdataintegrationservices/salesforceservice','true','false'};
        private String[] field_order_type_info = new String[]{'Successful','Message','Code'};
    }
    public class APIGetAccountResponse_element {
        public wsEdrnetComEnterpriseservicesAbsdata.APIGetAccountResult APIGetAccountResult;
        private String[] APIGetAccountResult_type_info = new String[]{'APIGetAccountResult','http://stagews.edrnet.com/enterpriseservices/absdataintegrationservices/salesforceservice','APIGetAccountResult','0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://stagews.edrnet.com/enterpriseservices/absdataintegrationservices/salesforceservice','true','false'};
        private String[] field_order_type_info = new String[]{'APIGetAccountResult'};
    }
    public class APIGetAccountResult {
        private String[] apex_schema_type_info = new String[]{'http://stagews.edrnet.com/enterpriseservices/absdataintegrationservices/salesforceservice','true','false'};
        private String[] field_order_type_info = new String[]{};
    }
}

 

Here is my class to call it:

public class ABSCalloutClass  {

    public static void CallABSWS(Set<Id> idsn){
		list <Account> acctRecs;
		string AccttoUpdateID;
		string ConFirstName;
		string ConLastName;
		string ConEmail;
		string AcctOwner;
		
         //Creating a List from a SOQL query using idsn
          acctRecs  = [SELECT acc.Id, acc.ownerid FROM Account acc WHERE acc.ID in :Idsn];
            
    	system.debug('The acctrecs is ' + acctRecs);
    	
    	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]);
		system.debug('map of owners ' + owners);
		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')]; 

		system.debug(' the contact list is ' + Contacts);
		
        //iterate thru the ids	
        for (Account Acct: acctRecs) {	
         	AccttoUpdateID = Acct.Id;
			If(owners.containskey(Acct.Ownerid))
				AcctOwner=owners.get(Acct.Ownerid).Name;
				
         	system.debug('the contacts are ' + Contacts);
         	for (AccountContactRole con: Contacts) { 
         		if (con.contact.AccountID == AccttoUpdateID) {
         			ConFirstName = Con.contact.Firstname;
         			ConLastName = Con.contact.Lastname;
         			ConEmail = Con.contact.Email;
         		}
         	}
         	system.debug('about to invoke call, the account is   ' + AccttoUpdateID + ' and the owner is ' + AcctOwner);
        	CallUpdateInvokeWebService(AccttoUpdateID, ConFirstName, ConLastName, ConEmail, AcctOwner);	
        }
    }  
    @future(callout=true)  	  
	public static void CallUpdateInvokeWebService(String AccttoUpdateID, String ConFirstName, String ConLastName, String ConEmail, string AcctOwner) {
	 	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];
   	
        system.debug('The name is ' + AccttoUpdate.name + ' the number is ' + AccttoUpdate.AccountNumber);
		
//        If(trigger.isUpdate) {     
            //Create Instance of service call 
        	wsEdrnetComEnterpriseservicesAbsdata.APIExistingCustomer edrCustomer = new
            wsEdrnetComEnterpriseservicesAbsdata.APIExistingCustomer();
            
        	wsEdrnetComEnterpriseservicesAbsdata.APINewCustomer edrNewCustomer = new
            wsEdrnetComEnterpriseservicesAbsdata.APINewCustomer();
            
            wsEdrnetComEnterpriseservicesAbsdata.APIResponse edrAPIResponse = new
            wsEdrnetComEnterpriseservicesAbsdata.APIResponse();
                   
            edrCustomer.AccountNumber = AccttoUpdate.AccountNumber;
            edrCustomer.Password=AccttoUpdate.EDR_Password__c; 
            edrNewCustomer.CompanyName = AccttoUpdate.Name; 
			edrNewCustomer.ContactFirstName=ConFirstName;
            
	        edrNewCustomer.ContactLastName = ConLastName;
        	edrNewCustomer.City = AccttoUpdate.BillingCity;
        	edrNewCustomer.State = AccttoUpdate.BillingState;
        	edrNewCustomer.ZipCode = AccttoUpdate.BillingPostalCode;
        	edrNewCustomer.Country = AccttoUpdate.BillingCountry;
        	edrNewCustomer.Phone = AccttoUpdate.Phone;
        	edrNewCustomer.Industry = AccttoUpdate.Industry;
        	edrCustomer.Email = ConEmail;
        	edrCustomer.Fax = AccttoUpdate.Fax;
        	edrCustomer.AEName=AcctOwner;
       		
       		//Split SF Street into 2 fields
       		List<string> address_parts = new List<String>();
			Address_parts=AccttoUpdate.BillingStreet.split('\n');

			If(address_parts.size()>=1)
			  edrNewCustomer.Address1=address_parts[0];
			  
			  system.debug('the address 1 is ' + edrNewCustomer.Address1); 
			  
			If(address_parts.size()>=2)
			  edrCustomer.Address2=address_parts[1];
			  
			  system.debug('the address 2 is ' + edrCustomer.Address2); 
			//If(address_parts.size()>=3)
			//Address3=address_parts[2];
       	
             wsEdrnetComEnterpriseservicesAbsdata.SalesForceServiceSoap edrNet = 
             new wsEdrnetComEnterpriseservicesAbsdata.SalesForceServiceSoap();
                 
             system.debug('about to call update');
               
             wsEdrnetComEnterpriseservicesAbsdata.APIUpdateAccountResult result = 
             edrNet.APIUpdateAccount(edrCustomer);
             system.debug('back from call update'); 
           
             
//        } // If trigger upadte    
	}	
}

 Thank you for time if you can help with this.

  • September 15, 2011
  • Like
  • 0

I have a trigger which caused above error during a bulk test by the user. 

 

So I am splitting into a trigger which will call a @future class.

 

I pass the id's for the trigger.old and trigger.new to the class but when I get the account values using the Id's from trigger old; it already has the new value. 

 

Here is the trigger:

trigger ZipAcctChangeShare on Account (after update)  {

 //   AccountShare[] newShares = new AccountShare[0];
    
    set<id> idsn = new set<id>();
    for (Account AcctRecs : trigger.new)
    {
        idsn.add(AcctRecs.Id);
        system.debug('in trigger the new postal code is ' + AcctRecs.BillingPostalCode + ' and the id is ' + AcctRecs.Id);
    }  
    //BUild Set of trigger old id's 
    set<id> idso = new set<id>();
    for (Account AcctRecsold : trigger.old)
    {
        idso.add(AcctRecsold.Id);
        system.debug('in trigger the old postal code is ' + AcctRecsold.BillingPostalCode + ' and the id is ' + AcctRecsold.Id);
    }  

    ProcessZipChangeOnAcct.ChangeShare(idsn, idso);
}

 

Now here is the class I created; I am testing it by commenting out the @future:

 

public class ProcessZipChangeOnAcct {
//@Future
     public static void ChangeShare(Set<Id> idsn, Set<Id> idso) {
 	
    AccountShare[] newShares = new AccountShare[0];

 	list<Account> zipsrecs = [SELECT BillingPostalCode from Account WHERE id in :idso]; 
	set<string> zipso = new set<string>();
	for (Account zr : zipsrecs)
    {
        zipso.add(zr.BillingPostalCode);
     }
	
	List<Territory_Zip_Code__c> tc = new List<Territory_Zip_Code__c>();
	For(List< Territory_Zip_Code__c> t: [SELECT id, GroupId__c, name FROM Territory_Zip_Code__c WHERE Name in :zipso])
                Tc.addall(t);
                
	Map<id,Account> acctold = new Map<id,Account>([SELECT ID, BillingPostalCode from Account WHERE id in :idso]);	   
	system.debug('the acct old map is ' + acctold); 
	
    list<Account> AcctRecs = [SELECT Id, BillingPostalCode FROM Account WHERE ID in :idsn]; 
    system.debug('the New list is ' +AcctRecs); 
    
	//List of account share to be deleted
	List<AccountShare> tbdACCShList = New List<AccountShare>();

	//get list of AccountShares that have an ID matching the Account ID’s in the set
	List<AccountShare> lAS = [Select id, AccountID, UserOrGroupID From AccountShare WHERE AccountID in : idsn];
	
	//system.debug('the list is ' + las); 
	
	For(Account acc :AcctRecs)
	{
	//system.debug('the acc  ' + acc); 
		//If (trigger.oldMap.get(Acc.Id).BillingPostalCode != Acc.BillingPostalCode) {
        If (acctold.get(Acc.id).BillingPostalCode != Acc.BillingPostalCode) {    
           for (Territory_Zip_Code__c tzc: tc) { 
	           	 //if (tzc.name == Trigger.oldMap.get(Acc.Id).BillingPostalCode) 
	           	 if (tzc.name == acctold.get(Acc.Id).BillingPostalCode) 
	           	 {
	           	     for (AccountShare Ashare :lAS) 
	           	     {	
					    // system.debug('the las  list is ' + las); 
					     if(Ashare.accountid == Acc.id && AShare.UserOrGroupId == tzc.GroupID__c) 
					     {
					   	 	//system.debug('inside ashare ');
							tbdACCShList.add(Ashare);
							//system.debug('the to be deleted ' + tbdACCShList );
					     }	
					}   //for (AccountShare Ashare :lAS)
	           	 }	  //(tzc.name == 
           	 }    //For Terr_Zip 
        }   //If trigger old              

    }  //For Account 
      
      
   	//If we have records to be deleted, delete the records    
   	system.debug('the size of the delete list is ' + tbdACCShList.size());       	 
	If(tbdACCShList.size() > 0)
	    Delete tbdACCShList;  
    	
    }
}

 Thank you for any assistace.

  • September 14, 2011
  • Like
  • 0

Hi,

 

Get SOQL limits error, I have tried several things and cannot seem to get around, any help greatly appreciated.

 

Here is the trigger:

trigger ZipAcctChangeShare on Account (after update)  {

    //Will create shares when zip changes - JJB Blackiron Group 8-2011       
     AccountShare[] newShares = new AccountShare[0];
    
    set<id> idsn = new set<id>();
    for (Account AcctRecs : Trigger.new)
    {
        idsn.add(AcctRecs.Id);
        system.debug('just added if ' +AcctRecs.Id);
    }  
    
	List<Territory_Zip_Code__c> tc = new List<Territory_Zip_Code__c>();

	set<string> zipso = new set<string>();
	for (Account AcctRecs : Trigger.old)
    {
        zipso.add(AcctRecs.BillingPostalCode);
    }

	For(List< Territory_Zip_Code__c> t: [SELECT id, GroupId__c, name FROM Territory_Zip_Code__c WHERE Name in :zipso])
                Tc.addall(t);
	   
    list<Account> AcctRecs = [SELECT Id, BillingPostalCode FROM Account WHERE ID in :idsn]; 
	//list< Territory_Zip_Code__c > ZipRecs = [SELECT id, GroupId__c, name FROM Territory_Zip_Code__c WHERE Name in :zipso];
    
//    for (Account AcctIn  : Trigger.new) {
    for (Account AcctIn  :AcctRecs) {      
                              
       system.debug('the Current ' + AcctIn.BillingPostalCode);
       system.debug('the Old zip is ' + Trigger.oldMap.get(Acctin.Id).BillingPostalCode);
       if (Trigger.oldMap.get(Acctin.Id).BillingPostalCode != AcctIn.BillingPostalCode) {
 
          //Build list of Territory zip records to get the groups 
          //   List<Territory_Zip_Code__c> ZipRecs =
          //   [SELECT terr.id, terr.GroupId__c
          //   FROM Territory_ZIP_Code__c  terr
         //    WHERE name = :Trigger.oldMap.get(Acctin.Id).BillingPostalCode ];
             
           for (Territory_Zip_Code__c tzc: tc) { 
           	 if (tzc.name == Trigger.oldMap.get(Acctin.Id).BillingPostalCode) 
           	 {
               system.debug('the group id is ' + tzc.GroupID__c);

                // Find and delete shares
                try {
                    system.debug('The acct id before share read is ' + AcctIn.id );
                    AccountShare accsh = [Select id, AccountID from AccountShare where AccountID = :AcctIn.id and UserOrGroupId = :tzc.GroupID__c ];
                    try
                    {
                        delete accsh;
                    }
                    catch (Exception ex) {
                    }   
                }
                catch (Exception ex) {
                }
           	 }
           }
      }             
    }  

}

 Here is the error:

15:16:12.830 (9830246000)|CODE_UNIT_FINISHED|ZipAcctChangeShare on Account trigger event AfterUpdate for [001T000000rsYqi]
15:16:12.832 (9832910000)|FATAL_ERROR|System.LimitException: Too many SOQL queries: 101

Trigger.ZipAcctChangeShare: line 21, column 38

 

  • September 09, 2011
  • Like
  • 0

I am getting above error on this line contained in block of code below:

 

Address_parts=AccttoUpdate.BillingStreet('\n');


 

AccttoUpdate = [SELECT acc.Id, acc.Name, acc.AccountNumber,          acc.EDR_Password__c, acc.Industry, 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];
   	
       		
	//Split SF Street into 2 fields
	List<string> address_parts = new List<String>();
	Address_parts=AccttoUpdate.BillingStreet('\n');

	If(address_parts.size()>=1)
            edrNewCustomer.Address1=address_parts[0];

	If(address_parts.size()>=2)
             edrCustomer.Address2=address_parts[1];

 Any Assistance greatly appreciated.

  • September 09, 2011
  • Like
  • 0

I am working on a callout to a webservice and I am getting an error structuring one of the methods.  The error is happening on this line:

               public static void APIParseResponse(APIUpdateAccountResult XXXAPIResponse) {

 

The error is:

Save error: Invalid type: APIUpdateAccountResult ABSCalloutClass.cls 

 

Here is the wsdl2apex: 

 

//Generated by wsdl2apex

//**********************************************
//BEFORE GOING LIVE CHANGE name from stagews. to ws. 
//**********************************************

public class wsXXXnetComEnterpriseservicesAbsdata {
    public class APIGetAccount_element {
        private String[] apex_schema_type_info = new String[]{'http://stagews.XXXnet.com/enterpriseservices/absdataintegrationservices/salesforceservice','true','false'};
        private String[] field_order_type_info = new String[]{};
    }
    public class APIUpdateAccount_element {
        public wsXXXnetComEnterpriseservicesAbsdata.APIExistingCustomer existingCustomer;
        private String[] existingCustomer_type_info = new String[]{'existingCustomer','http://Stagews.XXXnet.com/enterpriseservices/absdataintegrationservices/salesforceservice','APIExistingCustomer','0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://Stagews.XXXnet.com/enterpriseservices/absdataintegrationservices/salesforceservice','true','false'};
        private String[] field_order_type_info = new String[]{'existingCustomer'};
    }
    public class APIUpdateAccountResult {
        private String[] apex_schema_type_info = new String[]{'http://Stagews.XXXnet.com/enterpriseservices/absdataintegrationservices/salesforceservice','true','false'};
        private String[] field_order_type_info = new String[]{};
    }
    public class APIAddNewAccountResponse_element {
        public wsXXXnetComEnterpriseservicesAbsdata.APIAddNewAccountResult APIAddNewAccountResult;
        private String[] APIAddNewAccountResult_type_info = new String[]{'APIAddNewAccountResult','http://stagews.XXXnet.com/enterpriseservices/absdataintegrationservices/salesforceservice','APIAddNewAccountResult','0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://stagews.XXXnet.com/enterpriseservices/absdataintegrationservices/salesforceservice','true','false'};
        private String[] field_order_type_info = new String[]{'APIAddNewAccountResult'};
    }
    public class APINewCustomer {
        public String CompanyName;
        public String ContactFirstName;
        public String ContactLastName;
        public String Address1;
        public String City;
        public String State;
        public String ZipCode;
        public String Country;
        public String Phone;
        public String Industry;
        private String[] CompanyName_type_info = new String[]{'CompanyName','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] ContactFirstName_type_info = new String[]{'ContactFirstName','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] ContactLastName_type_info = new String[]{'ContactLastName','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] Address1_type_info = new String[]{'Address1','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] City_type_info = new String[]{'City','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] State_type_info = new String[]{'State','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] ZipCode_type_info = new String[]{'ZipCode','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] Country_type_info = new String[]{'Country','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] Phone_type_info = new String[]{'Phone','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] Industry_type_info = new String[]{'Industry','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://stagews.XXXnet.com/enterpriseservices/absdataintegrationservices/salesforceservice','true','false'};
        private String[] field_order_type_info = new String[]{'CompanyName','ContactFirstName','ContactLastName','Address1','City','State','ZipCode','Country','Phone','Industry'};
    }
    public class SalesForceServiceSoap {
        public String endpoint_x = 'http://stagews.XXXnet.com/enterpriseservices/absdataintegrationservices/salesforceservice.asmx';
        public Map<String,String> inputHttpHeaders_x;
        public Map<String,String> outputHttpHeaders_x;
        public String clientCertName_x;
        public String clientCert_x;
        public String clientCertPasswd_x;
        public Integer timeout_x;
        private String[] ns_map_type_info = new String[]{'http://stagews.XXXnet.com/enterpriseservices/absdataintegrationservices/salesforceservice', 'wsXXXnetComEnterpriseservicesAbsdata'};
        public wsXXXnetComEnterpriseservicesAbsdata.APIUpdateAccountResult APIUpdateAccount(wsXXXnetComEnterpriseservicesAbsdata.APIExistingCustomer existingCustomer) {
            wsXXXnetComEnterpriseservicesAbsdata.APIUpdateAccount_element request_x = new wsXXXnetComEnterpriseservicesAbsdata.APIUpdateAccount_element();
            wsXXXnetComEnterpriseservicesAbsdata.APIUpdateAccountResponse_element response_x;
            request_x.existingCustomer = existingCustomer;
            Map<String, wsXXXnetComEnterpriseservicesAbsdata.APIUpdateAccountResponse_element> response_map_x = new Map<String, wsXXXnetComEnterpriseservicesAbsdata.APIUpdateAccountResponse_element>();
            response_map_x.put('response_x', response_x);
            WebServiceCallout.invoke(
              this,
              request_x,
              response_map_x,
              new String[]{endpoint_x, 
              //For testing the http is http://Stagews.XXXnet	
              //For production the http is http://ws.XXXnet
              'http://Stagews.XXXnet.com/enterpriseservices/absdataintegrationservices/salesforceservice/APIUpdateAccount',
              'http://Stagews.XXXnet.com/enterpriseservices/absdataintegrationservices/salesforceservice',
              'APIUpdateAccount',
              'http://Stagews.XXXnet.com/enterpriseservices/absdataintegrationservices/salesforceservice',
              'APIUpdateAccountResponse',
              'wsXXXnetComEnterpriseservicesAbsdata.APIUpdateAccountResponse_element'}
            );
            response_x = response_map_x.get('response_x');
            return response_x.APIUpdateAccountResult;
        }
        public wsXXXnetComEnterpriseservicesAbsdata.APIAddNewAccountResult APIAddNewAccount(wsXXXnetComEnterpriseservicesAbsdata.APINewCustomer newCustomer) {
            wsXXXnetComEnterpriseservicesAbsdata.APIAddNewAccount_element request_x = new wsXXXnetComEnterpriseservicesAbsdata.APIAddNewAccount_element();
            wsXXXnetComEnterpriseservicesAbsdata.APIAddNewAccountResponse_element response_x;
            request_x.newCustomer = newCustomer;
            Map<String, wsXXXnetComEnterpriseservicesAbsdata.APIAddNewAccountResponse_element> response_map_x = new Map<String, wsXXXnetComEnterpriseservicesAbsdata.APIAddNewAccountResponse_element>();
            response_map_x.put('response_x', response_x);
            WebServiceCallout.invoke(
              this,
              request_x,
              response_map_x,
              new String[]{endpoint_x,
              'http://stagews.XXXnet.com/enterpriseservices/absdataintegrationservices/salesforceservice/APIAddNewAccount',
              'http://stagews.XXXnet.com/enterpriseservices/absdataintegrationservices/salesforceservice',
              'APIAddNewAccount',
              'http://stagews.XXXnet.com/enterpriseservices/absdataintegrationservices/salesforceservice',
              'APIAddNewAccountResponse',
              'wsXXXnetComEnterpriseservicesAbsdata.APIAddNewAccountResponse_element'}
            );
            response_x = response_map_x.get('response_x');
            return response_x.APIAddNewAccountResult;
        }
        public wsXXXnetComEnterpriseservicesAbsdata.APIGetAccountResult APIGetAccount() {
            wsXXXnetComEnterpriseservicesAbsdata.APIGetAccount_element request_x = new wsXXXnetComEnterpriseservicesAbsdata.APIGetAccount_element();
            wsXXXnetComEnterpriseservicesAbsdata.APIGetAccountResponse_element response_x;
            Map<String, wsXXXnetComEnterpriseservicesAbsdata.APIGetAccountResponse_element> response_map_x = new Map<String, wsXXXnetComEnterpriseservicesAbsdata.APIGetAccountResponse_element>();
            response_map_x.put('response_x', response_x);
            WebServiceCallout.invoke(
              this,
              request_x,
              response_map_x,
              new String[]{endpoint_x,
              'http://stagews.XXXnet.com/enterpriseservices/absdataintegrationservices/salesforceservice/APIGetAccount',
              'http://stagews.XXXnet.com/enterpriseservices/absdataintegrationservices/salesforceservice',
              'APIGetAccount',
              'http://stagews.XXXnet.com/enterpriseservices/absdataintegrationservices/salesforceservice',
              'APIGetAccountResponse',
              'wsXXXnetComEnterpriseservicesAbsdata.APIGetAccountResponse_element'}
            );
            response_x = response_map_x.get('response_x');
            return response_x.APIGetAccountResult;
        }
    }
    public class APIAddNewAccount_element {
        public wsXXXnetComEnterpriseservicesAbsdata.APINewCustomer newCustomer;
        private String[] newCustomer_type_info = new String[]{'newCustomer','http://stagews.XXXnet.com/enterpriseservices/absdataintegrationservices/salesforceservice','APINewCustomer','0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://stagews.XXXnet.com/enterpriseservices/absdataintegrationservices/salesforceservice','true','false'};
        private String[] field_order_type_info = new String[]{'newCustomer'};
    }
    public class APIAddNewAccountResult {
        private String[] apex_schema_type_info = new String[]{'http://stagews.XXXnet.com/enterpriseservices/absdataintegrationservices/salesforceservice','true','false'};
        private String[] field_order_type_info = new String[]{};
    }
    public class APIUpdateAccountResponse_element {
        public wsXXXnetComEnterpriseservicesAbsdata.APIUpdateAccountResult APIUpdateAccountResult;
        private String[] APIUpdateAccountResult_type_info = new String[]{'APIUpdateAccountResult','http://stagews.XXXnet.com/enterpriseservices/absdataintegrationservices/salesforceservice','APIUpdateAccountResult','0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://stagews.XXXnet.com/enterpriseservices/absdataintegrationservices/salesforceservice','true','false'};
        private String[] field_order_type_info = new String[]{'APIUpdateAccountResult'};
    }
    public class APIExistingCustomer {
        public String AccountNumber;
        public String Password;
        public String Email;
        public String Address2;
        public String Fax;
        public String AEName;
        public String Initials;
        private String[] AccountNumber_type_info = new String[]{'AccountNumber','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] Password_type_info = new String[]{'Password','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] Email_type_info = new String[]{'Email','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] Address2_type_info = new String[]{'Address2','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] Fax_type_info = new String[]{'Fax','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] AEName_type_info = new String[]{'AEName','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] Initials_type_info = new String[]{'Initials','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://stagews.XXXnet.com/enterpriseservices/absdataintegrationservices/salesforceservice','true','false'};
        private String[] field_order_type_info = new String[]{'AccountNumber','Password','Email','Address2','Fax','AEName','Initials'};
    }
    public class APIResponse {
        public Boolean Successful;
        public String Message;
        public String Code;
        private String[] Successful_type_info = new String[]{'Successful','http://www.w3.org/2001/XMLSchema','boolean','1','1','false'};
        private String[] Message_type_info = new String[]{'Message','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] Code_type_info = new String[]{'Code','http://stagews.XXXnet.com/enterpriseservices/absdataintegrationservices/salesforceservice','ReturnCodes','1','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://stagews.XXXnet.com/enterpriseservices/absdataintegrationservices/salesforceservice','true','false'};
        private String[] field_order_type_info = new String[]{'Successful','Message','Code'};
    }
    public class APIGetAccountResponse_element {
        public wsXXXnetComEnterpriseservicesAbsdata.APIGetAccountResult APIGetAccountResult;
        private String[] APIGetAccountResult_type_info = new String[]{'APIGetAccountResult','http://stagews.XXXnet.com/enterpriseservices/absdataintegrationservices/salesforceservice','APIGetAccountResult','0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://stagews.XXXnet.com/enterpriseservices/absdataintegrationservices/salesforceservice','true','false'};
        private String[] field_order_type_info = new String[]{'APIGetAccountResult'};
    }
    public class APIGetAccountResult {
        private String[] apex_schema_type_info = new String[]{'http://stagews.XXXnet.com/enterpriseservices/absdataintegrationservices/salesforceservice','true','false'};
        private String[] field_order_type_info = new String[]{};
    }
}

 Here is the callout class:

 

public class ABSCalloutClass  {

    public static void CallABSWS(Set<Id> idsn){
		list <Account> acctRecs;
		
     	system.debug('In call out class');
     	
         //Creating a List from a SOQL query using idsn
         // Need to add other fields once resolved.
          acctRecs  = 
            [SELECT acc.Id, acc.Name, acc.AccountNumber, acc.XXX_Password__c, acc.Industry,
                (SELECT con.LastName, con.FirstName
                    from Contacts con)          
            FROM Account acc  
            WHERE acc.ID in :Idsn];
            
     	//iterate thru the ids
    	system.debug('The size of acctrecs is ' + acctRecs.size());
    	
    	if (acctRecs.size() == 0)
        	return;  
   
    }   	  
	public void CallUpdateInvokeWebService(Account[] acctRecs) {
             
        for (Account Acct: acctRecs) {
        	
            system.debug('The name is ' + acct.name + ' the number is ' + acct.AccountNumber);
            
            If(trigger.isUpdate) {     
                //Create Instance of service call 
                 wsXXXnetComEnterpriseservicesAbsdata.APIExistingCustomer XXXCustomer = new
                 wsXXXnetComEnterpriseservicesAbsdata.APIExistingCustomer();

                 wsXXXnetComEnterpriseservicesAbsdata.APIResponse XXXAPIResponse = new
                 //wsXXXnetComEnterpriseservicesAbsdata.APIResponse();
                  wsXXXnetComEnterpriseservicesAbsdata.APIUpdateAccountResult();    
                   
                 XXXCustomer.AccountNumber = acct.AccountNumber;
                
                 XXXCustomer.Password=acct.XXX_Password__c; 
                 //Other fields being needed 
/*               
                Email;
                Address2;
                Fax;
                AEName;
                Initials;               
*/ 
                       
                 wsXXXnetComEnterpriseservicesAbsdata.SalesForceServiceSoap XXXNet = 
                 new wsXXXnetComEnterpriseservicesAbsdata.SalesForceServiceSoap();
                 
                system.debug('about to call update');
                
                  wsXXXnetComEnterpriseservicesAbsdata.APIUpdateAccountResult result = 
                 XXXNet.APIUpdateAccount(XXXCustomer);
                 
                 system.debug('back from call update');
            } // If trigger upadte    
        }   //For loop	
	}	
//*	
	@future(callout=true)
	public static void APIParseResponse(APIUpdateAccountResult XXXAPIResponse){ 

        Boolean XXXRespSuccessful;
        String XXXRespMessage;
        String XXXRespCode;

                 //Parse XXXAPIResponse
                XXXRespSuccessful = XXXAPIResponse.Successful;
                XXXRespMessage = XXXAPIResponse.Message;
                XXXRespCode = XXXAPIResponse.Code;
                 
                system.debug('the bool is  '+ XXXRespSuccessful);
                system.debug('the message is ' + XXXRespMessage);
                system.debug('the code is ' + XXXRespCode);

	}
//*/
}

Any help will be greatly appreciated.

Thank you.

  • September 07, 2011
  • Like
  • 0

Hi,

 

I have a trigger which I and the user have tested in the Sandbox. 

 

I also have a test class for it and it passes that.

 

It is failing on deployment and I believe i have tracked it to once statement but cannot see issue:

 

Here is the trigger:

 

trigger TerrZipAdd on Territory_ZIP_Code__c (after insert, after update) {
	
    User mrOpen = [select id,name from User where name=:RequestOwnershipService.MR_OPEN_NAME]; 
    AccountShare[] newShares = new AccountShare[0];   

	set<ID> idsn = Trigger.newmap.keySet();
	list<Territory_Zip_Code__c> tzcRecsn = [SELECT Id, Name, GroupId__c, SharingMode__c FROM Territory_Zip_Code__c WHERE ID in :idsn];
	for (Territory_Zip_Code__c tzcn: tzcRecsn) {
  
    //JJB Blackiron 8-2011 Per Brian he wanted the hard exclusion of the 3 profiles        
    //for(Territory_Zip_Code__c tzcn : Trigger.new) {  
        List<Account> AccountZipRecs =
            [SELECT id,  OwnerId
            FROM Account  
            //WHERE BillingPostalCode = :tzcn.Name];
            WHERE BillingPostalCode = :tzcn.Name 
            and Owner.ProfileId  not in 
			('00e30000000mIYBAA2', '00e700000017F9PAAU', '00e50000000nDWbAAM')];
            
        Group gr;
        if(tzcn.GroupId__c != null) { 
            try {
                system.debug('about to try name match');
                gr = [Select id from Group where Name = :tzcn.GroupID__c];
            }
            catch (Exception ex) {
                   system.debug('about to try id');
 	            try
	            {
	                gr = [Select Id, Name from Group where Id = :tzcn.GroupID__c];
	            }
	            catch (Exception ex1) {
	            }   
            } 
        } 
        system.debug('the group id is ' + gr.id);                 
        if(gr.id != null) {
	       // We have our list of accounts affected; now add shares for the new group ID
			
			for (Account accshare: AccountZipRecs)
			{
		    	// Set the access level
		        string accountAccessLevel = null;
		        string opportunityAccessLevel = null;
		        Boolean fullAccess = false; 
	                
		        if(accshare.ownerId == mrOpen.id)
		        	fullAccess = true;
	                // SharingMode can have 3 values: null, 'Default', 'Telesales'
	                if(tzcn.SharingMode__c == 'Telesales')
	                {
	                    accountAccessLevel = 'Edit';
	                    opportunityAccessLevel = 'None';
	                }
	                else
	                {
	                   accountAccessLevel = fullAccess ? 'Edit' : 'Read';
	                   opportunityAccessLevel = fullAccess ? 'Read' : 'None';
	                }
	                // Create new share
	                AccountShare newShare = new AccountShare();
	                newShare.UserOrGroupId = gr.id;
	                newShare.AccountId = accshare.id;
	                newShare.AccountAccessLevel = accountAccessLevel;
	                newShare.OpportunityAccessLevel = opportunityAccessLevel;
	                // Copy the share
	                newShares.add(newShare);
		                
	        }  //For loop bracket  
	    }    // If gr.id !null 
    }
     
    // Anything to insert?
    if (newShares.size() == 0)
        return;
 
    // Insert safely
    try
    {
        Database.SaveResult[] results = Database.insert(newShares, false);
        
        for (Database.SaveResult sr : results)
        {
            if (sr.isSuccess())
                continue;
            for (Database.Error edb : sr.getErrors())
 	           System.debug('-->     sr: ' + edb.getMessage());
            }
    }
    catch (DmlException edb) {
    }     
}

 

 

 Now in trying to see what was wrong I commented the lower half of the trigger where I go through the for loop and do insert out and it passed validation, so it would seem the top portion is okay. 

 

It seems it does like the for statement:

for (Account accshare: AccountZipRecs)

 

any help greatly appreciated, I would like to be able tp get the deploayed.

  • August 26, 2011
  • Like
  • 0

Hi,

 

I am trying to be mindful of trigger limits but I am having difficulty getting something working.

 

I am creating a list of the Territory Zip recs I need and then I need to find all accounts with that ip code.. The Territory list is fine.  How can I build the account list without putting it into the for loop? Below is what I am trying for Accoint and neither seems to be correct. 

 

set<ID> ids = Trigger.oldMap.keyset();

list<Territory_Zip_Code__c> tzcRecs = [SELECT Id, Name, GroupId__c FROM Territory_Zip_Code__c WHEREID in :ids]; 

 

//list<Account> AccountZipRecs = [SELECT id, BillingPostalCode FROM Account WHERE BillingPostalCode in :tzcRecs.Name ];

 

list<Account> AccountZipRecs = [SELECT id, BillingPostalCode FROMAccountWHERE BillingPostalCode in tzcRecs.Name ];

 

Any help appreciated,

  • August 24, 2011
  • Like
  • 0

Hi,

 

I have a pageblock table with some rows displayed.  The user logged on picks one of the rows and I need the id which is a hidden column returned to my class. 

 

This is what I have on the pageblocktable for this using the command link with a Param, what I get back is the id from the first row no matter which row I click on. 

 <apex:column headerValue="Sel"> 
      <apex:commandLink action="{!assign}" value="Sel"> >  
        <apex:param name="tobeassignid" value="{!pitem.userdata.id}" assignTo="{!AssignID}" /> 
       </apex:commandLink> 
</apex:column> 

 Any help greatly appreciated. Thank you.

 

  • August 18, 2011
  • Like
  • 0

Hi,

 

I thought I had this working but I found I do not.  I am trying to return the ID of the record selected in a block table I have on a VF page.   As the code is right now, what I get back is the ID of the first record in my blocktable.  I have 3 records returned to my blocktable and when I select the first or third record I get the same id returned in the Assign routine.

 

Here is the page code:

<apex:page controller="TeleReassign">
<apex:pageMessages />
<apex:form >
    <apex:pageBlock title="ThomasNet - Telemarketers Re-Assign of New Accounts">
        <apex:pageBlockTable value="{!users}" var="pitem" styleClass="data" rowClasses="rowOdd,rowEven">

        <apex:column headerValue="Sel"> 
            <apex:commandLink action="{!assign}" value="Sel"> </apex:commandLink>  
                        <apex:param name="tobeassignid" value="{!pitem.userdata.id}" assignTo="{!AssignID}" />  
                        <input type="hidden" name="tobeassignid" value="{!pitem.userdata.id}"/>
        </apex:column> 
        <apex:column rendered="false" headerValue="id"> <apex:outputText value="{!pitem.userdata.Id}" /> </apex:column>         
        <apex:column headerValue="Name"> <apex:outputText value="{!pitem.userdata.Name}" /> </apex:column> 
        <apex:column headerValue="Email"> <apex:outputText value="{!pitem.userdata.email}" /> </apex:column>
        <apex:column headerValue="Phone"> <apex:outputText value="{!pitem.userdata.phone}" /> </apex:column>
        <apex:column headerValue="Territory"> <apex:outputText value="{!pitem.userdata.Territory__c}" /> </apex:column> 
        </apex:pageBlockTable> 
    </apex:pageBlock>
</apex:form> 
</apex:page>

 

Here is the class code

 

public class TeleReassign {
    public string Acctid;
    public integer AccountOwn;
    public string UserTerr; 
    private String retURL = '/home/home.jsp';

    
   public String AssignID {get; set; }
   public String SelectedID {get; set; }

public TeleReassign() {

     if(ApexPages.currentPage().getParameters().containsKey('id')) {
       Acctid = ApexPages.currentPage().getParameters().get('id');
       retURL = '/' + Acctid;
       system.debug('The acct id ' + Acctid);
       
       try {
             AccountOwn = [SELECT Count() from Account where ownerid = :UserInfo.getUserId()];
             system.debug('the account owner count ' + AccountOwn ); 
             if(AccountOwn == 0) 
                 ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'To Re-Assign an Account you must own it.'));
                 return;  
           }
        catch (Exception ex) {
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'To Re-Assign an Account you must own it.'));
            return;
        } 
    }
}    
    public Territory_Limit__c tl {get; set;}
    public User us {get; set;}

public PageReference assign() {

    integer lengthOwned; 
    Integer numberOfAccounts;
    SelectedID = ApexPages.currentPage().getParameters().get('tobeassignid');

    system.debug(' the assignid is ' + SelectedID );
   try {
         tl = [Select Id, Account_Limit__c, Number_of_Days_Owned__c from Territory_Limit__c where territory__c = :UserTerr ];
         system.debug('the limit is ' + tl.Account_Limit__c); 
       }
    catch (Exception ex) {
        ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'The current user has no Territory limit record.'));
        return null;
    } 
 
    try {
        //numberOfAccounts = [Select count() from Account where OwnerId = :UserInfo.getUserId() and Do_Not_Count_towards_Limits__c != true and Type = 'Prospect'];
        //Get Reps number of accounts owned  
        numberOfAccounts = [Select count() from Account where OwnerId = :SelectedID  and Do_Not_Count_towards_Limits__c != true and Type = 'Prospect'];
         system.debug('The number of accounts is' + numberOfAccounts );
        lengthOwned = tl.Number_of_Days_Owned__c.Intvalue();       
        }
    catch (Exception ex) {
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Problem getting users ownership Quota.'));
            return null;
    }  
     
    Double RepAcctLimit = 0; 
    if(tl.Account_Limit__c <> null)
        RepAcctLimit = tl.Account_Limit__c; 

      if(numberOfAccounts <= RepAcctLimit + 10 ) { 
        system.debug('just before user query');
        User us2 = [Select Id from User where Id = :SelectedID ];
        system.debug('just before acct query');

        Account a = [Select Id, OwnerId from Account where Id = :Acctid];
        system.debug('after acct query');
        //NOTE: Update to owner done seperately from revert Date so it does not fire 
        //the Opportunity creation functinality  JJB Blackiron 8-2011
        a.OwnerId = us2.Id; 
        update a;
        //DO Not combine with above JJB Blackiron 8-2011
        a.Admin_Open_Revert_Date__c=Date.today().addDays(lengthOwned); 
        update a;
        ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.INFO, 'The account has been re-assigned.'));
        return null;
    }
    Else {
        ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'This Rep is at or above their limit.'));
        return null;
    }
} 
// Field to hold and list Userlist and class to hold data DisplayReps
public DisplayReps[] userlist {get; set;}

    public class DisplayReps {
    public User userdata {get; set; }
    public DisplayReps(User userrec) {
    this.userdata = userrec;
    }
}
//Method getusers to initialize the userlist
public DisplayReps[] getUsers() {

    if(AccountOwn >= 1) {
          
        if (userlist == null) {
            Territory_Limit__c tl;
            User u;
            //Added try catch code with an error message so accounts with no territory (our account) don't show an soql error. cbarisic
            try {
                system.debug('the user id is ' + UserInfo.getUserId());
                u = [Select Id, Territory__c from User where Id = :UserInfo.getUserId()];
                system.debug('the terr is ' + u.Territory__c);
                UserTerr = u.Territory__c;
    
            }
            catch (Exception ex) {
                ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'The current user has no territory.'));
                return null;
            }
             system.debug('the territory is ' + u.Territory__c);
            userlist = new DisplayReps[]{};
            for (User userrec: 
                [SELECT id, Name, email, phone, Territory__c, Ownership_quota__c 
                FROM User 
                WHERE Territory__c = :u.Territory__c and IsActive = true and Is_Telemarket_Rep__c = false])  {
                userlist.add(new DisplayReps(userrec));
            }
        }
    }
    return userlist; 
    }
}

 

Any help greatly appreciated.

 

  • August 17, 2011
  • Like
  • 0

Hi,

 

I am trying to watch the spring 12 training modules and getting error saying it is not available.

Here is the link:

http://salesforce.adobeconnect.com/spring12forcedotcom/ 

 

Any help appreciated.

  • March 26, 2012
  • Like
  • 0

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.

  • October 20, 2011
  • Like
  • 0

I am considering taking the Dev401 class but trying to decide on trip.  Staying at suggested hotels near the venue is usually more expensive then staying a little further out.   However sometimes staying at the suggested hotels allows for networking about the class and working on things at night can be good as well.

 

I am looking for feedback from others who have attended; could you please share your thougts on this. 

 

Thanks for the input

  • September 22, 2011
  • Like
  • 0

I have a trigger that is calling an @future to avoid hitting both SOQL limits and script limits.  It workis fine when you go into the account and make the change manually but not when run for a batch. 

 

Here is the trigger:

 

trigger ZipAcctChangeShare on Account (before update)  {

 	set<id> idso = new set<id>();
 	set<string> zipso = new set<string>();
	For(Account acc :trigger.old)
	{
		//Only send id's for those accounts with zip changes
		//system.debug('the old id trigger.oldMap.get(Acc.Id) is  ' + trigger.oldMap.get(Acc.Id));
		//system.debug('the new id trigger.newMap.get(Acc.Id) is ' + trigger.newMap.get(Acc.Id) + ' the acc.dd is ' + acc.id);
		//If (trigger.newMap.get(Acc.Id).BillingPostalCode != Acc.BillingPostalCode)
		If (trigger.newMap.get(Acc.Id).BillingPostalCode != Acc.BillingPostalCode)
		{ 
			idso.add(Acc.Id);
			zipso.add(Acc.BillingPostalCode);
		}
	}

	//system.debug('the size of idso is ' + idso.size());
	if(idso.size() > 0 && zipso.Size() > 0)
    	ProcessZipChangeOnAcct.ChangeShare(idso,zipso);
}

 

Here is the @future

 

public class ProcessZipChangeOnAcct {
@Future
    public static void ChangeShare(Set<Id> idso, Set<String> zipso) {
 	
 		//Build list of old zip code needed 
	 	list<Account> zipsrecs = [SELECT id, BillingPostalCode from Account WHERE id in :idso]; 
		
		//Get All territory zip records for zip codes from above
		List<Territory_Zip_Code__c> tc = new List<Territory_Zip_Code__c>();
		For(List< Territory_Zip_Code__c> t: [SELECT id, GroupId__c, name FROM Territory_Zip_Code__c WHERE Name in :zipso])
	                Tc.addall(t);
	              
		//List to hold account share to be deleted
		List<AccountShare> tbdACCShList = New List<AccountShare>();
	
		//get list of AccountShares that have an ID matching the Account ID’s in the set
		List<AccountShare> lAS = [Select id, AccountID, UserOrGroupID From AccountShare WHERE AccountID in : idso];
		
		For(Account acc :zipsrecs)
		{
           for (Territory_Zip_Code__c tzc: tc)
           { 
 	       	for (AccountShare Ashare :lAS) 
	        {	
			    if(Ashare.accountid == Acc.id && AShare.UserOrGroupId == tzc.GroupID__c) 
			 	 	tbdACCShList.add(Ashare);

			}   //for (AccountShare Ashare :lAS)
           }    //For Terr_Zip 
	    }  //For Account 
	      
	   	//If we have records to be deleted, delete the records    
	   	//system.debug('the size of the delete list is ' + tbdACCShList.size());       	 
		If(tbdACCShList.size() > 0)
		{
			try
			{
				Delete tbdACCShList;
			}
			catch (Exception e) {
			}
		}
    }
}

 Thank you for any assitance

  • September 15, 2011
  • Like
  • 0

I am trying to call the webservice and getting the following error:

First error: Web service callout failed: WebService returned a SOAP Fault: Server did not recognize the value of HTTP Header SOAPAction: 

 

Here is the apex from the wsdl:

public class wsEdrnetComEnterpriseservicesAbsdata {
    public class APIGetAccount_element {
        private String[] apex_schema_type_info = new String[]{'http://stagews.edrnet.com/enterpriseservices/absdataintegrationservices/salesforceservice','true','false'};
        private String[] field_order_type_info = new String[]{};
    }
    public class APIUpdateAccount_element {
        public wsEdrnetComEnterpriseservicesAbsdata.APIExistingCustomer existingCustomer;
        private String[] existingCustomer_type_info = new String[]{'existingCustomer','http://Stagews.edrnet.com/enterpriseservices/absdataintegrationservices/salesforceservice','APIExistingCustomer','0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://Stagews.edrnet.com/enterpriseservices/absdataintegrationservices/salesforceservice','true','false'};
        private String[] field_order_type_info = new String[]{'existingCustomer'};
    }
    public class APIUpdateAccountResult {
        private String[] apex_schema_type_info = new String[]{'http://Stagews.edrnet.com/enterpriseservices/absdataintegrationservices/salesforceservice','true','false'};
        private String[] field_order_type_info = new String[]{};
    }
    public class APIAddNewAccountResponse_element {
        public wsEdrnetComEnterpriseservicesAbsdata.APIAddNewAccountResult APIAddNewAccountResult;
        private String[] APIAddNewAccountResult_type_info = new String[]{'APIAddNewAccountResult','http://stagews.edrnet.com/enterpriseservices/absdataintegrationservices/salesforceservice','APIAddNewAccountResult','0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://stagews.edrnet.com/enterpriseservices/absdataintegrationservices/salesforceservice','true','false'};
        private String[] field_order_type_info = new String[]{'APIAddNewAccountResult'};
    }
    public class APINewCustomer {
        public String CompanyName;
        public String ContactFirstName;
        public String ContactLastName;
        public String Address1;
        public String City;
        public String State;
        public String ZipCode;
        public String Country;
        public String Phone;
        public String Industry;
        private String[] CompanyName_type_info = new String[]{'CompanyName','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] ContactFirstName_type_info = new String[]{'ContactFirstName','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] ContactLastName_type_info = new String[]{'ContactLastName','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] Address1_type_info = new String[]{'Address1','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] City_type_info = new String[]{'City','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] State_type_info = new String[]{'State','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] ZipCode_type_info = new String[]{'ZipCode','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] Country_type_info = new String[]{'Country','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] Phone_type_info = new String[]{'Phone','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] Industry_type_info = new String[]{'Industry','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://stagews.edrnet.com/enterpriseservices/absdataintegrationservices/salesforceservice','true','false'};
        private String[] field_order_type_info = new String[]{'CompanyName','ContactFirstName','ContactLastName','Address1','City','State','ZipCode','Country','Phone','Industry'};
    }
    public class SalesForceServiceSoap {
        public String endpoint_x = 'http://stagews.edrnet.com/enterpriseservices/absdataintegrationservices/salesforceservice.asmx';
        public Map<String,String> inputHttpHeaders_x;
        public Map<String,String> outputHttpHeaders_x;
        public String clientCertName_x;
        public String clientCert_x;
        public String clientCertPasswd_x;
        public Integer timeout_x;
        private String[] ns_map_type_info = new String[]{'http://stagews.edrnet.com/enterpriseservices/absdataintegrationservices/salesforceservice', 'wsEdrnetComEnterpriseservicesAbsdata'};
        public wsEdrnetComEnterpriseservicesAbsdata.APIUpdateAccountResult APIUpdateAccount(wsEdrnetComEnterpriseservicesAbsdata.APIExistingCustomer existingCustomer) {
            wsEdrnetComEnterpriseservicesAbsdata.APIUpdateAccount_element request_x = new wsEdrnetComEnterpriseservicesAbsdata.APIUpdateAccount_element();
            wsEdrnetComEnterpriseservicesAbsdata.APIUpdateAccountResponse_element response_x;
            request_x.existingCustomer = existingCustomer;
            Map<String, wsEdrnetComEnterpriseservicesAbsdata.APIUpdateAccountResponse_element> response_map_x = new Map<String, wsEdrnetComEnterpriseservicesAbsdata.APIUpdateAccountResponse_element>();
            response_map_x.put('response_x', response_x);
            WebServiceCallout.invoke(
              this,
              request_x,
              response_map_x,
              new String[]{endpoint_x, 
              //For testing the http is http://Stagews.edrnet	
              //For production the http is http://ws.edrnet
              'http://Stagews.edrnet.com/enterpriseservices/absdataintegrationservices/salesforceservice/APIUpdateAccount',
              'http://Stagews.edrnet.com/enterpriseservices/absdataintegrationservices/salesforceservice',
              'APIUpdateAccount',
              'http://Stagews.edrnet.com/enterpriseservices/absdataintegrationservices/salesforceservice',
              'APIUpdateAccountResponse',
              'wsEdrnetComEnterpriseservicesAbsdata.APIUpdateAccountResponse_element'}
            );
            response_x = response_map_x.get('response_x');
            return response_x.APIUpdateAccountResult;
        }
        public wsEdrnetComEnterpriseservicesAbsdata.APIAddNewAccountResult APIAddNewAccount(wsEdrnetComEnterpriseservicesAbsdata.APINewCustomer newCustomer) {
            wsEdrnetComEnterpriseservicesAbsdata.APIAddNewAccount_element request_x = new wsEdrnetComEnterpriseservicesAbsdata.APIAddNewAccount_element();
            wsEdrnetComEnterpriseservicesAbsdata.APIAddNewAccountResponse_element response_x;
            request_x.newCustomer = newCustomer;
            Map<String, wsEdrnetComEnterpriseservicesAbsdata.APIAddNewAccountResponse_element> response_map_x = new Map<String, wsEdrnetComEnterpriseservicesAbsdata.APIAddNewAccountResponse_element>();
            response_map_x.put('response_x', response_x);
            WebServiceCallout.invoke(
              this,
              request_x,
              response_map_x,
              new String[]{endpoint_x,
              'http://stagews.edrnet.com/enterpriseservices/absdataintegrationservices/salesforceservice/APIAddNewAccount',
              'http://stagews.edrnet.com/enterpriseservices/absdataintegrationservices/salesforceservice',
              'APIAddNewAccount',
              'http://stagews.edrnet.com/enterpriseservices/absdataintegrationservices/salesforceservice',
              'APIAddNewAccountResponse',
              'wsEdrnetComEnterpriseservicesAbsdata.APIAddNewAccountResponse_element'}
            );
            response_x = response_map_x.get('response_x');
            return response_x.APIAddNewAccountResult;
        }
        public wsEdrnetComEnterpriseservicesAbsdata.APIGetAccountResult APIGetAccount() {
            wsEdrnetComEnterpriseservicesAbsdata.APIGetAccount_element request_x = new wsEdrnetComEnterpriseservicesAbsdata.APIGetAccount_element();
            wsEdrnetComEnterpriseservicesAbsdata.APIGetAccountResponse_element response_x;
            Map<String, wsEdrnetComEnterpriseservicesAbsdata.APIGetAccountResponse_element> response_map_x = new Map<String, wsEdrnetComEnterpriseservicesAbsdata.APIGetAccountResponse_element>();
            response_map_x.put('response_x', response_x);
            WebServiceCallout.invoke(
              this,
              request_x,
              response_map_x,
              new String[]{endpoint_x,
              'http://stagews.edrnet.com/enterpriseservices/absdataintegrationservices/salesforceservice/APIGetAccount',
              'http://stagews.edrnet.com/enterpriseservices/absdataintegrationservices/salesforceservice',
              'APIGetAccount',
              'http://stagews.edrnet.com/enterpriseservices/absdataintegrationservices/salesforceservice',
              'APIGetAccountResponse',
              'wsEdrnetComEnterpriseservicesAbsdata.APIGetAccountResponse_element'}
            );
            response_x = response_map_x.get('response_x');
            return response_x.APIGetAccountResult;
        }
    }
    public class APIAddNewAccount_element {
        public wsEdrnetComEnterpriseservicesAbsdata.APINewCustomer newCustomer;
        private String[] newCustomer_type_info = new String[]{'newCustomer','http://stagews.edrnet.com/enterpriseservices/absdataintegrationservices/salesforceservice','APINewCustomer','0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://stagews.edrnet.com/enterpriseservices/absdataintegrationservices/salesforceservice','true','false'};
        private String[] field_order_type_info = new String[]{'newCustomer'};
    }
    public class APIAddNewAccountResult {
        private String[] apex_schema_type_info = new String[]{'http://stagews.edrnet.com/enterpriseservices/absdataintegrationservices/salesforceservice','true','false'};
        private String[] field_order_type_info = new String[]{};
    }
    public class APIUpdateAccountResponse_element {
        public wsEdrnetComEnterpriseservicesAbsdata.APIUpdateAccountResult APIUpdateAccountResult;
        private String[] APIUpdateAccountResult_type_info = new String[]{'APIUpdateAccountResult','http://stagews.edrnet.com/enterpriseservices/absdataintegrationservices/salesforceservice','APIUpdateAccountResult','0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://stagews.edrnet.com/enterpriseservices/absdataintegrationservices/salesforceservice','true','false'};
        private String[] field_order_type_info = new String[]{'APIUpdateAccountResult'};
    }
    public class APIExistingCustomer {
        public String AccountNumber;
        public String Password;
        public String Email;
        public String Address2;
        public String Fax;
        public String AEName;
        public String Initials;
        private String[] AccountNumber_type_info = new String[]{'AccountNumber','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] Password_type_info = new String[]{'Password','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] Email_type_info = new String[]{'Email','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] Address2_type_info = new String[]{'Address2','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] Fax_type_info = new String[]{'Fax','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] AEName_type_info = new String[]{'AEName','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] Initials_type_info = new String[]{'Initials','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://stagews.edrnet.com/enterpriseservices/absdataintegrationservices/salesforceservice','true','false'};
        private String[] field_order_type_info = new String[]{'AccountNumber','Password','Email','Address2','Fax','AEName','Initials'};
    }
    public class APIResponse {
        public Boolean Successful;
        public String Message;
        public String Code;
        private String[] Successful_type_info = new String[]{'Successful','http://www.w3.org/2001/XMLSchema','boolean','1','1','false'};
        private String[] Message_type_info = new String[]{'Message','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] Code_type_info = new String[]{'Code','http://stagews.edrnet.com/enterpriseservices/absdataintegrationservices/salesforceservice','ReturnCodes','1','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://stagews.edrnet.com/enterpriseservices/absdataintegrationservices/salesforceservice','true','false'};
        private String[] field_order_type_info = new String[]{'Successful','Message','Code'};
    }
    public class APIGetAccountResponse_element {
        public wsEdrnetComEnterpriseservicesAbsdata.APIGetAccountResult APIGetAccountResult;
        private String[] APIGetAccountResult_type_info = new String[]{'APIGetAccountResult','http://stagews.edrnet.com/enterpriseservices/absdataintegrationservices/salesforceservice','APIGetAccountResult','0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://stagews.edrnet.com/enterpriseservices/absdataintegrationservices/salesforceservice','true','false'};
        private String[] field_order_type_info = new String[]{'APIGetAccountResult'};
    }
    public class APIGetAccountResult {
        private String[] apex_schema_type_info = new String[]{'http://stagews.edrnet.com/enterpriseservices/absdataintegrationservices/salesforceservice','true','false'};
        private String[] field_order_type_info = new String[]{};
    }
}

 

Here is my class to call it:

public class ABSCalloutClass  {

    public static void CallABSWS(Set<Id> idsn){
		list <Account> acctRecs;
		string AccttoUpdateID;
		string ConFirstName;
		string ConLastName;
		string ConEmail;
		string AcctOwner;
		
         //Creating a List from a SOQL query using idsn
          acctRecs  = [SELECT acc.Id, acc.ownerid FROM Account acc WHERE acc.ID in :Idsn];
            
    	system.debug('The acctrecs is ' + acctRecs);
    	
    	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]);
		system.debug('map of owners ' + owners);
		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')]; 

		system.debug(' the contact list is ' + Contacts);
		
        //iterate thru the ids	
        for (Account Acct: acctRecs) {	
         	AccttoUpdateID = Acct.Id;
			If(owners.containskey(Acct.Ownerid))
				AcctOwner=owners.get(Acct.Ownerid).Name;
				
         	system.debug('the contacts are ' + Contacts);
         	for (AccountContactRole con: Contacts) { 
         		if (con.contact.AccountID == AccttoUpdateID) {
         			ConFirstName = Con.contact.Firstname;
         			ConLastName = Con.contact.Lastname;
         			ConEmail = Con.contact.Email;
         		}
         	}
         	system.debug('about to invoke call, the account is   ' + AccttoUpdateID + ' and the owner is ' + AcctOwner);
        	CallUpdateInvokeWebService(AccttoUpdateID, ConFirstName, ConLastName, ConEmail, AcctOwner);	
        }
    }  
    @future(callout=true)  	  
	public static void CallUpdateInvokeWebService(String AccttoUpdateID, String ConFirstName, String ConLastName, String ConEmail, string AcctOwner) {
	 	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];
   	
        system.debug('The name is ' + AccttoUpdate.name + ' the number is ' + AccttoUpdate.AccountNumber);
		
//        If(trigger.isUpdate) {     
            //Create Instance of service call 
        	wsEdrnetComEnterpriseservicesAbsdata.APIExistingCustomer edrCustomer = new
            wsEdrnetComEnterpriseservicesAbsdata.APIExistingCustomer();
            
        	wsEdrnetComEnterpriseservicesAbsdata.APINewCustomer edrNewCustomer = new
            wsEdrnetComEnterpriseservicesAbsdata.APINewCustomer();
            
            wsEdrnetComEnterpriseservicesAbsdata.APIResponse edrAPIResponse = new
            wsEdrnetComEnterpriseservicesAbsdata.APIResponse();
                   
            edrCustomer.AccountNumber = AccttoUpdate.AccountNumber;
            edrCustomer.Password=AccttoUpdate.EDR_Password__c; 
            edrNewCustomer.CompanyName = AccttoUpdate.Name; 
			edrNewCustomer.ContactFirstName=ConFirstName;
            
	        edrNewCustomer.ContactLastName = ConLastName;
        	edrNewCustomer.City = AccttoUpdate.BillingCity;
        	edrNewCustomer.State = AccttoUpdate.BillingState;
        	edrNewCustomer.ZipCode = AccttoUpdate.BillingPostalCode;
        	edrNewCustomer.Country = AccttoUpdate.BillingCountry;
        	edrNewCustomer.Phone = AccttoUpdate.Phone;
        	edrNewCustomer.Industry = AccttoUpdate.Industry;
        	edrCustomer.Email = ConEmail;
        	edrCustomer.Fax = AccttoUpdate.Fax;
        	edrCustomer.AEName=AcctOwner;
       		
       		//Split SF Street into 2 fields
       		List<string> address_parts = new List<String>();
			Address_parts=AccttoUpdate.BillingStreet.split('\n');

			If(address_parts.size()>=1)
			  edrNewCustomer.Address1=address_parts[0];
			  
			  system.debug('the address 1 is ' + edrNewCustomer.Address1); 
			  
			If(address_parts.size()>=2)
			  edrCustomer.Address2=address_parts[1];
			  
			  system.debug('the address 2 is ' + edrCustomer.Address2); 
			//If(address_parts.size()>=3)
			//Address3=address_parts[2];
       	
             wsEdrnetComEnterpriseservicesAbsdata.SalesForceServiceSoap edrNet = 
             new wsEdrnetComEnterpriseservicesAbsdata.SalesForceServiceSoap();
                 
             system.debug('about to call update');
               
             wsEdrnetComEnterpriseservicesAbsdata.APIUpdateAccountResult result = 
             edrNet.APIUpdateAccount(edrCustomer);
             system.debug('back from call update'); 
           
             
//        } // If trigger upadte    
	}	
}

 Thank you for time if you can help with this.

  • September 15, 2011
  • Like
  • 0

I have a trigger which caused above error during a bulk test by the user. 

 

So I am splitting into a trigger which will call a @future class.

 

I pass the id's for the trigger.old and trigger.new to the class but when I get the account values using the Id's from trigger old; it already has the new value. 

 

Here is the trigger:

trigger ZipAcctChangeShare on Account (after update)  {

 //   AccountShare[] newShares = new AccountShare[0];
    
    set<id> idsn = new set<id>();
    for (Account AcctRecs : trigger.new)
    {
        idsn.add(AcctRecs.Id);
        system.debug('in trigger the new postal code is ' + AcctRecs.BillingPostalCode + ' and the id is ' + AcctRecs.Id);
    }  
    //BUild Set of trigger old id's 
    set<id> idso = new set<id>();
    for (Account AcctRecsold : trigger.old)
    {
        idso.add(AcctRecsold.Id);
        system.debug('in trigger the old postal code is ' + AcctRecsold.BillingPostalCode + ' and the id is ' + AcctRecsold.Id);
    }  

    ProcessZipChangeOnAcct.ChangeShare(idsn, idso);
}

 

Now here is the class I created; I am testing it by commenting out the @future:

 

public class ProcessZipChangeOnAcct {
//@Future
     public static void ChangeShare(Set<Id> idsn, Set<Id> idso) {
 	
    AccountShare[] newShares = new AccountShare[0];

 	list<Account> zipsrecs = [SELECT BillingPostalCode from Account WHERE id in :idso]; 
	set<string> zipso = new set<string>();
	for (Account zr : zipsrecs)
    {
        zipso.add(zr.BillingPostalCode);
     }
	
	List<Territory_Zip_Code__c> tc = new List<Territory_Zip_Code__c>();
	For(List< Territory_Zip_Code__c> t: [SELECT id, GroupId__c, name FROM Territory_Zip_Code__c WHERE Name in :zipso])
                Tc.addall(t);
                
	Map<id,Account> acctold = new Map<id,Account>([SELECT ID, BillingPostalCode from Account WHERE id in :idso]);	   
	system.debug('the acct old map is ' + acctold); 
	
    list<Account> AcctRecs = [SELECT Id, BillingPostalCode FROM Account WHERE ID in :idsn]; 
    system.debug('the New list is ' +AcctRecs); 
    
	//List of account share to be deleted
	List<AccountShare> tbdACCShList = New List<AccountShare>();

	//get list of AccountShares that have an ID matching the Account ID’s in the set
	List<AccountShare> lAS = [Select id, AccountID, UserOrGroupID From AccountShare WHERE AccountID in : idsn];
	
	//system.debug('the list is ' + las); 
	
	For(Account acc :AcctRecs)
	{
	//system.debug('the acc  ' + acc); 
		//If (trigger.oldMap.get(Acc.Id).BillingPostalCode != Acc.BillingPostalCode) {
        If (acctold.get(Acc.id).BillingPostalCode != Acc.BillingPostalCode) {    
           for (Territory_Zip_Code__c tzc: tc) { 
	           	 //if (tzc.name == Trigger.oldMap.get(Acc.Id).BillingPostalCode) 
	           	 if (tzc.name == acctold.get(Acc.Id).BillingPostalCode) 
	           	 {
	           	     for (AccountShare Ashare :lAS) 
	           	     {	
					    // system.debug('the las  list is ' + las); 
					     if(Ashare.accountid == Acc.id && AShare.UserOrGroupId == tzc.GroupID__c) 
					     {
					   	 	//system.debug('inside ashare ');
							tbdACCShList.add(Ashare);
							//system.debug('the to be deleted ' + tbdACCShList );
					     }	
					}   //for (AccountShare Ashare :lAS)
	           	 }	  //(tzc.name == 
           	 }    //For Terr_Zip 
        }   //If trigger old              

    }  //For Account 
      
      
   	//If we have records to be deleted, delete the records    
   	system.debug('the size of the delete list is ' + tbdACCShList.size());       	 
	If(tbdACCShList.size() > 0)
	    Delete tbdACCShList;  
    	
    }
}

 Thank you for any assistace.

  • September 14, 2011
  • Like
  • 0

I am working on a callout to a webservice and I am getting an error structuring one of the methods.  The error is happening on this line:

               public static void APIParseResponse(APIUpdateAccountResult XXXAPIResponse) {

 

The error is:

Save error: Invalid type: APIUpdateAccountResult ABSCalloutClass.cls 

 

Here is the wsdl2apex: 

 

//Generated by wsdl2apex

//**********************************************
//BEFORE GOING LIVE CHANGE name from stagews. to ws. 
//**********************************************

public class wsXXXnetComEnterpriseservicesAbsdata {
    public class APIGetAccount_element {
        private String[] apex_schema_type_info = new String[]{'http://stagews.XXXnet.com/enterpriseservices/absdataintegrationservices/salesforceservice','true','false'};
        private String[] field_order_type_info = new String[]{};
    }
    public class APIUpdateAccount_element {
        public wsXXXnetComEnterpriseservicesAbsdata.APIExistingCustomer existingCustomer;
        private String[] existingCustomer_type_info = new String[]{'existingCustomer','http://Stagews.XXXnet.com/enterpriseservices/absdataintegrationservices/salesforceservice','APIExistingCustomer','0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://Stagews.XXXnet.com/enterpriseservices/absdataintegrationservices/salesforceservice','true','false'};
        private String[] field_order_type_info = new String[]{'existingCustomer'};
    }
    public class APIUpdateAccountResult {
        private String[] apex_schema_type_info = new String[]{'http://Stagews.XXXnet.com/enterpriseservices/absdataintegrationservices/salesforceservice','true','false'};
        private String[] field_order_type_info = new String[]{};
    }
    public class APIAddNewAccountResponse_element {
        public wsXXXnetComEnterpriseservicesAbsdata.APIAddNewAccountResult APIAddNewAccountResult;
        private String[] APIAddNewAccountResult_type_info = new String[]{'APIAddNewAccountResult','http://stagews.XXXnet.com/enterpriseservices/absdataintegrationservices/salesforceservice','APIAddNewAccountResult','0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://stagews.XXXnet.com/enterpriseservices/absdataintegrationservices/salesforceservice','true','false'};
        private String[] field_order_type_info = new String[]{'APIAddNewAccountResult'};
    }
    public class APINewCustomer {
        public String CompanyName;
        public String ContactFirstName;
        public String ContactLastName;
        public String Address1;
        public String City;
        public String State;
        public String ZipCode;
        public String Country;
        public String Phone;
        public String Industry;
        private String[] CompanyName_type_info = new String[]{'CompanyName','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] ContactFirstName_type_info = new String[]{'ContactFirstName','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] ContactLastName_type_info = new String[]{'ContactLastName','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] Address1_type_info = new String[]{'Address1','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] City_type_info = new String[]{'City','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] State_type_info = new String[]{'State','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] ZipCode_type_info = new String[]{'ZipCode','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] Country_type_info = new String[]{'Country','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] Phone_type_info = new String[]{'Phone','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] Industry_type_info = new String[]{'Industry','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://stagews.XXXnet.com/enterpriseservices/absdataintegrationservices/salesforceservice','true','false'};
        private String[] field_order_type_info = new String[]{'CompanyName','ContactFirstName','ContactLastName','Address1','City','State','ZipCode','Country','Phone','Industry'};
    }
    public class SalesForceServiceSoap {
        public String endpoint_x = 'http://stagews.XXXnet.com/enterpriseservices/absdataintegrationservices/salesforceservice.asmx';
        public Map<String,String> inputHttpHeaders_x;
        public Map<String,String> outputHttpHeaders_x;
        public String clientCertName_x;
        public String clientCert_x;
        public String clientCertPasswd_x;
        public Integer timeout_x;
        private String[] ns_map_type_info = new String[]{'http://stagews.XXXnet.com/enterpriseservices/absdataintegrationservices/salesforceservice', 'wsXXXnetComEnterpriseservicesAbsdata'};
        public wsXXXnetComEnterpriseservicesAbsdata.APIUpdateAccountResult APIUpdateAccount(wsXXXnetComEnterpriseservicesAbsdata.APIExistingCustomer existingCustomer) {
            wsXXXnetComEnterpriseservicesAbsdata.APIUpdateAccount_element request_x = new wsXXXnetComEnterpriseservicesAbsdata.APIUpdateAccount_element();
            wsXXXnetComEnterpriseservicesAbsdata.APIUpdateAccountResponse_element response_x;
            request_x.existingCustomer = existingCustomer;
            Map<String, wsXXXnetComEnterpriseservicesAbsdata.APIUpdateAccountResponse_element> response_map_x = new Map<String, wsXXXnetComEnterpriseservicesAbsdata.APIUpdateAccountResponse_element>();
            response_map_x.put('response_x', response_x);
            WebServiceCallout.invoke(
              this,
              request_x,
              response_map_x,
              new String[]{endpoint_x, 
              //For testing the http is http://Stagews.XXXnet	
              //For production the http is http://ws.XXXnet
              'http://Stagews.XXXnet.com/enterpriseservices/absdataintegrationservices/salesforceservice/APIUpdateAccount',
              'http://Stagews.XXXnet.com/enterpriseservices/absdataintegrationservices/salesforceservice',
              'APIUpdateAccount',
              'http://Stagews.XXXnet.com/enterpriseservices/absdataintegrationservices/salesforceservice',
              'APIUpdateAccountResponse',
              'wsXXXnetComEnterpriseservicesAbsdata.APIUpdateAccountResponse_element'}
            );
            response_x = response_map_x.get('response_x');
            return response_x.APIUpdateAccountResult;
        }
        public wsXXXnetComEnterpriseservicesAbsdata.APIAddNewAccountResult APIAddNewAccount(wsXXXnetComEnterpriseservicesAbsdata.APINewCustomer newCustomer) {
            wsXXXnetComEnterpriseservicesAbsdata.APIAddNewAccount_element request_x = new wsXXXnetComEnterpriseservicesAbsdata.APIAddNewAccount_element();
            wsXXXnetComEnterpriseservicesAbsdata.APIAddNewAccountResponse_element response_x;
            request_x.newCustomer = newCustomer;
            Map<String, wsXXXnetComEnterpriseservicesAbsdata.APIAddNewAccountResponse_element> response_map_x = new Map<String, wsXXXnetComEnterpriseservicesAbsdata.APIAddNewAccountResponse_element>();
            response_map_x.put('response_x', response_x);
            WebServiceCallout.invoke(
              this,
              request_x,
              response_map_x,
              new String[]{endpoint_x,
              'http://stagews.XXXnet.com/enterpriseservices/absdataintegrationservices/salesforceservice/APIAddNewAccount',
              'http://stagews.XXXnet.com/enterpriseservices/absdataintegrationservices/salesforceservice',
              'APIAddNewAccount',
              'http://stagews.XXXnet.com/enterpriseservices/absdataintegrationservices/salesforceservice',
              'APIAddNewAccountResponse',
              'wsXXXnetComEnterpriseservicesAbsdata.APIAddNewAccountResponse_element'}
            );
            response_x = response_map_x.get('response_x');
            return response_x.APIAddNewAccountResult;
        }
        public wsXXXnetComEnterpriseservicesAbsdata.APIGetAccountResult APIGetAccount() {
            wsXXXnetComEnterpriseservicesAbsdata.APIGetAccount_element request_x = new wsXXXnetComEnterpriseservicesAbsdata.APIGetAccount_element();
            wsXXXnetComEnterpriseservicesAbsdata.APIGetAccountResponse_element response_x;
            Map<String, wsXXXnetComEnterpriseservicesAbsdata.APIGetAccountResponse_element> response_map_x = new Map<String, wsXXXnetComEnterpriseservicesAbsdata.APIGetAccountResponse_element>();
            response_map_x.put('response_x', response_x);
            WebServiceCallout.invoke(
              this,
              request_x,
              response_map_x,
              new String[]{endpoint_x,
              'http://stagews.XXXnet.com/enterpriseservices/absdataintegrationservices/salesforceservice/APIGetAccount',
              'http://stagews.XXXnet.com/enterpriseservices/absdataintegrationservices/salesforceservice',
              'APIGetAccount',
              'http://stagews.XXXnet.com/enterpriseservices/absdataintegrationservices/salesforceservice',
              'APIGetAccountResponse',
              'wsXXXnetComEnterpriseservicesAbsdata.APIGetAccountResponse_element'}
            );
            response_x = response_map_x.get('response_x');
            return response_x.APIGetAccountResult;
        }
    }
    public class APIAddNewAccount_element {
        public wsXXXnetComEnterpriseservicesAbsdata.APINewCustomer newCustomer;
        private String[] newCustomer_type_info = new String[]{'newCustomer','http://stagews.XXXnet.com/enterpriseservices/absdataintegrationservices/salesforceservice','APINewCustomer','0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://stagews.XXXnet.com/enterpriseservices/absdataintegrationservices/salesforceservice','true','false'};
        private String[] field_order_type_info = new String[]{'newCustomer'};
    }
    public class APIAddNewAccountResult {
        private String[] apex_schema_type_info = new String[]{'http://stagews.XXXnet.com/enterpriseservices/absdataintegrationservices/salesforceservice','true','false'};
        private String[] field_order_type_info = new String[]{};
    }
    public class APIUpdateAccountResponse_element {
        public wsXXXnetComEnterpriseservicesAbsdata.APIUpdateAccountResult APIUpdateAccountResult;
        private String[] APIUpdateAccountResult_type_info = new String[]{'APIUpdateAccountResult','http://stagews.XXXnet.com/enterpriseservices/absdataintegrationservices/salesforceservice','APIUpdateAccountResult','0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://stagews.XXXnet.com/enterpriseservices/absdataintegrationservices/salesforceservice','true','false'};
        private String[] field_order_type_info = new String[]{'APIUpdateAccountResult'};
    }
    public class APIExistingCustomer {
        public String AccountNumber;
        public String Password;
        public String Email;
        public String Address2;
        public String Fax;
        public String AEName;
        public String Initials;
        private String[] AccountNumber_type_info = new String[]{'AccountNumber','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] Password_type_info = new String[]{'Password','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] Email_type_info = new String[]{'Email','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] Address2_type_info = new String[]{'Address2','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] Fax_type_info = new String[]{'Fax','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] AEName_type_info = new String[]{'AEName','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] Initials_type_info = new String[]{'Initials','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://stagews.XXXnet.com/enterpriseservices/absdataintegrationservices/salesforceservice','true','false'};
        private String[] field_order_type_info = new String[]{'AccountNumber','Password','Email','Address2','Fax','AEName','Initials'};
    }
    public class APIResponse {
        public Boolean Successful;
        public String Message;
        public String Code;
        private String[] Successful_type_info = new String[]{'Successful','http://www.w3.org/2001/XMLSchema','boolean','1','1','false'};
        private String[] Message_type_info = new String[]{'Message','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] Code_type_info = new String[]{'Code','http://stagews.XXXnet.com/enterpriseservices/absdataintegrationservices/salesforceservice','ReturnCodes','1','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://stagews.XXXnet.com/enterpriseservices/absdataintegrationservices/salesforceservice','true','false'};
        private String[] field_order_type_info = new String[]{'Successful','Message','Code'};
    }
    public class APIGetAccountResponse_element {
        public wsXXXnetComEnterpriseservicesAbsdata.APIGetAccountResult APIGetAccountResult;
        private String[] APIGetAccountResult_type_info = new String[]{'APIGetAccountResult','http://stagews.XXXnet.com/enterpriseservices/absdataintegrationservices/salesforceservice','APIGetAccountResult','0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://stagews.XXXnet.com/enterpriseservices/absdataintegrationservices/salesforceservice','true','false'};
        private String[] field_order_type_info = new String[]{'APIGetAccountResult'};
    }
    public class APIGetAccountResult {
        private String[] apex_schema_type_info = new String[]{'http://stagews.XXXnet.com/enterpriseservices/absdataintegrationservices/salesforceservice','true','false'};
        private String[] field_order_type_info = new String[]{};
    }
}

 Here is the callout class:

 

public class ABSCalloutClass  {

    public static void CallABSWS(Set<Id> idsn){
		list <Account> acctRecs;
		
     	system.debug('In call out class');
     	
         //Creating a List from a SOQL query using idsn
         // Need to add other fields once resolved.
          acctRecs  = 
            [SELECT acc.Id, acc.Name, acc.AccountNumber, acc.XXX_Password__c, acc.Industry,
                (SELECT con.LastName, con.FirstName
                    from Contacts con)          
            FROM Account acc  
            WHERE acc.ID in :Idsn];
            
     	//iterate thru the ids
    	system.debug('The size of acctrecs is ' + acctRecs.size());
    	
    	if (acctRecs.size() == 0)
        	return;  
   
    }   	  
	public void CallUpdateInvokeWebService(Account[] acctRecs) {
             
        for (Account Acct: acctRecs) {
        	
            system.debug('The name is ' + acct.name + ' the number is ' + acct.AccountNumber);
            
            If(trigger.isUpdate) {     
                //Create Instance of service call 
                 wsXXXnetComEnterpriseservicesAbsdata.APIExistingCustomer XXXCustomer = new
                 wsXXXnetComEnterpriseservicesAbsdata.APIExistingCustomer();

                 wsXXXnetComEnterpriseservicesAbsdata.APIResponse XXXAPIResponse = new
                 //wsXXXnetComEnterpriseservicesAbsdata.APIResponse();
                  wsXXXnetComEnterpriseservicesAbsdata.APIUpdateAccountResult();    
                   
                 XXXCustomer.AccountNumber = acct.AccountNumber;
                
                 XXXCustomer.Password=acct.XXX_Password__c; 
                 //Other fields being needed 
/*               
                Email;
                Address2;
                Fax;
                AEName;
                Initials;               
*/ 
                       
                 wsXXXnetComEnterpriseservicesAbsdata.SalesForceServiceSoap XXXNet = 
                 new wsXXXnetComEnterpriseservicesAbsdata.SalesForceServiceSoap();
                 
                system.debug('about to call update');
                
                  wsXXXnetComEnterpriseservicesAbsdata.APIUpdateAccountResult result = 
                 XXXNet.APIUpdateAccount(XXXCustomer);
                 
                 system.debug('back from call update');
            } // If trigger upadte    
        }   //For loop	
	}	
//*	
	@future(callout=true)
	public static void APIParseResponse(APIUpdateAccountResult XXXAPIResponse){ 

        Boolean XXXRespSuccessful;
        String XXXRespMessage;
        String XXXRespCode;

                 //Parse XXXAPIResponse
                XXXRespSuccessful = XXXAPIResponse.Successful;
                XXXRespMessage = XXXAPIResponse.Message;
                XXXRespCode = XXXAPIResponse.Code;
                 
                system.debug('the bool is  '+ XXXRespSuccessful);
                system.debug('the message is ' + XXXRespMessage);
                system.debug('the code is ' + XXXRespCode);

	}
//*/
}

Any help will be greatly appreciated.

Thank you.

  • September 07, 2011
  • Like
  • 0

Hi,

 

I am trying to be mindful of trigger limits but I am having difficulty getting something working.

 

I am creating a list of the Territory Zip recs I need and then I need to find all accounts with that ip code.. The Territory list is fine.  How can I build the account list without putting it into the for loop? Below is what I am trying for Accoint and neither seems to be correct. 

 

set<ID> ids = Trigger.oldMap.keyset();

list<Territory_Zip_Code__c> tzcRecs = [SELECT Id, Name, GroupId__c FROM Territory_Zip_Code__c WHEREID in :ids]; 

 

//list<Account> AccountZipRecs = [SELECT id, BillingPostalCode FROM Account WHERE BillingPostalCode in :tzcRecs.Name ];

 

list<Account> AccountZipRecs = [SELECT id, BillingPostalCode FROMAccountWHERE BillingPostalCode in tzcRecs.Name ];

 

Any help appreciated,

  • August 24, 2011
  • Like
  • 0

Hi,

 

I thought I had this working but I found I do not.  I am trying to return the ID of the record selected in a block table I have on a VF page.   As the code is right now, what I get back is the ID of the first record in my blocktable.  I have 3 records returned to my blocktable and when I select the first or third record I get the same id returned in the Assign routine.

 

Here is the page code:

<apex:page controller="TeleReassign">
<apex:pageMessages />
<apex:form >
    <apex:pageBlock title="ThomasNet - Telemarketers Re-Assign of New Accounts">
        <apex:pageBlockTable value="{!users}" var="pitem" styleClass="data" rowClasses="rowOdd,rowEven">

        <apex:column headerValue="Sel"> 
            <apex:commandLink action="{!assign}" value="Sel"> </apex:commandLink>  
                        <apex:param name="tobeassignid" value="{!pitem.userdata.id}" assignTo="{!AssignID}" />  
                        <input type="hidden" name="tobeassignid" value="{!pitem.userdata.id}"/>
        </apex:column> 
        <apex:column rendered="false" headerValue="id"> <apex:outputText value="{!pitem.userdata.Id}" /> </apex:column>         
        <apex:column headerValue="Name"> <apex:outputText value="{!pitem.userdata.Name}" /> </apex:column> 
        <apex:column headerValue="Email"> <apex:outputText value="{!pitem.userdata.email}" /> </apex:column>
        <apex:column headerValue="Phone"> <apex:outputText value="{!pitem.userdata.phone}" /> </apex:column>
        <apex:column headerValue="Territory"> <apex:outputText value="{!pitem.userdata.Territory__c}" /> </apex:column> 
        </apex:pageBlockTable> 
    </apex:pageBlock>
</apex:form> 
</apex:page>

 

Here is the class code

 

public class TeleReassign {
    public string Acctid;
    public integer AccountOwn;
    public string UserTerr; 
    private String retURL = '/home/home.jsp';

    
   public String AssignID {get; set; }
   public String SelectedID {get; set; }

public TeleReassign() {

     if(ApexPages.currentPage().getParameters().containsKey('id')) {
       Acctid = ApexPages.currentPage().getParameters().get('id');
       retURL = '/' + Acctid;
       system.debug('The acct id ' + Acctid);
       
       try {
             AccountOwn = [SELECT Count() from Account where ownerid = :UserInfo.getUserId()];
             system.debug('the account owner count ' + AccountOwn ); 
             if(AccountOwn == 0) 
                 ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'To Re-Assign an Account you must own it.'));
                 return;  
           }
        catch (Exception ex) {
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'To Re-Assign an Account you must own it.'));
            return;
        } 
    }
}    
    public Territory_Limit__c tl {get; set;}
    public User us {get; set;}

public PageReference assign() {

    integer lengthOwned; 
    Integer numberOfAccounts;
    SelectedID = ApexPages.currentPage().getParameters().get('tobeassignid');

    system.debug(' the assignid is ' + SelectedID );
   try {
         tl = [Select Id, Account_Limit__c, Number_of_Days_Owned__c from Territory_Limit__c where territory__c = :UserTerr ];
         system.debug('the limit is ' + tl.Account_Limit__c); 
       }
    catch (Exception ex) {
        ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'The current user has no Territory limit record.'));
        return null;
    } 
 
    try {
        //numberOfAccounts = [Select count() from Account where OwnerId = :UserInfo.getUserId() and Do_Not_Count_towards_Limits__c != true and Type = 'Prospect'];
        //Get Reps number of accounts owned  
        numberOfAccounts = [Select count() from Account where OwnerId = :SelectedID  and Do_Not_Count_towards_Limits__c != true and Type = 'Prospect'];
         system.debug('The number of accounts is' + numberOfAccounts );
        lengthOwned = tl.Number_of_Days_Owned__c.Intvalue();       
        }
    catch (Exception ex) {
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Problem getting users ownership Quota.'));
            return null;
    }  
     
    Double RepAcctLimit = 0; 
    if(tl.Account_Limit__c <> null)
        RepAcctLimit = tl.Account_Limit__c; 

      if(numberOfAccounts <= RepAcctLimit + 10 ) { 
        system.debug('just before user query');
        User us2 = [Select Id from User where Id = :SelectedID ];
        system.debug('just before acct query');

        Account a = [Select Id, OwnerId from Account where Id = :Acctid];
        system.debug('after acct query');
        //NOTE: Update to owner done seperately from revert Date so it does not fire 
        //the Opportunity creation functinality  JJB Blackiron 8-2011
        a.OwnerId = us2.Id; 
        update a;
        //DO Not combine with above JJB Blackiron 8-2011
        a.Admin_Open_Revert_Date__c=Date.today().addDays(lengthOwned); 
        update a;
        ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.INFO, 'The account has been re-assigned.'));
        return null;
    }
    Else {
        ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'This Rep is at or above their limit.'));
        return null;
    }
} 
// Field to hold and list Userlist and class to hold data DisplayReps
public DisplayReps[] userlist {get; set;}

    public class DisplayReps {
    public User userdata {get; set; }
    public DisplayReps(User userrec) {
    this.userdata = userrec;
    }
}
//Method getusers to initialize the userlist
public DisplayReps[] getUsers() {

    if(AccountOwn >= 1) {
          
        if (userlist == null) {
            Territory_Limit__c tl;
            User u;
            //Added try catch code with an error message so accounts with no territory (our account) don't show an soql error. cbarisic
            try {
                system.debug('the user id is ' + UserInfo.getUserId());
                u = [Select Id, Territory__c from User where Id = :UserInfo.getUserId()];
                system.debug('the terr is ' + u.Territory__c);
                UserTerr = u.Territory__c;
    
            }
            catch (Exception ex) {
                ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'The current user has no territory.'));
                return null;
            }
             system.debug('the territory is ' + u.Territory__c);
            userlist = new DisplayReps[]{};
            for (User userrec: 
                [SELECT id, Name, email, phone, Territory__c, Ownership_quota__c 
                FROM User 
                WHERE Territory__c = :u.Territory__c and IsActive = true and Is_Telemarket_Rep__c = false])  {
                userlist.add(new DisplayReps(userrec));
            }
        }
    }
    return userlist; 
    }
}

 

Any help greatly appreciated.

 

  • August 17, 2011
  • Like
  • 0

Hi,

 

I have a page that I have created but when I load it the table\pageblocks are appearing in the middle with lots of white space above it rather then at top.  

 

Here is the page code: 

<apex:page controller="SuggestOwner">
<apex:pageMessages />
    <apex:form >
         <div style="float:left">
         <TABLE BORDER="0" CELLPADDING="2" CELLSPACING="2" WIDTH="100%">
        <TR> 
         <TD>            
            <apex:iframe scrolling="false" id="accIframe" width="60%">
                <apex:pageBlock title="ThomasNet - Account">
                    <apex:pageBlockButtons >
                        <apex:commandButton action="{!Accept}" value="Accept"/>
                    </apex:pageBlockButtons>
                    <apex:pageBlockSection columns="1" collapsible="false" title="Account" showHeader="true">                   
                            <apex:outputField value="{!acctfields.Name}" />
                            <apex:outputField value="{!acctfields.BillingStreet}" />
                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="Billing City State Zip" />
                    <apex:outputLabel value="{!CityStZip}" />
                </apex:pageBlockSectionItem>
                            <apex:outputField value="{!acctfields.BillingCountry}" />
                </apex:pageBlockSection> 
            </apex:pageBlock>
            </apex:iframe>
            </TD>
         <TD>
            <apex:iframe scrolling="false" id="ownIframe" width="40%">
                <apex:pageBlock title="Suggested Owner">
                    <apex:pageBlockButtons >
                        <apex:commandButton action="{!Cancel}" value="Cancel"/>
                    </apex:pageBlockButtons>
                        <apex:pageBlockSection columns="1" collapsible="false" title="Suggested Owner" showHeader="true">                   
                            <apex:outputLabel value=" " />

                                <apex:outputLabel value="{!SuggestedOwnerName}" />
                    </apex:pageBlockSection> 
            </apex:pageBlock>
            </apex:iframe>
            </TD>
   </TR>
    </TABLE>            
        </div>
</apex:form> 
</apex:page

 

Thank you in advance for any assistance.

  • August 08, 2011
  • Like
  • 0