Hi, We are trying to create a vendor bill from exi...
# general
p
Hi, We are trying to create a vendor bill from existing purchase order using suitescript N/record module. Following is the code:
Copy code
var vendorBill = recordModule.create({
            type: recordModule.Type.VENDOR_BILL,
            isDynamic: true,
            defaultValues: {
                entity: supplierId
            }
        });
vendorBill.selectNewLine('item');
vendorBill.setCurrentSublistValue('item', 'orderdoc', poId);
vendorBill.setCurrentSublistValue('item', 'orderline', poLineId);
                
vendorBill.commitLine('item');
vendorBill.save({
			enableSourcing: false,
			ignoreMandatoryFields: true
		});
This above code is written in a restlet and when we invoke it from postman, we get :
Copy code
{
  "type": "error.SuiteScriptError",
  "name": "YOU_CANNOT_ADD_MULTIPLE_VENDORS_ANDOR_CURRENCIES_TO_A_SINGLE_VENDOR_BILL",
  "message": "You cannot add multiple vendors and/or currencies to a single Vendor Bill.",
  "id": "",
  "stack": [
    "anonymous(N/serverRecordService)",
    "postBill(/SuiteScripts/new_post_transaction.js:1402)",
    "doPost(/SuiteScripts/new_post_transaction.js:641)"
  ],
  "cause": {
    "type": "internal error",
    "code": "YOU_CANNOT_ADD_MULTIPLE_VENDORS_ANDOR_CURRENCIES_TO_A_SINGLE_VENDOR_BILL",
    "details": "You cannot add multiple vendors and/or currencies to a single Vendor Bill.",
    "userEvent": null,
    "stackTrace": [
      "anonymous(N/serverRecordService)",
      "postBill(/SuiteScripts/new_post_transaction.js:1402)",
      "doPost(/SuiteScripts/new_post_transaction.js:641)"
    ],
    "notifyOff": false
  },
  "notifyOff": false,
  "userFacing": false
}
Please help.
r
Are you able to create the same vendor bill for that purchase order through UI? On an unrelated note, did you try record.transform api to create that vendor bill ?