How to make fields hidden in create view only- Sugar7?

I would like to make some fields of my custom module hidden in the create view and appear only in edit/detail view (record view)

  • Hi Surabhil,

    You can use this.createMode to check whether it is record mode or create mode.

    Then loop throrugh the fields array,then make fields you want to hidden by css.

    This make you fields to hidden.Alternatively you can use "field.hide()".

    This also will make fields to hide,but field label will present.So better,We can go with css visibility hidden.

    Below is the sample code snippet to hide field in create view.Make use of it,Here i am making sales stage field to hide in opportunity module.

    ({
      extendsFrom: 'CreateActionsView',
        initialize: function(options) {                     
          this._super('initialize', [options]);                                  
          this.on('render', this.testFunc, this);
        },
        testFunc: function() {
            if (this.createMode) {
               console.log("this create entered");
              _.each(this.fields, function(field) {
      if (_.isEqual(field.def.name, 'sales_stage')) {
         console.log("entered");
      //~ field.hide();
      this.$('[data-name=sales_stage]').css('visibility', 'hidden');
      }
               }, this);
            }
       },
    })
    

    Also side,you should know that changes are coming :

    CreateActionsView changes in Sugar 7.7.0 « Sugar Developer Blog – SugarCRM