• vlacha
  • NEWBIE
  • 25 Points
  • Member since 2013

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 10
    Replies

All I am writing an Inbound Message Class to handle XML in the body of the e-mail. I am struggling with one error and I am not sure how to resolve it. Any assistance would be appreciated. Below is my class. My Error is on line 95. It is Method Does Not Exist or Incorrect Signature: getDecodedString(System.XMLStreamReader) I understand that it is missing an element before 'reader', btu honestly I am not sure what it should be.

 

/**
 * Email services are automated processes that use Apex classes
 * to process the contents, headers, and attachments of inbound
 * email.
 */
global class Email_CustomerRecord implements Messaging.InboundEmailHandler {

    global Messaging.InboundEmailResult handleInboundEmail(Messaging.InboundEmail email, Messaging.InboundEnvelope envelope) {
        Messaging.InboundEmailResult result = new Messaging.InboundEmailresult();
		
		List<Account> act1;
		try
		{
			String messageBody = '';
			String action = '';
			String cust_num = '';
			String name = '';
			String cust_seq = '';
			String addr1 = '';
			String addr2 = '';
			String addr3 = '';
			String addr4 = '';
			String city = '';
			String CusCounty = '';
			String state = '';
			String country = '';
			String zip = '';
			
			messageBody = email.plainTextBody;
			messageBody = messageBody.trim();
			
			messageBody = messageBody.substring(messageBody.indexof('<?xml version="1.0" encoding="UTF-8"?>'),messageBody.indexOf('</CustomerRecord>')+12);
			
			Action = readXMLelement(messageBody,'action');
			
			String cn = readXMLelement(messageBody,'cust_num');
			List<Account> actl = [SELECT Id, Customer_Number__c, Name, BillingStreet, BillingCity, BillingState, BillingPostalCode, BillingCountry
									  FROM Account 
									  WHERE Customer_Number__c =: cn
									  ];
			
			if(Action == 'add')
			{
				Account act = new Account();
				
				act.Customer_Number__c = readXMLelement(messageBody,'cust_num');
				act.Name = readXMLelement(messageBody,'name');
				act.BillingStreet = readXMLelement(messageBody,'addr1') + readXMLelement(messageBody,'addr2') + readXMLelement(messageBody,'addr3') + readXMLelement(messageBody,'addr4');
				act.BillingCity  = readXMLelement(messageBody,'city');
				act.BillingState  = readXMLelement(messageBody,'state');
				act.BillingPostalCode  = readXMLelement(messageBody,'zip');
				act.BillingCountry  = readXMLelement(messageBody,'country');
				
				insert act;
			}
			if(Action == 'modify')
			{
				for(Account actList : act1)
				{
					actList.Name = readXMLelement(messageBody,'name');
					actList.BillingStreet = readXMLelement(messageBody,'addr1') + readXMLelement(messageBody,'addr2') + readXMLelement(messageBody,'addr3') + readXMLelement(messageBody,'addr4');
					actList.BillingCity  = readXMLelement(messageBody,'city');
					actList.BillingState  = readXMLelement(messageBody,'state');
					actList.BillingPostalCode  = readXMLelement(messageBody,'zip');
					actList.BillingCountry  = readXMLelement(messageBody,'country');
				}
				
				update act1;					
			}
			if(Action == 'delete')
			{
				delete act1;
			}
		}
		catch(exception e)
		{
			
		}
		
        return result;
    }
    public static String readXMLelement(String xml, String element)
    {
        String elementValue = 'NOT FOUND'; 
        
        try
        {
	        Xmlstreamreader reader = new Xmlstreamreader(xml);
	        while (reader.hasNext()) 
	        {
	            if (reader.getEventType() == XmlTag.START_ELEMENT && reader.getLocalName() == element)
	            {
	                System.debug('Found SID');
	                reader.next();
	                elementValue = getDecodedString(reader); <---Error Method Does Not Exist or Incorrect Signature: getDecodedString(System.XMLStreamReader)
	            }         
	            reader.next();
	        }
	        return elementValue;
        }
        catch(exception e)
        {
			String err;
			err = e.getMessage();
			return err;
        }
    }
}

 Thank you for your assistance.

Hi!

 

I have developed a code to obtain a point coordinates making a call to Google maps API. I am using a trigger an a future method to do the call out. The problem is that few call outs after I obtain this error ' Over query limit'. In the API documentation I read 'The limit is 2500 calls for day). 

 

What is the problem?? I can understand why happen it. I only do a few call outs.

Ok, 

 

Almost cracked the nut but I have fallen short on the formula/work flow. 

 

Scope: 

Want to create a Quote PDF that shows an image of the main machine that is beign purchased. There are a total of 4 main machines. 

 

From my digging around I have come up with the following solution

In the Quotes

1. Create a pick list Machine Types with options A,B,C,D

2. Create a Custom field Text (Rich) called Image

3. Store all 4 product images in documents

4. Create a work flow (this is where I get stuck) When A,B,C or D are selected Change Field Images to the url of Image A,B,C,D

 

Effect: you select the machine type and the Image field auto changes the Image field with the image. When I create the PDF Quote I get a nice picture of the Machine selected. 

 

Am i barking mad or almost there? any help would be tops. 

 

 

Hello,

 

First time writing here so my apologies if I’m not as in depth / clear about my issue.

 

I’ve hit a brick wall with my formulas with my desired solution hitting its character limit. My work around was to involve a workflow rule that would complete a field update to determine if the "Commission cut-off date" exceeded the date of "Product added date"

 

I have the workflow rule created but i need it to evaluate the rule and run on a daily basis. Is it possible for me to use APEX or anything like that to automate a trigger for the workflow to run?

Any help would be greatly appreciated!!


Matt Tindall

Hi everyone , 

Im an apex noob,  and have just started a position in a company that uses salesforce for its CRM,  Unfortunately my predecessor left without handing over the salesforce reigns and I have been tasked with trying to change an email address in the code.  However when i change the address and try to reupload the code,  it goes to the sandbox without any problems,  however when it goes to the production server I get the message that there is a system Dml exception due to an inactive owner or user.  I have checked salesforce for the status of those that wrote the original code and they are all down as active ( despite being no longer with the company )..  The error seams to come in the testing code.

I would like to teach myself salesforce development however this one error is a giant brick wall to me. I have posted the code below,  can anybody give me some pointers in how to overcome this.

 

@isTest
private class vf_testing {

    static testMethod void myUnitTestofmultiple() {
        // TO DO: implement unit test
        caserefs igor = new caserefs();
        igor.caser='123';
        igor.poster='456';
     }
     
     static testMethod void testingextra_dates(){
     Account Fred = new Account(LastName='Flintstoned');
     insert Fred;
     ID whom=Fred.Id;
     Account kgm = new Account(Name='KGM');
     insert kgm;
     ID insurer=kgm.id;
     Opportunity Barney = new Opportunity(Name='Flintstoned', AccountId=whom, Insurer_prefix__c='KGM', Insurer__c=insurer, Case_referral_type__c='Unrecovered Theft', Business_Unit__c='Motor', Claim_Ref__c='430640', StageName='Claims Support', Date_of_Loss__c=date.today(), CloseDate=date.today());
     insert Barney;
     Opportunity rei =[select id, name, estimatediscovery__c, account.personmailingstreet, account.PersonMailingCity, account.personmailingstate, account.personmailingpostalcode, Insurer_prefix__c, insurer__c, Case_referral_type__c, Business_Unit__c, case_file_long_reference__c, StageName, Date_of_Loss__c, AccountId from opportunity where id=:barney.id];
     system.debug(rei.case_file_long_reference__c);
     ApexPages.StandardController pebbles=new ApexPages.StandardController(rei);
     extra_dates_opp bambam = new extra_dates_opp(pebbles);
     bambam.setappDriskAddr(false);
     bambam.setappDstreet('Street name');
     String name=bambam.getappDstreet();
     bambam.setappDcity('Street name');
     name=bambam.getappDcity();
     bambam.setappDcounty('Street name');
     name=bambam.getappDcounty();
     bambam.setappDpostcode('Street name');
     name=bambam.getappDpostcode();
     bambam.setappDuk('Street name');
     name=bambam.getappDuk();
     boolean isaddr=bambam.getappDriskaddr();
     bambam.setappDriskAddr(true);
     name=bambam.getappDstreet();
     name=bambam.getappDcity();
     name=bambam.getappDcounty();
     name=bambam.getappDpostcode();
     bambam.setappDstreet('Street name');
     bambam.setappDcity('Street name');
     bambam.setappDcounty('Street name');
     bambam.setappDpostcode('Street name');
     bambam.setappDcircs('Event');
     name=bambam.getappDcircs();
     name=bambam.getincidentwords();
     bambam.setincidentwords('incidentwords');
     name=bambam.getHTMLinfo();
     PageReference bexbex=bambam.PDFHH14();
     name=bambam.getapprox();
     name=bambam.getlongdate();
     name=bambam.getlossdate();
     bambam.nullme();
     PageReference nowhere=bambam.pdfme();
     name=bambam.getInsDial();
     name=bambam.getInsFormal();
     name=bambam.chooseInsName('EC');
     name=bambam.Choose0845('EC');
     name=bambam.chooseInsName('KG');
     name=bambam.Choose0845('KG');
     name=bambam.chooseInsName('MG');
     name=bambam.Choose0845('MG');
     name=bambam.chooseInsName('EI');
     name=bambam.Choose0845('EI');
     name=bambam.chooseInsName('CS');
     name=bambam.Choose0845('CS');
     name=bambam.chooseInsName('HS');
     name=bambam.Choose0845('HS');
     name=bambam.chooseInsName('RS');
     name=bambam.Choose0845('RS');
     name=bambam.chooseInsName('EQ');
     name=bambam.Choose0845('EQ');
     name=bambam.ChooseInsName('EM');
     name=bambam.Choose0845('EM');
     name=bambam.chooseInsName('HT');
     name=bambam.Choose0845('HT');
     name=bambam.Choose0845('EP');
     name=bambam.chooseInsName('XX');
     name=bambam.Choose0845('XX');
     name=bambam.gettype_of_incident();
     name=bambam.gettype_of_hhincident();
     name=bambam.incwords('MAD');
     name=bambam.incwords('SANE');
     name=bambam.hhincwords('HAL');
     name=bambam.hhincwords('HAD');
     name=bambam.hhincwords('HUM');
     }
     
     static testMethod void testingmulti_insert(){
     	Account Fred = new Account(LastName='Flintstoned');
     insert Fred;
     ID whom=Fred.Id;
     Account kgm = new Account(Name='KGM');
     insert kgm;
     ID insurer=kgm.id;
     Opportunity Barney = new Opportunity(Name='Flintstoned', AccountId=whom, Insurer_prefix__c='KGM', Insurer__c=insurer, Case_referral_type__c='Unrecovered Theft', Claim_Ref__c='430640', StageName='Claims Support', Date_of_Loss__c=date.today(), CloseDate=date.today());
     insert Barney;
     String caseref=Barney.Claim_Ref__c;
     system.debug(caseref);
     system.debug(Barney.Case_file_long_reference__c);
     	multi_insert pile=new multi_insert();
     	RecordTypeListCon types=new RecordTypeListCon();
     	types.sObjectType='Account';
     	List<SelectOption> screed=pile.gettypes();
     	screed=types.getItems();
     	pile.setSubject('Subjective');
     	String subj=pile.getSubject();
     	PageReference nowhere=pile.cancel();
     	boolean tick=pile.getDocreturns();
     	pile.setDocreturns(tick);
     	pile.addrow();
     	pile.removerow();
     	pile.cases[0].caser=caseref;
     	pile.cases[0].docser=true;
     	pile.docReturns=true;
     	pile.save();
     	pile.savepost();
     	pile.saveemail();
     	pile.clearout();
     	//Split here as the SOQL count is getting high.
     }
     
     static testMethod void testingmulti_insert2(){
     	Account Fred = new Account(LastName='Flintstoned');
     insert Fred;
     ID whom=Fred.Id;
     Account kgm = new Account(Name='KGM');
     insert kgm;
     ID insurer=kgm.id;
     Opportunity Barney = new Opportunity(Name='Flintstoned', AccountId=whom, Insurer_prefix__c='KGM', Insurer__c=insurer, Case_referral_type__c='Unrecovered Theft', Claim_Ref__c='430640', StageName='Claims Support', Date_of_Loss__c=date.today(), CloseDate=date.today());
     insert Barney;
     String caseref=Barney.Claim_Ref__c;
     system.debug(caseref);
     system.debug(Barney.Case_file_long_reference__c);
     	multi_insert pile=new multi_insert();
     	pile.cases[0].caser='bogus';
     	pile.save();
     	pile.cases[0].caser='430640';
     	pile.setSubject('Documents Received');
     	pile.save();
     	pile.outg();
     	pile.setSubject('1st Class Post');
     	pile.redticket=true;
     	pile.outg();
     	pile.setSubject('2nd Class Post');
     	pile.outg();
     	pile.setSubject('1st Class Packet');
     	pile.outg();
     	pile.numitems=1;
     	pile.totalcost=10.0;
     	pile.docReturns=true;
     	pile.outg();
     }
     
}

 It seams to bounce its issue against 

testingmulti_insert

                     SystemDmlException:Insert failed: First exception on row 1; first error:INACTIVE_OWNER_OR_USER. operation performed with inactive user.

                                                   Class.multi_insert.saveemail:line 176, column 1

 

Any help would be greatly and desperately appreciated

 

:)

 

Note : even if i change nothing and trying to send it back to the server I get the same error.

All I am writing an Inbound Message Class to handle XML in the body of the e-mail. I am struggling with one error and I am not sure how to resolve it. Any assistance would be appreciated. Below is my class. My Error is on line 95. It is Method Does Not Exist or Incorrect Signature: getDecodedString(System.XMLStreamReader) I understand that it is missing an element before 'reader', btu honestly I am not sure what it should be.

 

/**
 * Email services are automated processes that use Apex classes
 * to process the contents, headers, and attachments of inbound
 * email.
 */
global class Email_CustomerRecord implements Messaging.InboundEmailHandler {

    global Messaging.InboundEmailResult handleInboundEmail(Messaging.InboundEmail email, Messaging.InboundEnvelope envelope) {
        Messaging.InboundEmailResult result = new Messaging.InboundEmailresult();
		
		List<Account> act1;
		try
		{
			String messageBody = '';
			String action = '';
			String cust_num = '';
			String name = '';
			String cust_seq = '';
			String addr1 = '';
			String addr2 = '';
			String addr3 = '';
			String addr4 = '';
			String city = '';
			String CusCounty = '';
			String state = '';
			String country = '';
			String zip = '';
			
			messageBody = email.plainTextBody;
			messageBody = messageBody.trim();
			
			messageBody = messageBody.substring(messageBody.indexof('<?xml version="1.0" encoding="UTF-8"?>'),messageBody.indexOf('</CustomerRecord>')+12);
			
			Action = readXMLelement(messageBody,'action');
			
			String cn = readXMLelement(messageBody,'cust_num');
			List<Account> actl = [SELECT Id, Customer_Number__c, Name, BillingStreet, BillingCity, BillingState, BillingPostalCode, BillingCountry
									  FROM Account 
									  WHERE Customer_Number__c =: cn
									  ];
			
			if(Action == 'add')
			{
				Account act = new Account();
				
				act.Customer_Number__c = readXMLelement(messageBody,'cust_num');
				act.Name = readXMLelement(messageBody,'name');
				act.BillingStreet = readXMLelement(messageBody,'addr1') + readXMLelement(messageBody,'addr2') + readXMLelement(messageBody,'addr3') + readXMLelement(messageBody,'addr4');
				act.BillingCity  = readXMLelement(messageBody,'city');
				act.BillingState  = readXMLelement(messageBody,'state');
				act.BillingPostalCode  = readXMLelement(messageBody,'zip');
				act.BillingCountry  = readXMLelement(messageBody,'country');
				
				insert act;
			}
			if(Action == 'modify')
			{
				for(Account actList : act1)
				{
					actList.Name = readXMLelement(messageBody,'name');
					actList.BillingStreet = readXMLelement(messageBody,'addr1') + readXMLelement(messageBody,'addr2') + readXMLelement(messageBody,'addr3') + readXMLelement(messageBody,'addr4');
					actList.BillingCity  = readXMLelement(messageBody,'city');
					actList.BillingState  = readXMLelement(messageBody,'state');
					actList.BillingPostalCode  = readXMLelement(messageBody,'zip');
					actList.BillingCountry  = readXMLelement(messageBody,'country');
				}
				
				update act1;					
			}
			if(Action == 'delete')
			{
				delete act1;
			}
		}
		catch(exception e)
		{
			
		}
		
        return result;
    }
    public static String readXMLelement(String xml, String element)
    {
        String elementValue = 'NOT FOUND'; 
        
        try
        {
	        Xmlstreamreader reader = new Xmlstreamreader(xml);
	        while (reader.hasNext()) 
	        {
	            if (reader.getEventType() == XmlTag.START_ELEMENT && reader.getLocalName() == element)
	            {
	                System.debug('Found SID');
	                reader.next();
	                elementValue = getDecodedString(reader); <---Error Method Does Not Exist or Incorrect Signature: getDecodedString(System.XMLStreamReader)
	            }         
	            reader.next();
	        }
	        return elementValue;
        }
        catch(exception e)
        {
			String err;
			err = e.getMessage();
			return err;
        }
    }
}

 Thank you for your assistance.

public class ToKnowUserInfo{

public void doGetUserInfo() {
try {
GetUserInfoResult result =connection.getUserInfo();
System.out.println('\nUser Information');
System.out.println('\tFull name: ' + result.getUserFullName());
System.out.println('\tEmail: ' + result.getUserEmail());
System.out.println('\tLocale: ' + result.getUserLocale());
System.out.println('\tTimezone: ' + result.getUserTimeZone());
System.out.println('\tCurrency symbol: ' + result.getCurrencySymbol());
System.out.println('\tOrganization is multi-currency: ' +
result.isOrganizationMultiCurrency());
} catch (ConnectionException ce) {
ce.printStackTrace();
}
}

}

 

While i compile this code i get error 
"Error: Compile Error: Invalid type: GetUserInfoResult at line 5 column 7" what is the reason ............knoe any ple tell me  

                                                                                                                                                                                                           thank u

Hi Guys,

Apex class posted below is part of a system that routes calls to our users.  It is all working perfectly but we recently needed to add the function where it only returned records that:

1)  Any state but WA/Western Australia, any time

2)  If in the state of WA/Western Australia (Field-wise this is "Inferred State" or "State"); AND only after 10:30am USER (callers) time as they are 2 hours behind us


Everything works well, but I can't get (2) above to work!  Please help!  For our WA opportunties I simply want to only route these Opps ONLY after 10:30am User/Caller (not customer) time and not before for our WA/Western Australia opportunities! 

I only have VERY limited Apex knowledge (in fact I am not a coder - this ws inherited from a past developer that is no longer in business), so PLEASE let me know what and where to post a change to make this work.  Thank you soooo much in advance!

Code is below.  Code I am trying to get to work isin BOLD text.  Everything else but this time routing is working perfectly.

public with sharing class OpportunityFinder {

 
  public PageReference GoToNextOpportunity(){
    Id op_id = findNextOpportunity();
    if( op_id == null ) return new Pagereference('/apex/No_Further_Opportunities');
   
    PageReference p = new PageReference('/apex/OpportunityCallView?id=' + op_id);
    p.setRedirect(true);
   
    return p;
  }

  public static Id findNextOpportunity(){
   
    Opportunity[] found;
   
    Id user_id = UserInfo.getUserId();
   
    // My Open opportunities where StageCount = 0
    found = [SELECT Id FROM Opportunity WHERE IsClosed = false AND (datetime.now() > datetime.newInstance(Date.today().year(), Date.today().month(), Date.today().day(), 10, 30, 0)) AND (State__c = 'WA' OR Inferred_State__c = 'Western Australia')) AND (State__c != 'WA' OR Inferred_State__c != 'Western Australia')) AND (StageName != 'Following - No Phone - Email Only')) AND (Stage_Count__c = 0 OR Stage_Count__C = null) AND Call_Back_Date__c = null AND Last_Call__c != :Date.today() AND In_Queue__c = false AND OwnerId = :user_id ORDER BY Lead_Score_From_Contact__c DESC LIMIT 1];
    if( found.size() > 0 ) return found[0].Id;
   
    // My Open opportunities where Callback Date = today
    found = [SELECT Id FROM Opportunity WHERE IsClosed = false AND (datetime.now() > datetime.newInstance(Date.today().year(), Date.today().month(), Date.today().day(), 10, 30, 0)) AND (State__c = 'WA' OR Inferred_State__c = 'Western Australia')) AND (State__c != 'WA' OR Inferred_State__c != 'Western Australia')) AND (StageName != 'Following - No Phone - Email Only') AND Call_Back_Date__c = :Date.today() AND Last_Call__c != :Date.today() AND In_Queue__c = false AND OwnerId = :user_id ORDER BY LastModifiedDate DESC LIMIT 1];
    if( found.size() > 0 ) return found[0].Id;
 
    // My Open opportunities where StageCount = 1 AND Callback <= today
    found = [SELECT Id FROM Opportunity WHERE IsClosed = false AND (datetime.now() > datetime.newInstance(Date.today().year(), Date.today().month(), Date.today().day(), 10, 30, 0)) AND (State__c = 'WA' OR Inferred_State__c = 'Western Australia')) AND (State__c != 'WA' OR Inferred_State__c != 'Western Australia')) AND (StageName != 'Following - No Phone - Email Only')  AND Stage_Count__c = 1 AND Call_Back_Date__c <= :Date.today() AND Last_Call__c != :Date.today() AND In_Queue__c = false AND OwnerId = :user_id ORDER BY Lead_Score_From_Contact__c DESC LIMIT 1];
    if( found.size() > 0 ) return found[0].Id;
   
   
    return null;
 
   
  }

}