I'm trying to override

module-sales/view/adminhtml/web/order/create/scripts.js file.

Added the custom js file in my requirejs-config.js file. But the issue is, What all changes I made to in custom script.js file is reflecting in Magento core functionalities also, For example in order page. I need to reflect the changes in my custom module pages only. How to make it possible?

Please, can anyone help?

  • Did u get any solution for this?
    – coderunner
    Commented Nov 30, 2017 at 8:06
  • @mani No. Im checking Commented Nov 30, 2017 at 9:49

2 Answers 2


You have to add custom.js file in your module layout xml file like this:

    <script src=path/cutom.js"/>

And put only that which you needed for that module only other code move to default custom.js.


I tried editing and overriding this file but was not able to find a proper way. As a workaround I created my extra functionality in another prototype object and called it inside a phtml defined in the sales_order_create_index layout file.




], function (jQuery, modal,loader) {
    window.addProduct = Class.create();

    addProduct.prototype = {
      //Custom code
     initialize: function () {
            //Code to run on Object Initialisation
      setPopUpContainer: function (trigger) {
            //Code to pull up a modal 

        reloadAreas: function () {
          // this accesses the order object from the scripts.js file and reloads the various areas in the page
          order.loadArea(['items', 'shipping_method', 'totals', 'billing_method'], true);




    require(["jquery", "prototype", "Magento_Sales/order/create/form", "Namespace_Module/js/customscript"], function ($) {

        window.CustomAddProduct = new addProduct();




<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
        <referenceContainer name="js"> 
            <block class="Namespace\Module\Block\Adminhtml\CustomBlock" template="Namespace_Module::custom-js.phtml" name="customblockname"/>

  • Hello Rohan, did you add require-config.js for that customscript.js? or add that script in head tag using <link src="vendor_Module::js/customscript.js" />
    – aravind
    Commented Dec 17, 2019 at 7:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.