var currentStatus = reversalRecord.getValue({ fieldId: 'status' }); log.debug('Current Status before Set:', currentStatus);

                reversalRecord.setValue({
                    fieldId: 'status',
                    value: "Approved"
                }); 

                // Log status after setting
                var newStatus = reversalRecord.getValue({
                    fieldId: 'status'
                });
                log.debug('New Status after Set:', newStatus);

Please help me to solve this issue

2

There are 2 best solutions below

0
bknights On

If that's a Journal Entry that you are saving you need to set the field 'approved' to true

0
Jose Sanchez-Capo On

In NetSuite SuiteScript 2.0, if you're using record.setValue to update a field in a custom record, you also need to commit the changes using the record.save() method to persist the changes to the database.

/**

  • @NApiVersion 2.x

  • @NScriptType Suitelet */ define(['N/record', 'N/log'], function(record, log) {

    function onRequest(context) { try { // Replace 'customrecord_your_custom_record_id' with the actual internal ID of your custom record type var customRecordId = 'customrecord_your_custom_record_id';

         // Replace 'your_custom_record_field_id' with the actual internal ID of the 'status' field in your custom record
         var statusFieldId = 'your_custom_record_field_id';
    
         // Replace 'your_custom_record_id' with the actual internal ID of the specific record you want to update
         var customRecordInstance = record.load({
             type: customRecordId,
             id: 'your_custom_record_id',
             isDynamic: true,
         });
    
         // Set the 'status' field value to 'approved'
         customRecordInstance.setValue({
             fieldId: statusFieldId,
             value: 'approved',
         });
    
         // Save the changes to the custom record
         var recordId = customRecordInstance.save();
    
         log.debug({
             title: 'Record Updated',
             details: 'Custom Record ID: ' + recordId,
         });
    
         context.response.write('Record Updated Successfully');
     } catch (e) {
         log.error({
             title: 'Error',
             details: e.toString(),
         });
    
         context.response.write('Error updating record: ' + e.message);
     }
    

    }

    return { onRequest: onRequest, }; });