How do you extend the create.js on a module level?

We have created a 1 to 1 relationship for 2 custom modules. Now when we create a related record based on the parent record we want to hide or do some customization on the create drawer. We have already achieved this but we have to copy the entire create.js file to custom/client/base/view/create/create.js. My question is can this be done on a modular level without the need to copy the entire file?
  • Hi EvilPeri,

    To answer your primary question, the method you described for customizing the create.js file is currently the only supported method. In researching your question with our engineering team, the suggestion came up to potentially handle this use case in another manner. 

    Here is an example that extends the Record view (which the Create view also extends) and appends some content to it without having to copy and paste the controller or the template.  You still have to copy and paste the metadata from my understanding.

    You can create your own view that extends the Create view and then replace the normal Create view with your custom Create view in only the module layouts that apply for this scenario. Unless you really need to override the view and not just add something to the Create view, our advice is to build an additional view and add it to the Create layouts where needed.

    Chris
  • Hi Chris,

    Thanks for the reply. The workaround you gave is the same as one of your articles on the developer guide on sugar. It would call the record.js of Module 1 but when you try and create a Module 2 record the customization doesn't seem to work. Also i need to add a few validations before i hit save.

    I did some digging up with your create layouts and views and started customizing the create-noduplicate and create-action which extends the default create view. Those two can be customized on a modular level.
  • Hi EvilPeri,

    After some further investigation, customizing extending create.js at a modular level is possible as you seem to have found. To help others encountering this same issue, module specific custom views can extend from the base one, if no module specific view for that module exists out of the box. 

    If the following example was created in custom/modules/<module name>/clients/base/views/create/create.js , it would do as expected and extend from the base create view. 

    ({     extendsFrom: 'CreateView',
        /**
         * Some extra functionality
         */
        doSomethingCool: function() {
        },
        _dispose: function() {
            //additional stuff before calling the core create _dispose goes here
            this._super('_dispose');
        }
    })
    Chris

  • Hi Chris,

    Another question is there a way to augment or extend the context or the data manager models? 

    My customization involves 3 modules, first M1 and M2 have a 1 to 1 relationship and M3 has a many to one relationship with M2. Now i want to pull all the subpanels (not just the data) of M2 and display it on M1. Is this possible to implement on sugarcrm 7.1.5 Pro now?
  • Chris, This doesn't seem to work for me! Could you please post a working example exending the create view for a module? I've been looking all over the place for this and there seem to be a lot of miss assumptions about it. Is it really possible?? Thanks!!
  • I have the same problem, do you have solution now? it seems to me that the create.js is not working but create-action.js is working. someone said it is an issue for 7.1.6 (community.sugarcrm.com/.../18823) but I am working on 7.2.0, is the issue still not fixed?
  • You can exende the create-action view or any of field views. I haven't manage to exend the create view, but I haven't tried in 7.2
  • it seems to me that extending create-action view is working but extending create view is not working in 7.2. so my only choice is to extend the create view rather than create-action view.
  • You can extend the field-views as well
  • Hi guys,

    I've had the same result on 7.5.1. I'm not able to extend create, but am able to extend create-actions.
1 2