Hi all, Netsuite will auto create Purchase Order (...
# suitescript
d
Hi all, Netsuite will auto create Purchase Order (PO) for Special order item by default once the Sales order is approved. It will group all item by vendor and create 1 PO I want to do the same using script, for non special order item, any clue how to do it ? I tried this https://netsuite.custhelp.com/app/answers/detail/a_id/71358/kw/shipgroup but i got error
"name":"USER_ERROR","message":"You must enter at least one line item for this transaction."
I thought the items will be auto copy over to the PO Thanks
b
its a little unstable, but you can sometimes recreate special order purchase orders using default values
create the special order by clicking the link from the sales order
and pay attention to the parameters in the url
each parameter is a default value you can set while creating the record in suitescript
d
i tried that. I have 2 line items in Sales Order, if i click the link, it will only create PO with that item
i see that NS can create 1 PO containing both 2 items, i want to achieve the same
b
dont expect to recreate anything you wouldnt be able to do in the ui
you can try removing parameters that dont look mandatory, but remember what i said abut instability
d
Copy code
var po_params = {
            'recordmode': 'dynamic',
            'soid': 8307115,
            'shipgroup': 1,
            'poentity': 253618,
            'specord': 'T',
            'custid': 3369282,
            'entity': 253618
        };

        var po = record.create({
            type: record.Type.PURCHASE_ORDER,
            isDynamic: true,
            defaultValues: po_params
        });

        var poId = po.save({
            enableSourcing: true,
            ignoreMandatoryFields: true
        });
this is my code, i tried clicking the 'Spec. Ord.' link from the SO, it opened up PO page, with all line items in place actually
but not the case using my script above, seems like the line items are not copied over, because i got error like this
You must enter at least one line item for this transaction.
maybe i should try to set each line items in the PO before save it
b
whats the url used to create the po
d
you mean the url when i click on Spec Ord link from Sales Order ?
<http://netsuite.com/app/accounting/transactions/purchord.nl?soid=8307115&specord=T&custid=3369282|netsuite.com/app/accounting/transactions/purchord.nl?soid=8307115&specord=T&custid=3369282>
b
use the same default values as parameters
there should only be 3
d
let me try
different error
Please enter a value for Vendor
i believe i need the
entity
param as well
i manually set the line items using po.selectNewLine and commitLine. PO successfully created, but it's like standalone PO, no link to Sales Order
b
adding new lines wont get you the link to the sales order
d
initially i thought that with the defaultvalues in place, i just need to make sure that the PO can be saved, then it will link to the sales order, but apparently it did not
wow, it works! this piece of codes works
Copy code
var po_params = {
            'recordmode': 'dynamic',
            'soid': 8307115,
            //'shipgroup': 1,
            'poentity': 253618,
            'specord': true,
            'custid': 3369282,
            'entity': 253618
        };

        var po = record.create({
            type: record.Type.PURCHASE_ORDER,
            isDynamic: true,
            defaultValues: po_params
        });

        var poId = po.save({
            enableSourcing: true,
            ignoreMandatoryFields: true
        });
the key here is 'specord' : true instead of 'specord' : 'T'
🎉
103 Views