-1

This is what I can provide in the coding part from my end:

function beforeSubmit(scriptContext) { var salesorder = scriptContext.newRecord;

    var discount = salesorder.getValue('discountitem');
    if(discount == ''){

        log.debug('Hi');

        var discountSearch = search.load({
            id   : 'customsearch_cg_ue_discount_in_order'    // ID of the saved search created.
        });
                    var searchResult = discountSearch.run().getRange({
            start: 0,
            end: 5
            });

                            for (var i = 0; i < searchResult.length; i++) {
                var  item = searchResult[i].getValue('itemid');
                log.debug('I am here ' + item);
                if(item == 'z10% Discount'){                      // Assigning this discount line on SO form.
                    log.debug('I should print :' + item);

                  salesorder.setText('discountitem',item.id);

                }
            }  

    }

}

2 Answers2

0

We used to do this at my company, till we moved away from additional discount lines (it kills performance on large transactions). The way we did it, though, was to grab all the lines and work backwards updating/creating discount lines depending on the item line information.

Not sure where you are on your code, though. If you include code and where you are stuck, viewers will be able to assist you much easier and faster. ;)

w3bguy
  • 2,215
  • 1
  • 19
  • 34
  • I am new to Java Script. Can you help with the code ? I feel Before Submit will be used in this one. – Kaul Shishir Apr 03 '18 at 12:33
  • 1
    Then you should get your company to run you through a course or not take on work until you have some experience with the necessary tools. – bknights Apr 03 '18 at 16:09
  • I have to agree with bknights. You are trying to do something that could very well screw up your financial system, if done wrong, and you don't know how to code. If you can provide what you have so far, I'm sure we can help out. I would also suggest you read up on SuiteScript (https://system.na1.netsuite.com/app/help/helpcenter.nl?fid=part_4563537633.html) and learn the basics of how to use it. – w3bguy Apr 04 '18 at 11:04
  • I have added the code. Please go through it @W3BGUY . Thanks! – Kaul Shishir Apr 04 '18 at 12:03
-1

there are multiple ways to do this as there is performance impact. If the line items are less then you can use Before Submit.

var count = nlapiGetLineItemCount('item'); for(var i=1;i<=count;i++){ //Insert new lines for each discount }

NetSuite Help
  • 218
  • 3
  • 12