0

Using Pick, Pack and Ship and advanced PDF HTML templates, NetSuite cannot display the qty remaining to pick. So if we do a partial pick, we cannot show the warehouse the remaining balance. The math is simple, here is the script and function I would like to see (based on forum feedback). Will this work and what is the best way to deploy this script such that the result is stored in the custom column until another pick takes place? The value is to be calculated at time of changes, but available to all related transaction records.

function SetQtytoPick(type){
  if(type == 'item'){
    var qtyordered = nlapiGetCurrentLineItemValue('item', 'quantity');
    var qtypicked = nlapiGetCurrentLineItemValue('item', 'quantitypicked');
    var qtytopick = qtyordered-qtypicked
    nlapiSetCurrentLineItemValue('item', 'custcol_qty_to_pick', qtytopick);
  }
}
DLindy
  • 1
  • 1

1 Answers1

2

Actually one of the really fun things about the Advanced HTML/PDF templates is that you don't need your code. When print the packing slip the template supplies the item fulfillment (as record) and the sales order (as salesorder).

You can get the value you need from the Sales Order's Item Line's quantityfulfilled value.

the following snippet was from a customized packing slip where the customer wanted the PS to always show all the Sales Order's items. It doesn't directly solve your problem but you can see that the template itself can be used to calculate the items remaining to ship at the time of printing.

<#list salesorder.item as tranline>
    <#assign shipped=0>
    <#assign prevShipped=tranline.quantityfulfilled>
    <#assign qtyRemaining=tranline.quantity - prevShipped>
    <#if (tranline.quantitybackordered gt 0)> <#assign qtyRemaining=tranline.quantitybackordered></#if>
    <#list record.item as item><#if tranline.line==item.orderline>
        <#assign shipped=item.quantity>
        <#assign prevShipped=tranline.quantityfulfilled-item.quantity>
    </#if></#list>
    <tr>
    <td colspan="12"><span class="itemname">${tranline.item}</span><#if tranline.itemtype =='NonInvtPart'>**<#assign anyNonInvt='T'></#if><br />${tranline.description?html}</td>
    <td align="center" colspan="3"><#if shipped gt 0><b>${shipped}</b><#else>0</#if></td>
    <td align="center" colspan="3">${tranline.quantity}</td>
    <td align="center" colspan="3">${prevShipped}</td>
    <td align="center" colspan="3">${qtyRemaining}</td>
    <td colspan="4">${tranline.options?html}</td>

    </tr>
    </#list>
</#if>

The other way to do this would be to put your script into a user event script before submit event. You'd deploy it on Item Fulfillments

bknights
  • 14,408
  • 2
  • 18
  • 31
  • I am hoping the approach you outline above can do the job. It looks like it assumes that a fulfillment event has taken place. There are really three possible scenarios: 1. The order has not been fulfilled, therefore nothing in the tranline, only info in the order, 2. a full fulfillment, in which there is a tranline, and 0 remaining to be fulfilled. 3. a partial fulfillment where there is both a tranline, and info to be sourced in the order. How would you approach this? We have explored the script with mixed results, hoping your approach can get it done. – DLindy Mar 21 '16 at 03:13
  • Actually the code above was for a packing slip. If you are printing a pick ticket you will only have the sales order lines and they will be there as `<#list record.item as item>` and you'd do roughly the same as the packing slip code but ignore the part where you try to adjust for what is on the item fulfillment. – bknights Mar 21 '16 at 14:35
  • There is a setting in NetSuite called Pick, Pack and Ship. When this is enabled, you can have a sales order that is partially fulfilled. The value of item.quantitypicked is not available (not exposed) in Advanced PDF/HTML templates on the SO Record. So, what I want to do, in the form is the following: If there is a fulfillment record, partial or full, go get the quantitypicked from that fulfillment record and set it = "prevPicked" and set "qtyToPick=item.quantity - prevPicked", otherwise, set qtyToPick=item.quantity. Is it possible to do that logic in the form? Or, if you get a Null – DLindy Mar 22 '16 at 00:48
  • when looking for the fulfillment record, can you set the prevPicked value = 0? – DLindy Mar 22 '16 at 00:48
  • Hi @DLindy. If you review what I originally posted that was for the packing slip for a customer using Pick,Pack and Ship. The to pick value is in `${qtyRemaining}` – bknights Mar 22 '16 at 01:03