If I want to create a vendorBill for purchase orde...
# suitescript
r
If I want to create a vendorBill for purchase order through script. Is it possible to set the Netsuite standard created from field without transforming the record?
b
yes and no
there is no created from field on vendor bills. so you cant set it
you can however set the line level orderdoc and orderline, which are what are actually used for the purchose order relationship
r
And is it better to create the bill and tag the purchase order ? Or should one transform the purchase order to bill ?
b
transforming the purchase order makes it much harder to mess up setting up the lines
if you set the fields yourself, you need to do all the sourcing correctly
the primary reason you would try to set the fields fields yourself is if you wanted to create a bill for multiple purchase orders
r
Is there any disadvantage when transforming the purchase order to bill except that it will be a 1 to 1 relationship?
b
use record.tranform, if you are going for 1 to 1
💯 1
r
don't think record. Transform is the right approach. Loading the purchasing order, iterating through the lines and setting the values in vendor bill will be better. will check both regardless, should not take much time.
@battk Can you please tell me how to find orderDoc and OrderLine field visible, can't seem to find these 2 fields in the VendorBill nor I can find it in form.
b
they arent visible in the ui
they are internal fields used by netsuite which arent normally settable
though vendorbill is one of the unusual ones that do
its one of the reasons you want to use the transform instead
r
we will have to create 1 vendor bill for multiple purchase order in a very near future, that's why want to go for the second approach.
I am not able to set orderDoc and orderLine fields in the script.
Copy code
vendorBillRecord.setCurrentSublistValue({ sublistId: 'item', fieldId: 'orderdoc', value: purchaseorderId });                                vendorBillRecord.setCurrentSublistValue({ sublistId: 'item', fieldId: 'orderline', value: uniqueLine });
If I do not comment this potion of code, I am getting an error
Copy code
YOU_CANNOT_ADD_AN_ITEM_AND_PURCHASE_ORDER_COMBINATION_THAT_DOES_NOT_EXIST_TO_A_VENDOR_BILL
But without these 2 lines, there is no linking between the vendor bill and the purchaseOrder. The ivendor, tems, quantity, rate, amount, etc everything is coming correct. just need some input on how to link these 2.
b
start smaller
make the vendor bill in the ui first
load it in script so you can examine its lines to see which fields you need to set with what values
then delete the vendor bill and try it in code
r
will do that, just ot be sure, what I will be setting in orderdoc and orderline field? I was trying to previously set, in orderDoc Purchacse order document numbner and in OrderLine, Purchase order unqieue line key Then I treied setting I was trying to previously set, in orderDoc Purchacse order internalID What will be the correct approach among the 2?
b
it sounds like you have yet to examine an existing vendor bill yet
r
yes, will check that, sandbox went down, waiting for it to come back up
Thank You @battk setting the lineID field, internalid line now instead of uniquelinekey. It is working, orders are getting linked, and purchase order is going to fully billed status as well.