title: How do I change a line item of a sales order using SuiteScript 2
body: <p>OK, this works in SuiteScript 1, but for some reason I can't get it to work with SuiteScript 2. What am I missing?</p>
  
  <p>Client side (on field changed/on line changed) or server side (on submit), I can't alter the lines on a sales order, e.g. set a custom field.</p>
  
  <p>Neither of these work. Either the function is not found or nothing happens. I've tried all sorts of different functions and combinations for setting the text or the value. I just doesn't seem to work:</p>
  
  <p>1.</p>
  
  <pre><code>Rec.setSublistText({
      sublistId : 'item',
      fieldId : 'custcol_example',
      line : i,
      value : "A"
  });
  </code></pre>
  
  <p>2.</p>
  
  <pre><code>Rec.selectLine({
      sublistId : 'item',
      line : i
  });
  Rec.setCurrentSublistText({
      sublistId : 'item',
      fieldId : 'custcol_example',
      value : "A",
      ignoreFieldChange: true
  });
  Rec.commitLine();
  </code></pre>
  
  <p>This works perfectly in SuiteScript 1</p>
  
  <pre><code>function clientFieldChanged(type, name, linenum) {
      var Count = nlapiGetLineItemCount("item");
      for (var i = 1; i &lt;= Count; i++) {
          nlapiSelectLineItem("item", i);
          nlapiSetCurrentLineItemValue("item", "custcol_example", "A", false, false);
          nlapiCommitLineItem("item");
      }
  }
  </code></pre>
  
  <p>As requested, a more complete SS2 example. Doesn't work.</p>
  
  <pre><code>function fieldChanged(scriptContext) {
          var Rec = scriptContext.currentRecord;
          var Count = Rec.getLineCount("item");
          for (var i = 0; i &lt; Count; i++) {
              Rec.selectLine({
                  sublistId : 'item',
                  line : i
              });
              Rec.setCurrentSublistText({
                  sublistId : 'item',
                  fieldId : 'custcol_example',
                  line : i,
                  value : "A"
              });
              Rec.commitLine();
          }
  }
  </code></pre>