title: Can we update a Netsuite "Custom Record type" field by clicking a button?
body: <p>I have a Suitelet script to create a form, there I pull the information contained in a  &quot;Custom Record type&quot; as the default value for the form fields.
  Also create a ClientScript for the Suitelet form with the functions that are executed by clicking a button.
  The function works, but I don't know how to update the information of the custom record type.
  Here is part of my code:</p>
  <p>Suitelet:</p>
  <pre><code>/**
   *@NApiVersion 2.0
   *@NScriptType Suitelet
   */
  
   define(['N/record', 'N/search', 'N/ui/serverWidget'],
   function(record, search, serverWidget) { 
       function onRequest(context) { 
          try {
              if (context.request.method === 'GET') {
  
                  var form = serverWidget.createForm({
                      title: 'SKU Information'
                  });
  
                  form.clientScriptFileId  =  3060; 
     
                  //create fields groups to organize the fields
                  var itemgroup = form.addFieldGroup({
                      id : 'itemgroup',
                      label : 'Next item SKU Number'
                  });
  
                  var usegroup = form.addFieldGroup({
                      id : 'usegroup',
                      label : 'Who is using this?'
                  });
                  
                 //Add the fields
                  var skufield = form.addField({
                      id: 'skufield',
                      type: serverWidget.FieldType.TEXT,
                      label: 'SKU Number',
                      container: 'itemgroup'
                  });
                  skufield.isMandatory = true;
     
                  // create a field with the user using this numbers when clicking the button
                  var whousingskunumber = form.addField({
                      id: 'namefield',
                      type: serverWidget.FieldType.TEXT,
                      label: 'User:',
                      container: 'usegroup'
                  });
                  whousingskunumber.updateDisplayType({
                      displayType: serverWidget.FieldDisplayType.DISABLED
                  });
  
                  var usingsince = form.addField({
                      id: 'sincefield',
                      type: serverWidget.FieldType.TEXT,
                      label: 'Using since',
                      container: 'usegroup'
                  });
                  usingsince.updateDisplayType({
                      displayType: serverWidget.FieldDisplayType.DISABLED
                  });
  
                  // Add the buttons
                  form.addSubmitButton({
                      label: 'Update Number'
                  });
                  form.addResetButton({
                      label: 'Cancel'
                  });
                  
                  var useNumber = form.addButton({
                      label: 'Use this number',
                      id: 'useNumber',
                      functionName: 'useNumberFunction',
                  });
                  var releaseNumber = form.addButton({
                      label: 'Release usage',
                      id: 'relaseNumber',
                      functionName: 'relaseNumberFunction',
                  });
  
                 context.response.writePage(form);
                 
             } else {
                 // Section Four - Output - Used in all sections
                 var delimiter = /\u0001/;
                 var skuField = context.request.parameters.skufield;
                 var whoField = context.request.parameters.whofield;
     
                 var ccField = context.request.parameters.cctypefield;
     
                 context.response.write('You have entered:'
                     + '&lt;br/&gt;  New SKU Number: '+ whoField + skuField);
              }
  
              var skuNumObj = search.lookupFields({
                 type: 'customrecordere_lw_lastskunum',
                 id: 2,
                 columns: ['custrecord_ere_lw_usingsince', 'custrecordere_lw_nextskunum', 'custrecord_ere_lw_whousingskunum']
             });
             
             var usingSince = skuNumObj.custrecord_ere_lw_usingsince;
             var whoIsUsing = skuNumObj.custrecord_ere_lw_whousingskunum;
             var nextSku = skuNumObj.custrecordere_lw_nextskunum;
             
             skufield.defaultValue = nextSku;
             whousingskunumber.defaultValue = 'Nobody';
             usingsince.defaultValue = 'You can use it!';
  
          } catch (error) {
              log.error({title: 'Failed to get items to update', details: error});
          }
  
       }
   return {
       onRequest: onRequest
   };
  
  });
  </code></pre>
  <p>ClientScript</p>
  <pre><code>/**
   * @NApiVersion 2.x
   * @NScriptType ClientScript
   */
  //Noslen Pena
  
  define(['N/runtime', 'N/currentRecord', 'N/ui/dialog', 'N/search'],
      function (runtime, currentRecord, dialog, search) {
          function pageInit(context){
              try {
                  
  
              } catch (error) {
                  log.error({title: 'Failed initializing', details: error});
              }
          }
  
       function useNumberFunction(){
           try {
              var skuNumObj = search.lookupFields({
                  type: 'customrecordere_lw_lastskunum',
                  id: 2,
                  columns: ['custrecord_ere_lw_usingsince', 'custrecordere_lw_nextskunum', 'custrecord_ere_lw_whousingskunum']
              });
              var nextSku = skuNumObj.custrecordere_lw_nextskunum[0].value;
              skuNumObj.custrecordere_lw_nextskunum[0].value = Number(nextSku)+1;
  
              dialog.alert({
                  title: &quot;Information&quot;,
                  message: 'Remember to unlock after you have used'
              });
              context.skufield.updateDisplayType({
                  displayType: serverWidget.FieldDisplayType.DISABLED
              });
           } catch (error) {
              log.error({title: 'Failed clicking the button', details: error});
           }
       }
  
       function relaseNumberFunction(){
          dialog.alert({
              title: &quot;Thank you!&quot;,
              message: &quot;Remember to update the number and save the changes&quot;
          });
          record.namefield.setValue('Nobody');
          log.debug({title: 'liberaron el uso', details:'Nobody is using the number now'})
       }
  
      return {
          pageInit : pageInit,
          useNumberFunction    : useNumberFunction,
          relaseNumberFunction : relaseNumberFunction
  
      };
  
  });
  </code></pre>