This topic contains 5 replies, has 0 voices, and was last updated by Mikemacx 7 years, 7 months ago.
-
AuthorPosts
-
April 7, 2017 at 2:53 pm #21652
MikemacxHey all…
I'm still new to Suitescript.
We have an item call 'NEW ITEM' that represents an item not yet entered in Netsuite that reps can use temporarily. They can make a sales order, but are instructed not to convert to invoice. They must make a customer deposit, wait for the new item to be entered into the system, and then can correct the sales order and go to an invoice.
Reps seldom obey the rule and I need to prevent them from creating invoices from sales order with a 'NEW ITEM'. Otherwise it makes problems.
I wrote this code. It loops through the line item names to see if 'NEW ITEM' is one of them. It works as far as stopping them from saving the invoice with a new item and showing an alert, but my headache is that is also prevents an invoice without new items from saving as well. Nothing happens when clicking SAVE. I don't what else to put in here to make it work. I'm attaching this to the invoice record in the SAVE RECORD FUNCTION area.
function stopSave()
{
var count = nlapiGetLineItemCount('item');
for(var i = 1; i <= count; i++) {
var id = nlapiGetLineItemText('item', 'item', i);
if(id !== 'NEW ITEM') {
continue; }
else if(id == 'NEW ITEM') {
alert('You cannot create an invoice containing new items. Please take a deposit from the customer and wait until the items are added to Netsuite. Thank you');
return false;
}
}
}
I know I'm close, but can't figure how to have it save the record if 'NEW ITEM' is not found. Thanks…….
This is a cached copy. Click here to see the original post. -
April 7, 2017 at 3:19 pm #21653
MikemacxI think I have figured it out. It needed a last return switch in the code….
function stopSave()
{
var linePass = true;
var count = nlapiGetLineItemCount('item');
for(var i = 1; i <= count; i++) {
var id = nlapiGetLineItemText('item', 'item', i);
if(id!=='NEW ITEM') {
continue;
}
if(id == 'NEW ITEM') {
alert('You cannot create an invoice containing new items. Please take a deposit from the customer and wait until the items are added to Netsuite. Thank you');
return false;
linePass-false;
break;
}
}
return linePass;
}
-
April 7, 2017 at 3:32 pm #21654
david.smithYou should also never use text when looking at values. You should use the internalid. This will prevent mistakes from happening.
-
April 7, 2017 at 3:51 pm #21655
MikemacxThat is good advice and duly noted
Thank you
-
April 7, 2017 at 5:31 pm #21656
erictgrubaughIf they shouldn't even save the order in the first place with NEW ITEM, then I guess I don't follow why NEW ITEM exists at all. Seems like you could just delete NEW ITEM from your items altogether, and you wouldn't need any code at all.
If there is a reason they should be able to save it with NEW ITEM, then you could also enable Sales Order Approvals so that orders would need to be approved before being Invoiced.
-
April 7, 2017 at 10:53 pm #21657
MikemacxQuite simple. If the item doesn't exist yet in Netsuite, they need something to enter into the sales order to complete it for Purchasing. They are required to take a deposit instead, wait until the new item is entered into the system, change the item in the sales order once the item is available, and then they can invoice and apply the deposit.
I've got over 900,000 skus in Netsuite, but new items are coming out from our manufacturers periodically. When a 'New Item' is entered in a sales order with a description and price, it emails me on save and then I can make the new item with the proper information. They have to be able to take a full payment at that moment from the customer, so the new item is a placeholder of sorts.
Hey….iI saw you on Youtube. Thanks for the introduction for Suitescript. It helped me lose my inhibition to try it.
-
AuthorPosts
You must be logged in to reply to this topic.