Need help setting custom Date field with value from Customer.LastModifiedDate
Hello,
I am using the following script and in attempting to set a custom field (date format) with the following script I am receiving the error "TypeError: Cannot find function getFullYear in object 6/19/2015 1:01 pm. (custSubmit (1).js$3340248$sys#2976)" Can someone tell me what is wrong with my script? I have tried the 'datetime' and 'date' formats, checked my date settings in my preferences and still cannot get it to work. Any assistance is appreciated, I can't use the custom field as a string/text field since we need to use it for setting date criteria to report on.
If it helps at all, when setting var fmtDateModified = nlapiDateToString(parentDateModified, 'date') the debugger returns fmtDateModified = {date} Fri Jun 19 2015 13:44:00 GMT-0700 (PDT) [FONT=tahoma]when stepping through the script and throws an unexpected error has occurred
on completion with no descriptive error value.[/FONT]
Thanks,
Jocelyn
[CODE]// on the before submit user event of the customer record
function afterSubmit() {
if (type == 'xedit' || type == 'edit')
{
var recordId = nlapiGetRecordId();
var record = nlapiLoadRecord('customer', recordId);
var customerId = nlapiGetFieldValue('entityid');
var parentDateModified = nlapiGetFieldValue('lastmodifieddate');
var fmtDateModified = nlapiDateToString(parentDateModified, 'datetime');
var filters = new Array();
filters[0] = new nlobjSearchFilter( 'entityid', null, 'contains', customerId, null);
var results = nlapiSearchRecord('contact', null, filters, null );
if (results !== null) {
var count = results.length;
for (var i = 0; i < count; i++) {
var contactId = results[i].getId();
nlapiSubmitField('contact', contactId, 'custentity_contact_custupd', fmtDateModified);
//nlapiSubmitRecord('contact',true);
}
}
nlapiLogExecution('AUDIT', 'details', customerId);
nlapiLogExecution('AUDIT', 'details', contactId);
nlapiLogExecution('AUDIT', 'details', fmtDateModified);
}
}[/CODE]