Client Script Question – Remove items from Item sublist which are having unit price has greater than 50 bucks.

This is my code but when i tried to run this code, its now working , in execution log nothing is showing why ? Please help

define(['N/currentRecord'], function(currentRecord) {
        function sublistChangedRemoveItems(scriptContext) {
        try {
            var sublistName = scriptContext.sublistId;
            // Check if the sublist is the item sublist
            if (sublistName === 'item') {
              var currentRecord = scriptContext.currentRecord;
              var lineCount = currentRecord.getLineCount({
              for (var i = lineCount - 1; i >= 0; i--) {
                var unitPrice = currentRecord.getSublistValue({
                  sublistId: sublistName,
                  fieldId: 'rate',
                  line: i,
                // Check if the unit price is greater than 50 bucks
                if (unitPrice > 50) {
                    title: 'Removing item',
                    details: 'Item removed from sublist with unit price greater than 50 bucks',
                  // Remove the item from the sublist
                    sublistId: sublistName,
                    line: i,
        } catch (e) {
                title: "error entry",
                details: e
    return {
        sublistChanged: sublistChangedRemoveItems
Rookie Asked on June 14, 2023 in SuiteScript.
Add Comment
1 Answer(s)

Please remember that sublistChanged runs whenever you commit a line so it’s unusual to need to loop through the lines in this function.

You may wish to consider:

  • Using validateLine to prevent the user entering these lines in the first place.
  • Running your check on saveRecord and looping through the lines there.



Intermediate Answered on June 16, 2023.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.
  • This site made possible by our sponsors:   Tipalti   Celigo   Become a Sponsor   Become a Sponsor