Has anyone encountered this before? - Suitelet wit...
# suitescript
r
Has anyone encountered this before? • Suitelet with sublist and client script attached • Suitelet loads some select field columns with pre-populated values from a saved search • Make one of the pre-populated columns blank in the UI then click on submit button • Client side script still sees the pre-populated value and not the blank value • Does not occur for checkbox column
n
What's your CS code? Are you using saveRecord trigger?
r
I am using the saveRecord trigger. Below is the relevant code
Copy code
function _checkSelection(recCurrent, inLineCount) {
  var flAmount = 0.0;

  var stCustomer = null;
  var stProvider = null;
  var stAccountManager = null;
  var stReason = null;
  var stCloseAmount = null;

  var blSelected = false;
  var blSelectedItem = false;
  var blSplitInvoice = false;
  var blClose = false;

  for (var inIndex = 0; inIndex < inLineCount; inIndex++) {
    blSelected = recCurrent.getSublistValue({
      sublistId: "custpage_billableexpensesublist",
      fieldId: "custpage_select",
      line: inIndex,
    });
    stCustomer = recCurrent.getSublistValue({
      sublistId: "custpage_billableexpensesublist",
      fieldId: "custpage_customer",
      line: inIndex,
    });
    stProvider = recCurrent.getSublistValue({
      sublistId: "custpage_billableexpensesublist",
      fieldId: "custpage_provider",
      line: inIndex,
    });
    stAccountManager = recCurrent.getSublistValue({
      sublistId: "custpage_billableexpensesublist",
      fieldId: "custpage_accnt_mngr",
      line: inIndex,
    });
    flAmount = recCurrent.getSublistValue({
      sublistId: "custpage_billableexpensesublist",
      fieldId: "custpage_inv_amount",
      line: inIndex,
    });
    blSplitInvoice = recCurrent.getSublistValue({
      sublistId: "custpage_billableexpensesublist",
      fieldId: "custpage_split",
      line: inIndex,
    });

    blClose = recCurrent.getSublistValue({
      sublistId: "custpage_billableexpensesublist",
      fieldId: "custpage_close",
      line: inIndex,
    });

    stCloseAmount = recCurrent.getSublistValue({
      sublistId: "custpage_billableexpensesublist",
      fieldId: "custpage_close_amount",
      line: inIndex,
    });

    stReason = recCurrent.getSublistValue({
      sublistId: "custpage_billableexpensesublist",
      fieldId: "custpage_close_reason",
      line: inIndex,
    });

    if (blSelected == true || blSelected == "T") {
      blSelectedItem = true;

      // <Gerrom V. Infante (ginfan@appwrap.tech) 02/10/2024> - added logic to ignore Customer, and Provider if the User has checked the split invoice or if the Close field is selected
      if (
        (blSplitInvoice == false || blSplitInvoice == "F") &&
        (blClose == false || blClose == "F")
      ) {
        if (
          !stCustomer ||
          !stProvider ||
          !stAccountManager ||
          !flAmount ||
          stCustomer == -1 ||
          stProvider == -1 ||
          stAccountManager == -1
        ) {
          dialog.alert({
            message:
              "At least one of the following fields is blank.  Please provide a value to the field and try" +
              " again.<br/>Customer<br/>Provider<br/>Account Manager<br/>Invoice Amount",
          });
          return false;
        }
      }

      if (blClose == true || blClose == "T") {
        // if  customer or provider is selected for line marked as closed, check if amount is provided
        if (
          !stCustomer ||
          !stProvider ||
          !stAccountManager ||
          stCustomer == -1 ||
          stProvider == -1||
          stAccountManager == -1
        ) {
          if (!flAmount) {
            dialog.alert({
              message: "Invoice amount is a required field.",
            });
            return false;
          }
        }

        // check if Close Reason is provided
        if (!stReason) {
          dialog.alert({
            message: "Please provide a close reason.",
          });
          return false;
        }

        if (!stCloseAmount) {
          dialog.alert({
            message: "Close Amount is a required field.",
          });
          return false;
        }

        // stCloseAmount should not be more than flAmount
        if (Number(flAmount) < Number(stCloseAmount)) {
          dialog.alert({
            message: "Close Amount cannot be more than Invoice amount.",
          });
          return false;
        }
      }
    }
  }

  if (!blSelectedItem) {
    dialog.alert({ message: "Please select at least one item." });
    return false;
  }

  return true;
}
n
Can you try using get Current Sublist value after selecting each line?
r
I think I figured it out, if you blank a select field by selecting the text then using the 'Delete' key, the value is not registered. You have to scroll all the up to the blank value in the select field.