Importing Vendor Payments is working fine until I ...
# csvimports
n
Importing Vendor Payments is working fine until I do it with a particular User Event script. The scripts function is to populate the Payment memo with a summary of the Bill references. Problem is that some imported Payments will be saved with blank document numbers (tranid). The UE script has been working fine in the UI for a year. The UE script does not access the 'tranid' except I've added it now for debug purposes. From the debug logs the transaction already has a blank tranid as soon as the script executes whereas for the transactions where it works correctly the tranid is immediately present.
Copy code
if (context.type !== context.UserEventType.CREATE && context.type !== context.UserEventType.EDIT) {
      return; // Only run on creation or editing of Vendor Payment record
    }
    
    var newRecord = context.newRecord;
    var vendorPaymentMemo = '';
    var paidBills = [];
    
    // Get the paid vendor bills linked to this vendor payment
    var lineCount = newRecord.getLineCount({ sublistId: 'apply' });
    for (var i = 0; i < lineCount; i++) {
      if (newRecord.getSublistValue({ sublistId: 'apply', fieldId: 'apply', line: i })) {
        var paidBill = newRecord.getSublistValue({ sublistId: 'apply', fieldId: 'doc', line: i });
        if (paidBill && paidBills.indexOf(paidBill) === -1) {
          paidBills.push(paidBill);
        }
      }
    }
        
    // If paid bills were found, construct the vendor payment memo
    if (paidBills.length > 0) {
      var billSearch = search.create({
    	  type: search.Type.VENDOR_BILL,
    	  filters: [['internalid', 'anyof', paidBills],'AND',
    	            ['mainline', 'is', 'T']],
        	columns: ['tranid']
      });
      
      var results = billSearch.run().getRange({ start: 0, end: 1000 }); // Limit to 1000 bills
      
      for (var i = 0; i < results.length; i++) {
        vendorPaymentMemo += results[i].getValue({ name: 'tranid' }) + ', ';
      }
      
      vendorPaymentMemo = vendorPaymentMemo.slice(0, -2) // Remove the final ', ' 
      
    // Set the vendor payment memo
    newRecord.setValue({ fieldId: 'memo', value: vendorPaymentMemo });
Today's discovery, two Administrator users, using the same CSV file and the same CSV mapping. One Administrator gets the transactions all with defaulting number series of checks. The other user gets the text override for 75% of the checks with the other 25% being blank.
😵‍💫 1
weird
d
very weird. maybe share it to #C29HQS63G?