2

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.

quarks
  • 33,478
  • 73
  • 290
  • 513
user2233949
  • 2,053
  • 19
  • 22

1 Answers1

0

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.

Todd Grimm
  • 509
  • 1
  • 3
  • 14