Suitescript - transforming item fulfillment mark shipped - netsuite

We utilize advanced shipping Pick, Pack, Ship and I'm having a difficult trying create an item fulfillment marked shipped.
After transforming, the item fulfillment is marked as picked.
I tried to set the value by using
fulfillment.setValue(’shipstatus’,’ItemShip:C’);
but that would return an error.
var fulfillment = record.transform({
fromType: record.Type.SALES_ORDER,
fromId: _salesOrderId,
toType: record.Type.ITEM_FULFILLMENT,
defaultValues: {
inventorylocation: 31
},
isDynamic:true
})
Is this possible to create an item fulfillment as marked shipped when transforming?

After you create the fulfillment you may need to set up packages and verify which and what quantity of items are being shipped. How these default is dependent on a couple of setups in your Netsuite account.
When you've got all that done you'd set the Shipped status as:
fulfillment.setValue({fieldId:'shipstatus', value:'C'});
The old fields on Netsuite that cause or reflect state changes on things (transactions, support cases, etc) often have puzzling values. So you search for status with values such as 'ItemShip:C' but you just set the status as 'C'.

Related

NetSuite Suitescript 2.0 - Remove Member Item then Add member item based on a field on the kit

I am working on a SuiteScript that I have pieced together from watching videos and reading various articles.
Purpose: Remove a member item from a Kit/Package item and add a new Member Item found in a Custom Field.
Some Details: We use Kit/Package item to promote the sale of general goods we have in stock under a single SKU. When we are low or out of stock we may have substitute items that can take its place. I added a custom field called, "Best Member Item" {custitem_burkett_bestmemberitem}. This field populates itself with the best alternative substitute item that we could use to fill customer orders.
Issue #1: Script is not happy about me entering just the field label for Value..
Issue #2: I tested by adding TEXT, and it complained "Skipped - Script Workflow Action : Set Best Member Item doesn't have matching audience
"
Below is the Script.
define(["N/currentRecord"], function(r){
var rec = currentRecord.get();
function insertLine(rec) {
rec.insertLine({
sublistId: "item",
line: 1
});
rec.SetCurrentSublistValue({
sublistId: "item",
fieldId: "item",
Value: {custitem_burkett_bestmemberitem},
});
rec.SetCurrentSublistValue({
sublistId: "item",
fieldId: "quantity",
Value: 1
});
rec.commitLine({sublistId: "item"});
};
})
I think you will need some more help before continuing further, based on the sample you gave.
I think you will need to understand and tell us what your execution context is - for example, on create of the item, on edit of the item, or on a transaction level basis.
Secondly, I am almost certain, for best practice or otherwise, N/currentRecord should only be used within client scripts. So that can be something you can research on. Your current sample will work as a 2.0 client script with a few changes...
but depending on your use case, i.e if your user will only update this in UI, or further, with csv, or both, you might need more than one script.
To me, unless there is major changes or use cases, using this as a wfa (workflow action script) is not the correct design forward..

Netsuite SS1 Cannot tell if inventory detail is set

I have a workflow script that transforms a sales order into an item fulfillment when the order is approved.
I can create a subrecord for inventory detail no problem, but in some cases Netsuite will automatically set the inventory detail. In these cases, when I go to add a subrecord, I receive an error on fulfillment submit record.
I have tried for 2 hours and cannot seem to find a way only to verify if the inventory detail is existing. I tried using the examples from the documentation
var invDetailSubrecord = fulfillment.editCurrentLineItemSubrecord('item', 'inventorydetail');
var invDetailSubrecord = fulfillment.viewCurrentLineItemSubrecord('item', 'inventorydetail');
fulfillment.removeCurrentLineItemSubrecord('item', 'inventorydetail');
None of the above commands do anything and are ignored. I don't see any way possible to verify that inventory detail is set before creating it. Viewing the actual data isn't necessary.
You can use nlapiGetLineItemCount on inventory-details subrecord(I am using the same in SuiteScript2.0 and it works) before setting/updating records manually and if you get line count greater than 0, you can safely assume inventory details already exists for the line.
You can check this out for further reading.

NetSuite Workflow - Set Field Mandatory Option

I am creating a NetSuite workflow to set a field mandatory. Use case as follows:
If custom field "Customer Has Billing Issue" checkbox is checked, then make "Billing Issue Ticket Number" (custom field) mandatory.
Settings as follows:
Workflow:
Name: (any)
Record Type: Customer
Sub Types: Customer
Execute as admin: checked
Status: Released (in Sandbox)
Event definition: On create, on view or update
Trigger type (I've tried all): Current set to Before Record Load
State:
Action 1: Set field Mandatory:
Condition: Company has billing issue = T
Trigger on (I've tried them all) currently on: After field edit
Triggering Client fields: Customer has billing issue
Parameters: Field: Billing Issue Ticket Number
Mandatory = Checked
Action 2: Set field Mandatory:
Condition: Company has billing issue = F
Trigger on (I've tried them all) currently on: After field edit
Triggering Client fields: Customer has billing issue
Parameters: Field: Billing Issue Ticket Number
Mandatory = Unchecked
I tried all combinations. The workflow is triggering but I cant seem to make the field mandatory. Any suggestions?
I got it to work like this. Actions have the "Customer Has Billing Issue" field as the triggering field

Netsuite - Sales Order Status of item fulfilment

Pending Fulfilment is not a helpful status when looking at a sales order
Would like to know the latest status on the item fulfilment record on the sales order itself. Picked, Packed or Shipped.
This button should only show when the status of the sales order pending fulfilment.
Do i acheive this via a workflow? or customized form. We are just not sure where to start! All guidance is appreciated.
Maybe try to create a new custom field and source from item fulfillment status.
See answers from here:
Adding new transaction status in netsuite

How to create a vendorpayment record from a NetSuite 2.0 restlet?

I'm trying my hand at a 2.0 restlet. This is more or less my first experience with SuiteScript 2.0. I'm trying to create a vendorpayment record. I've been able to create a vendor record without an issue, but when I try with vendorpayment, I get an error that says, "You must enter at least one line item for this transaction", which seems to make sense. That's where I'm stuck though. I can't seem to create that sublist item in 2.0.
I've tried a few things, but basically I'm creating a record like this (type, isDynamic and defaultValues are parameters in this function. isDynamic is false):
var rec = record.create({
type: type,
isDynamic: isDynamic,
defaultValues: defaultValues
});
How do I then use 'rec' to add a transaction? I'm assuming it goes to the 'apply' sublist, so I've tried a few things similar to
rec.selectLine('apply', 0);
rec.setSublistValue({'sublistId': 'apply', 'fieldId': 'doc', 'value': 'blah', 'line': 0});
but I get an error that says, "Cannot find function selectLine in object DeferredDynamicRecord". I've tried various other snippets as well, but no love. I'm not sure if I'm going about it the right way. Thanks in advance.
Solely based on what code you have provided there are a few things to point out. First off with this type of record you will need to set the 'entity' value in your defaultValue property in order for there to even be an 'apply' list available to get or set values against. Your other option would be to set 'isDynamic' to true. With that you will again need to set the 'entity' value before having access to the 'apply' list.
The next issue is the rec.selectLine() call. You do not need to do a selectLine() when the record is not in dynamic mode, for that matter if you do selectLine() you must then use the setCurrentSublistValue/Text() call.
Finally you cannot set the value 'doc' in the apply list. This is not a sublist such as the Item sublist on a sales order that can be added to dynamically. It is more like the list on the item fulfillment which limits what options you have regarding setting values. You can only affect the following fields in the apply list on the Bill Payment screen:
'apply'- This is the Checkbox on the far left.
'disc' - the Disc Taken field.
'amount' - Payment field.
I suggest running through the process of creating a Bill Payment in the UI so that you understand how the process needs to function from a timing standpoint before attempting to fix your script. Good luck and I hope this helps.

Resources