Since I need a quick fix to this I'm throwing this out there for comments. The following code and values from the script debugger are from a script that runs against inbound cases. Up until this weekends upgrade to 2012.2 it worked fine and returned the Customer ID and Date (as well as other things). It is now returning -1 for the string length and I believe that perviously it was returning the actual length of the customer id or date that we were looking for. At -1 length is is not returning the subsequent substring we are looking for (customer id).
Any ideas on what changed with 2012.2?
Code:
var curcase = nlapiLoadRecord('supportcase', 120738);
//Obtain the value of the case subject
var subject = curcase.getFieldValue('title');
//Test if Maintenance Completed is in the case subject
var subjectpattern = new RegExp("Inspection Date");
var testsubject = subjectpattern.test(subject);
//If testpatt is true, continue (indicates that "Inspection Date" is in the subject).
if (testsubject == true) {
var inboundem = curcase.getFieldValue('incomingmessage');
//Obtain the Customer ID from the incoming message text
var custidpatt = new RegExp("CompanyID:");
var testcustid = custidpatt.test(inboundem);
}
if (testcustid == true) {
var remainingstr = RegExp.rightContext;
var pagebreakpatt = /<br>/;
var custidstrlength = remainingstr.search(pagebreakpatt);
var custidstr = remainingstr.substr(0, custidstrlength);
var custid = custidstr;
// Obtain the inspection date
var idatepatt = new RegExp("IDate:");
var testidate = idatepatt.test(inboundem);
var remainingstridate = RegExp.rightContext;
var idatestrlength = remainingstridate.search(pagebreakpatt);
var idatestr = remainingstridate.substr(0, idatestrlength);
//nlapiLogExecution('Debug', 'The Date is = ', idatestr);
Debugger Values:
x = null
updaterec = null
casereplytoem = null
inspreportem = null
currcust = null
idatestr = {string}
idatestrlength = {number} -1
remainingstridate = {string} 9/25/2012 Inspector Name: Dxxx Gxxx Facility Name: Mxxx Cxxx Cxxx
testidate = {boolean} true
idatepatt = {regexp} /IDate:/
custid = {string}
custidstr = {string}
custidstrlength = {number} -1
pagebreakpatt = {regexp} /<br>/
remainingstr = {string} 4484 IDate:9/25/2012 Inspector Name: Dxxx Gxxx Facility Name: Mxxx Cxxx Cxxx
testcustid = {boolean} true
custidpatt = {regexp} /CompanyID:/
inboundem = {string} CompanyID:4484 IDate:9/25/2012 Inspector Name: Dxxx Gxxx Facility Name: Mxxx Cxxx
testsubject = {boolean} true
subjectpattern = {regexp} /Inspection Date/
subject = {string} Your form "Inspection Date" got a response
curcase = {nlobjDeferredDynamicRecord} supportcase (id=120738)