I am struggling a bit with this user event script,...
# suitescript
d
I am struggling a bit with this user event script, I am trying to save a relationship to another custom record… all the debugging data comes back clear and it doesn’t appear that a exception is being thrown…. However the data is no persisted on the other object. Attached is code in thread.
Copy code
/**
 *@NApiVersion 2.x
 *@NModuleScope Public
 *@NScriptType UserEventScript
 */
define(['N/record', 'N/search', 'N/log'], function(record, search, log) {

  function onAfterSubmit(context) {

    var scaleReading = context.newRecord;
    log.debug('afterSubmit Triggered'+context.type);

    var scale = record.load({
      type: 'customrecord_mro_scale_scale',
      id: scaleReading.getValue('custrecord_mro_scale_scalereading_scale'),
      isDynamic: true
    });
    log.debug('scale serial: '+scale.getValue('custrecord_mro_scale_scale_serialnumber'));
    log.debug('scale reading id: '+scaleReading.id);
    try {
      scale.setValue('custrecord_mro_scale_scale_currentreadin', scaleReading.id);
      scale.save();
    }
    catch(e){
      log.debug(e);
    }
    return;
  }
  return {
    afterSubmit: onAfterSubmit
  };

});
b
whats the value of
Copy code
scale
  .getField({ fieldId: "custrecord_mro_scale_scale_currentreadin" })
  .getSelectOptions();
d
Copy code
[{"value":"1","text":"1"},{"value":"2","text":"2"},{"value":"3","text":"3"},{"value":"4","text":"4"
b
is scaleReading.id a number between 1 and 4
d
no
because the ID will always increment up everytime a new one is created
b
is the id you are trying to set in the list
d
ggrrrrlkjasdfkl;jsadfl;kjadfs
Ok I know what was happening
but now that leads to another question
I had access level and view level set to not editable thinking that this only controlled user level interface
Is it possible to dissallow editing of that field by h00man?
b
usually that is done by setting the displaytype
d
@battk Thanks, that worked….
@battk Is there a way that you know of to get the system to display a value of that realtionship such as {currentReading.reading} instead of just the ID?
b
create another field
and use the sourcing/filtering options