This is the first script I've ever created, and I'm getting an Unexpected Error from Netsuite, which is completely unhelpful because it gives me literally no information about what I am doing wrong. I am trying to create a simple script that does the following:
Whenever a cash sale is created, add today's date to a custom field on each of the items on the cash sale.
Here is what I have produced so far (sorry about formatting):
function lastSaleDateAfterSubmit(type){
if (type=='create')
{
var lineNumber = nlapiGetLineItemCount('item');
var i = 1;
var today = new Date();
for(i; i<=lineNumber; i++)
{
nlapiSelectLineItem('item', i);
var itemToEdit = nlapiGetCurrentLineItemValue('item','id'); nlapiSubmitField('inventoryitem',itemToEdit,'custitem15',today);
}
}
}
I'm sure there are probably a couple things I am doing wrong here, but if anybody could point me in the right direction, I would be grateful. I've tried messing with the parameters in the SubmitField and GetCurrentLineItemValue but I can't get anything that doesn't either cause a user error telling me that the field is invalid, or giving me an unexpected error.
Thanks