tuli
10/11/2021, 9:04 PMNetsuite Tragic
10/12/2021, 2:18 AMNetsuite Tragic
10/12/2021, 2:18 AMNetsuite Tragic
10/12/2021, 2:18 AMNetsuite Tragic
10/12/2021, 2:19 AMNetsuite Tragic
10/12/2021, 2:19 AMfunction afterSubmitUpdateTimeTracking(type)
{
//get the current invoice record
currentRecordId = nlapiGetRecordId();
// nlapiLogExecution ( 'DEBUG', 'current record id', currentRecordId );
var currentRec= nlapiLoadRecord('invoice',currentRecordId);
// Get the number of line Time Tracking items submitted
lines = currentRec.getLineItemCount('time');
//parse the list of time records
for ( var i=1; i<=lines; i++ )
{
//get the ID of the Time Tracking
var timeRecId = currentRec.getLineItemValue('time', 'doc', i);
nlapiLogExecution ( 'DEBUG', 'time rec id', timeRecId );
var timeSelected = currentRec.getLineItemValue('time', 'apply', i);
nlapiLogExecution ( 'DEBUG', 'time selected id', timeSelected );
//if it's selected on the invoice, update its custom field
if (timeSelected == 'T')
nlapiSubmitField('timebill', timeRecId, 'custcol_related_invoice', currentRecordId );
else
{
//ensure that updates on invoices when Time Tracking records are unapplied
var timeRecord = nlapiLoadRecord('timebill', timeRecId);
var invoiceNoSet = timeRecord.getFieldValue('custcol_related_invoice');
if (invoiceNoSet != null)
nlapiSubmitField('timebill', timeRecId, 'custcol_related_invoice', null );
}
nlapiLogExecution('DEBUG', "title Record Updated", "Invoice=" + currentRecordId );
}
//log.debug({
//"title": "Record Updated",
//"details": "Invoice=" + currentRecordId
//});
}
tuli
10/14/2021, 10:32 AM