To find if any changes has been made to a suitelet form

Scenario:

I have created a suitelet form to edit a particular record. If there are no changes in the form, I have to block the submission and display a warning.

Solution:

Link a client script file to the necessary suitelet page and in the client script page give the below code.

define([‘N/log’, ‘N/ui/dialog’],

function (log, dialog) {

let isModified = false;

function fieldChanged(scriptContext) {

      isModified = true;

    }

function saveRecord(scriptContext) {

      if (!isModified) {

        dialog.alert({

          title: ‘Warning’,

          message: ‘No changes are being made.’

        });

        return false;

      }

      return true;

      

    }

return {

     fieldChanged: fieldChanged,

      saveRecord: saveRecord

    };

  });

here isModified stores the boolean value of whether any fields have been changed.

Leave a comment

Your email address will not be published. Required fields are marked *