+ Start a Discussion
Kalle KalifKalle Kalif 

Handling inbound email upserting 320 fields in custom object

Hi,

 

I am handling a inbound email which contains ~320 field values, contained in tags <field1>123<field1> etc.

 

This is handled in the following way:

//Retrieve data
string[] OBJECT_ID=email.plaintextbody.split('<OBJECT_ID>',3);
string[] FORM_OBJECT_ID=email.plaintextbody.split('<FORM_OBJECT_ID>',3);

//etc.. for 320 strings


Daily__c r = new Daily__c(Name = RptName, 
Object_ID__c=(OBJECT_ID[1] == null || integer.valueof(OBJECT_ID[1].trim().length()) == 0)? null :integer.valueof(OBJECT_ID[1].trim()),
Form_Object_ID__c=(FORM_OBJECT_ID[1] == null || integer.valueof(FORM_OBJECT_ID[1].trim().length()) == 0)? null :integer.valueof(FORM_OBJECT_ID[1].trim()),

//etc again with 320 lines

);

upsert r Name; 

 

Problem is when doing the testing of the code, before deploying to production, i get the error message:

554 Method exceeds maximum number of allowed op codes.  Please break this method into multiple, smaller methods.

 

So i understand my code might be abit inefficient. The question is, how can I fix this? I dont really understand exactly what limit i'm hitting either.

 

thanks for any help!