I'm trying to use one select field to populate ano...
# suitescript
r
I'm trying to use one select field to populate another via client script. It appears there's no
currentRecord.setValue()
. How can I accomplish this? I want it to populate when the first field is selected, so beforeLoad/beforeSubmit/afterSubmit are not viable options.
b
currentRecord.get().setValue
i wouldn't recommend doing it like that, but thats the minimum
r
how would you recommend doing it?
i see what you mean. it's being called recursively, ad infinitum.
b
Copy code
/**
 * @NApiVersion 2.x
 * @NScriptType ClientScript
 */
define([], function() {
  function fieldChanged(context) {
    if (context.fieldId !== "custrecord72") {
      return;
    }
    var requestType = context.currentRecord.getValue({
      fieldId: "custrecord72" // sandbox
    });

    if (requestType === "1") {
      context.currentRecord.setValue({
        fieldId: "custrecord_cxt_engaged",
        value: "2" // Not engaged
      });
    }
  }
  return {
    fieldChanged: fieldChanged
  };
});
you dont need N/currentRecord, and what you said earlier
generally you want filtering on the field in fieldChanged